mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 14:41:53 +00:00
fix: pass ctx keys get_price_list_rate_for reads, skip rate update on insert
update_item_rates passed price_not_uom_dependent, a key get_price_list_rate_for never reads, and omitted conversion_factor, so a stock-UOM price was never converted to the row UOM. The function's (historically misnamed) price_list_uom_dependant ctx key carries the Price List's price_not_uom_dependent value: truthy returns the found rate as-is, falsy multiplies by conversion_factor. Also guard on_update with is_new(): has_value_changed returns True when there is no doc_before_save, so every first save re-wrote item rates.
This commit is contained in:
@@ -179,7 +179,7 @@ class MaterialRequest(BuyingController):
|
|||||||
self.buying_price_list = buying_price_list
|
self.buying_price_list = buying_price_list
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
if self.buying_price_list and self.has_value_changed("buying_price_list"):
|
if not self.is_new() and self.buying_price_list and self.has_value_changed("buying_price_list"):
|
||||||
self.update_item_rates()
|
self.update_item_rates()
|
||||||
|
|
||||||
def update_item_rates(self):
|
def update_item_rates(self):
|
||||||
@@ -195,7 +195,8 @@ class MaterialRequest(BuyingController):
|
|||||||
"transaction_date": self.transaction_date,
|
"transaction_date": self.transaction_date,
|
||||||
"qty": item.qty,
|
"qty": item.qty,
|
||||||
"stock_uom": item.stock_uom,
|
"stock_uom": item.stock_uom,
|
||||||
"price_not_uom_dependent": price_not_uom_dependent,
|
"conversion_factor": item.conversion_factor,
|
||||||
|
"price_list_uom_dependant": price_not_uom_dependent,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
item.item_code,
|
item.item_code,
|
||||||
|
|||||||
Reference in New Issue
Block a user