Hello
You need to create 2 extra fields to achieve this things.
Hope below Example help you.
Define fields
product_id = fields.Many2one('product.product', 'Product') # This standard field.
product_id_new = fields.Many2one('product.product', 'Product New') # This custom field.
product_id_old = fields.Many2one('product.product', 'Product Old') # This custom field.
Define onchange method
@api.onchange('product_id')
def onchange_product_id(self):
OldProduct = self.product_id_new.id
self.product_id_new = self.product_id.id
self.product_id_old = OldProduct
you can get old product on product_id_old fields.
Best Thanks,
Ankit H Gandhi.