Skip to content

Commit

Permalink
fix: ignore pricing rule while making DN from Pick List (backport #42763
Browse files Browse the repository at this point in the history
) (#42768)

fix: ignore pricing rule while making DN from Pick List (#42763)

(cherry picked from commit 0db82ec)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Aug 14, 2024
1 parent 6a77683 commit aba54ba
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
4 changes: 4 additions & 0 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,10 @@ def make_delivery_note(source_name, target_doc=None, kwargs=None):
}

def set_missing_values(source, target):
if kwargs.get("ignore_pricing_rule"):
# Skip pricing rule when the dn is creating from the pick list
target.ignore_pricing_rule = 1

target.run_method("set_missing_values")
target.run_method("set_po_nos")
target.run_method("calculate_taxes_and_totals")
Expand Down
10 changes: 9 additions & 1 deletion erpnext/stock/doctype/pick_list/pick_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"consider_rejected_warehouses",
"get_item_locations",
"pick_manually",
"ignore_pricing_rule",
"section_break_6",
"scan_barcode",
"column_break_13",
Expand Down Expand Up @@ -200,11 +201,18 @@
"fieldname": "pick_manually",
"fieldtype": "Check",
"label": "Pick Manually"
},
{
"default": "0",
"description": "If enabled then system won't apply the pricing rule on the delivery note which will be create from the pick list",
"fieldname": "ignore_pricing_rule",
"fieldtype": "Check",
"label": "Ignore Pricing Rule"
}
],
"is_submittable": 1,
"links": [],
"modified": "2024-03-27 22:49:16.954637",
"modified": "2024-08-14 13:20:42.168827",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List",
Expand Down
3 changes: 2 additions & 1 deletion erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PickList(Document):
customer_name: DF.Data | None
for_qty: DF.Float
group_same_items: DF.Check
ignore_pricing_rule: DF.Check
locations: DF.Table[PickListItem]
material_request: DF.Link | None
naming_series: DF.Literal["STO-PICK-.YYYY.-"]
Expand Down Expand Up @@ -1144,7 +1145,7 @@ def create_dn_with_so(sales_dict, pick_list):
for customer in sales_dict:
for so in sales_dict[customer]:
delivery_note = None
kwargs = {"skip_item_mapping": True}
kwargs = {"skip_item_mapping": True, "ignore_pricing_rule": pick_list.ignore_pricing_rule}
delivery_note = create_delivery_note_from_sales_order(so, delivery_note, kwargs=kwargs)
break
if delivery_note:
Expand Down
61 changes: 61 additions & 0 deletions erpnext/stock/doctype/pick_list/test_pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,3 +1205,64 @@ def test_over_allowance_picking(self):
pl_doc.submit()

frappe.db.set_single_value("Stock Settings", "over_picking_allowance", 0)

def test_ignore_pricing_rule_in_pick_list(self):
frappe.flags.print_stmt = False
warehouse = "_Test Warehouse - _TC"
item = make_item(
properties={
"is_stock_item": 1,
"has_batch_no": 1,
"batch_number_series": "IPR-PICKLT-.######",
"create_new_batch": 1,
}
).name

make_stock_entry(
item=item,
to_warehouse=warehouse,
qty=2,
basic_rate=100,
)

pricing_rule = frappe.get_doc(
{
"doctype": "Pricing Rule",
"title": "Same Free Item",
"price_or_product_discount": "Product",
"selling": 1,
"apply_on": "Item Code",
"items": [
{
"item_code": item,
}
],
"same_item": 1,
"is_recursive": 1,
"recurse_for": 2,
"free_qty": 1,
"company": "_Test Company",
"customer": "_Test Customer",
}
)

pricing_rule.save()
frappe.flags.print_stmt = True

so = make_sales_order(item_code=item, qty=2, rate=100, do_not_save=True)
so.set_warehouse = warehouse
so.submit()

self.assertEqual(len(so.items), 2)
self.assertTrue(so.items[1].is_free_item)

pl = create_pick_list(so.name)
pl.ignore_pricing_rule = 1
pl.save()
pl.submit()

self.assertEqual(len(pl.locations), 1)

delivery_note = create_delivery_note(pl.name)

self.assertEqual(len(delivery_note.items), 1)

0 comments on commit aba54ba

Please sign in to comment.