fix: fetch rate from item price list when document is saved
(cherry picked from commit 1e4b9fbdf0)
This commit is contained in:
@@ -817,7 +817,7 @@ class AccountsController(TransactionBase):
|
|||||||
item.get(fieldname) is None
|
item.get(fieldname) is None
|
||||||
or fieldname in force_item_fields
|
or fieldname in force_item_fields
|
||||||
or (
|
or (
|
||||||
fieldname in ["serial_no", "batch_no"]
|
fieldname in ["serial_no", "batch_no", "rate", "price_list_rate"]
|
||||||
and item.get("use_serial_batch_fields")
|
and item.get("use_serial_batch_fields")
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -206,13 +206,21 @@ def update_stock(ctx, out, doc=None):
|
|||||||
filter_batches(batches, doc)
|
filter_batches(batches, doc)
|
||||||
|
|
||||||
for batch_no, batch_qty in batches.items():
|
for batch_no, batch_qty in batches.items():
|
||||||
|
rate = get_batch_based_item_price(
|
||||||
|
{"price_list": doc.selling_price_list, "uom": out.uom, "batch_no": batch_no},
|
||||||
|
out.item_code,
|
||||||
|
)
|
||||||
if batch_qty >= qty:
|
if batch_qty >= qty:
|
||||||
out.update({"batch_no": batch_no, "actual_batch_qty": qty})
|
out.update({"batch_no": batch_no, "actual_batch_qty": qty})
|
||||||
|
if rate:
|
||||||
|
out.update({"rate": rate, "price_list_rate": rate})
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
qty -= batch_qty
|
qty -= batch_qty
|
||||||
|
|
||||||
out.update({"batch_no": batch_no, "actual_batch_qty": batch_qty})
|
out.update({"batch_no": batch_no, "actual_batch_qty": qty})
|
||||||
|
if rate:
|
||||||
|
out.update({"rate": rate, "price_list_rate": rate})
|
||||||
|
|
||||||
if out.has_serial_no and out.has_batch_no and has_incorrect_serial_nos(ctx, out):
|
if out.has_serial_no and out.has_batch_no and has_incorrect_serial_nos(ctx, out):
|
||||||
kwargs["batches"] = [ctx.get("batch_no")] if ctx.get("batch_no") else [out.get("batch_no")]
|
kwargs["batches"] = [ctx.get("batch_no")] if ctx.get("batch_no") else [out.get("batch_no")]
|
||||||
|
|||||||
Reference in New Issue
Block a user