Skip to Content
मेन्यू
This question has been flagged
1 Reply
2505 Views

In purchase order line i need to show the list_price of the product but that have a condition, today(may 30) if i make a purchase then the list_price is 100 will shown and after confirming the purchase if i change the list_price to 120 in the purchase it still needs to show 100 for that i have create a function with api.onchange()
It works well, 
but if i create a replenish with buy it creates a purchase order in that order the list_price is not updating
below is my onchange code

class PurchaseOrderInherit(models.Model):
_inherit = 'purchase.order.line'

mrp = fields.Float("MRP", help="Load from Product MRP(Latest)", digits='Product Price')

@api.onchange('product_template_id', 'product_id')
def _compute_mrp(self):
for rec in self:
if rec.product_id:
rec.mrp = rec.product_id.list_price
else:
rec.mrp = False

Kindly help me

Avatar
Discard
Author

NOTE : I have enabled purchase_product_matrix this module it will create product_template_id in po_order_line

Best Answer

I suggest replace on_change with compute method in you case sir, on_change doesn't store in the database, it just temporary data so that might be the cause

Avatar
Discard
Author

If i use compute every time i change list_price in product it changes in purchase
i don't need that, if the purchase confirmed after that even the list_price chnage i need the one before confirm that's why i use onchange

No, if you depend on fields ('product_template_id', 'product_id') when you change list_price on product it will not change 'mrp' unless you depend like this ('product_template_id.list_price', 'product_id.list_price')

Author

I have checked now, even though i use ('product_template_id', 'product_id') this on depends if i change list_price in product it changes in purchase

Related Posts Replies Views Activity
1
जन॰ 25
1149
0
दिस॰ 24
1149
1
जन॰ 24
1620
2
दिस॰ 24
14893
2
मार्च 15
5186