diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 739fc3d8fcbd2770987fa781a1fe1a92463f2d1d..df17d67156013cf17c0065768f6abbbc92c89d2c 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -1040,6 +1040,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") diff --git a/erpnext/stock/doctype/pick_list/pick_list.json b/erpnext/stock/doctype/pick_list/pick_list.json index 0e466e44d1b1cc9f60dc0b6e776d048b6fae9035..a5a46ff91871ad55678a38c321f3333fa6bb0156 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.json +++ b/erpnext/stock/doctype/pick_list/pick_list.json @@ -19,6 +19,7 @@ "consider_rejected_warehouses", "get_item_locations", "pick_manually", + "ignore_pricing_rule", "section_break_6", "scan_barcode", "column_break_13", @@ -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", diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index c1bac92faf68c6e94ef4ac6f8177f533871f7709..2a1733a2595c69949369d67f7d85aaad7fbf4a78 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -51,6 +51,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.-"] @@ -1154,7 +1155,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: diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index eb196772fb57991f7fbe42cdd66955a0b17b8d51..6c21d73985bac67555372e9e138d523d121d29ef 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -1208,3 +1208,64 @@ class TestPickList(FrappeTestCase): 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)