mirror of
https://github.com/frappe/erpnext.git
synced 2026-07-28 06:58:17 +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.
(cherry picked from commit 6dcc0cab3a)
This commit is contained in:
@@ -198,7 +198,7 @@ class MaterialRequest(BuyingController):
|
||||
self.buying_price_list = buying_price_list
|
||||
|
||||
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()
|
||||
|
||||
def update_item_rates(self):
|
||||
@@ -214,7 +214,8 @@ class MaterialRequest(BuyingController):
|
||||
"transaction_date": self.transaction_date,
|
||||
"qty": item.qty,
|
||||
"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,
|
||||
|
||||
Reference in New Issue
Block a user