Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dynamic condition in the pricing rule not working (backport #42467) #42495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
me.in_apply_price_list = true;
return this.frm.call({
method: "erpnext.stock.get_item_details.apply_price_list",
args: { args: args },
args: { args: args, doc: me.frm.doc },
callback: function(r) {
if (!r.exc) {
frappe.run_serially([
Expand Down
8 changes: 4 additions & 4 deletions erpnext/stock/get_item_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ def get_batch_qty(batch_no, warehouse, item_code):


@frappe.whitelist()
def apply_price_list(args, as_doc=False):
def apply_price_list(args, as_doc=False, doc=None):
"""Apply pricelist on a document-like dict object and return as
{'parent': dict, 'children': list}

Expand Down Expand Up @@ -1228,7 +1228,7 @@ def apply_price_list(args, as_doc=False):
for item in item_list:
args_copy = frappe._dict(args.copy())
args_copy.update(item)
item_details = apply_price_list_on_item(args_copy)
item_details = apply_price_list_on_item(args_copy, doc=doc)
children.append(item_details)

if as_doc:
Expand All @@ -1246,10 +1246,10 @@ def apply_price_list(args, as_doc=False):
return {"parent": parent, "children": children}


def apply_price_list_on_item(args):
def apply_price_list_on_item(args, doc=None):
item_doc = frappe.db.get_value("Item", args.item_code, ["name", "variant_of"], as_dict=1)
item_details = get_price_list_rate(args, item_doc)
item_details.update(get_pricing_rule_for_item(args))
item_details.update(get_pricing_rule_for_item(args, doc=doc))

return item_details

Expand Down
Loading