I am working in Odoo 12 in the model product.template
trying to order the records within a One2Many table, which is in the modelproduct.supplierinfo
To sort the records I am using:
supplier = self.env['product.supplierinfo'].search([('id', '=', id_ultimo_costo)], order='id asc')
The function is executed without errors, however, the table is not affected at any time, that is, it does not order the records.
It is worth mentioning that I do not want to order the view , but the records of the table
Here is the code I am using & an image of the table:
@api.one
@api.depends('seller_ids')
def _order_table(self):
_logger = logging.getLogger(__name__)
product_search = self.env['product.product'].search([('default_code', '=', self.default_code)], limit=1)
all_seller_ids = product_search.seller_ids.ids
if all_seller_ids:
id_ultimo_costo = all_seller_ids[:]
supplier = self.env['product.supplierinfo'].search([('id', '=', id_ultimo_costo)], order='id asc')
sorted(supplier)
_logger.info('IDS DE SELLERS: %s', all_seller_ids)
You can use the reserved field
_order
for your model'product.supplierinfo'
, like this depending on what you need:Hope this answer can help you.