From dcef0de906fa3268dc22f1bc6477fdbbbb45c542 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 14:36:29 +0530 Subject: [PATCH 1/6] fix(pos): mode of payment disappears after save (cherry picked from commit 69c34cd7ae128dde56cde10c53b479331c33d56f) --- erpnext/accounts/doctype/pos_invoice/pos_invoice.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 2d6bef5bca5..9d585411582 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -439,7 +439,6 @@ class POSInvoice(SalesInvoice): self.paid_amount = 0 def set_account_for_mode_of_payment(self): - self.payments = [d for d in self.payments if d.amount or d.base_amount or d.default] for pay in self.payments: if not pay.account: pay.account = get_bank_cash_account(pay.mode_of_payment, self.company).get("account") From f2264fa58dedd14b7240b91233b560a80a895672 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 15:18:06 +0530 Subject: [PATCH 2/6] fix(pos): coupon code is applied even if ignore pricing rule is check (cherry picked from commit 81514516f3c7106a5b211796bb74ddad0a6add20) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 15 +++++++++++ .../selling/page/point_of_sale/pos_payment.js | 25 +++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 4801b333df9..a6c223385a3 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2264,6 +2264,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, +<<<<<<< HEAD coupon_code: function() { var me = this; frappe.run_serially([ @@ -2272,6 +2273,20 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => this.frm.doc.ignore_pricing_rule=0, () => me.apply_pricing_rule() ]); +======= + coupon_code() { + if (this.frm.doc.coupon_code || this.frm._last_coupon_code) { + // reset pricing rules if coupon code is set or is unset + const _ignore_pricing_rule = this.frm.doc.ignore_pricing_rule; + return frappe.run_serially([ + () => this.frm.doc.ignore_pricing_rule=1, + () => this.frm.trigger('ignore_pricing_rule'), + () => this.frm.doc.ignore_pricing_rule=_ignore_pricing_rule, + () => this.frm.trigger('apply_pricing_rule'), + () => this.frm._last_coupon_code = this.frm.doc.coupon_code + ]); + } +>>>>>>> 81514516f3 (fix(pos): coupon code is applied even if ignore pricing rule is check) } }); diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js index 4d75e6ef1bf..1e9f6d7d920 100644 --- a/erpnext/selling/page/point_of_sale/pos_payment.js +++ b/erpnext/selling/page/point_of_sale/pos_payment.js @@ -170,17 +170,20 @@ erpnext.PointOfSale.Payment = class { }); frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => { - if (!frm.doc.ignore_pricing_rule) { - if (frm.doc.coupon_code) { - frappe.run_serially([ - () => frm.doc.ignore_pricing_rule=1, - () => frm.trigger('ignore_pricing_rule'), - () => frm.doc.ignore_pricing_rule=0, - () => frm.trigger('apply_pricing_rule'), - () => frm.save(), - () => this.update_totals_section(frm.doc) - ]); - } + if (!frm.doc.ignore_pricing_rule && frm.doc.coupon_code) { + frappe.run_serially([ + () => frm.doc.ignore_pricing_rule=1, + () => frm.trigger('ignore_pricing_rule'), + () => frm.doc.ignore_pricing_rule=0, + () => frm.trigger('apply_pricing_rule'), + () => frm.save(), + () => this.update_totals_section(frm.doc) + ]); + } else if (frm.doc.ignore_pricing_rule && frm.doc.coupon_code) { + frappe.show_alert({ + message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."), + indicator: "orange" + }); } }); From 6bb1dccddd3ed903177aaff186a2655d89c23eb6 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 15:45:52 +0530 Subject: [PATCH 3/6] fix: merge conflicts --- erpnext/public/js/controllers/transaction.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a6c223385a3..a89776250f2 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2264,17 +2264,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, -<<<<<<< HEAD coupon_code: function() { - var me = this; - frappe.run_serially([ - () => this.frm.doc.ignore_pricing_rule=1, - () => me.ignore_pricing_rule(), - () => this.frm.doc.ignore_pricing_rule=0, - () => me.apply_pricing_rule() - ]); -======= - coupon_code() { if (this.frm.doc.coupon_code || this.frm._last_coupon_code) { // reset pricing rules if coupon code is set or is unset const _ignore_pricing_rule = this.frm.doc.ignore_pricing_rule; @@ -2286,7 +2276,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => this.frm._last_coupon_code = this.frm.doc.coupon_code ]); } ->>>>>>> 81514516f3 (fix(pos): coupon code is applied even if ignore pricing rule is check) } }); From afade046fb60c77c1099dc3caaf2367a6ed4d214 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 25 Feb 2022 23:07:04 +0530 Subject: [PATCH 4/6] fix: org chart connectors not rendered when Employee Naming is set to Full Name (backport #29997) (#29998) Co-authored-by: Rucha Mahabal --- .../js/hierarchy_chart/hierarchy_chart_desktop.js | 14 ++++++++------ .../js/hierarchy_chart/hierarchy_chart_mobile.js | 9 +++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js index 831626aa915..a585aa614fb 100644 --- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js +++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js @@ -304,12 +304,13 @@ erpnext.HierarchyChart = class { } get_child_nodes(node_id) { + let me = this; return new Promise(resolve => { frappe.call({ - method: this.method, + method: me.method, args: { parent: node_id, - company: this.company + company: me.company } }).then(r => resolve(r.message)); }); @@ -350,12 +351,13 @@ erpnext.HierarchyChart = class { } get_all_nodes() { + let me = this; return new Promise(resolve => { frappe.call({ method: 'erpnext.utilities.hierarchy_chart.get_all_nodes', args: { - method: this.method, - company: this.company + method: me.method, + company: me.company }, callback: (r) => { resolve(r.message); @@ -427,8 +429,8 @@ erpnext.HierarchyChart = class { add_connector(parent_id, child_id) { // using pure javascript for better performance - const parent_node = document.querySelector(`#${parent_id}`); - const child_node = document.querySelector(`#${child_id}`); + const parent_node = document.getElementById(`${parent_id}`); + const child_node = document.getElementById(`${child_id}`); let path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js index 0a8ba78f643..52236e7df96 100644 --- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js +++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js @@ -235,7 +235,7 @@ erpnext.HierarchyChartMobile = class { let me = this; return new Promise(resolve => { frappe.call({ - method: this.method, + method: me.method, args: { parent: node_id, company: me.company, @@ -286,8 +286,8 @@ erpnext.HierarchyChartMobile = class { } add_connector(parent_id, child_id) { - const parent_node = document.querySelector(`#${parent_id}`); - const child_node = document.querySelector(`#${child_id}`); + const parent_node = document.getElementById(`${parent_id}`); + const child_node = document.getElementById(`${child_id}`); const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); @@ -518,7 +518,8 @@ erpnext.HierarchyChartMobile = class { level.nextAll('li').remove(); let node_object = this.nodes[node.id]; - let current_node = level.find(`#${node.id}`).detach(); + let current_node = level.find(`[id="${node.id}"]`).detach(); + current_node.removeClass('active-child active-path'); node_object.expanded = 0; From 067ede76ea0851a29e270e150f482368e0afa194 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Sat, 26 Feb 2022 11:13:00 +0530 Subject: [PATCH 5/6] fix: validate Work Order qty against Production Plan (#29721) * fix: validate Work Order qty against Production Plan * chore: err msg when max_qty is 0 * test: add test for overproduction * fix: CI --- .../production_plan/test_production_plan.py | 20 +++++++++++-------- .../doctype/work_order/work_order.py | 15 ++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index d88e10a564c..2359815813d 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -9,6 +9,7 @@ from erpnext.manufacturing.doctype.production_plan.production_plan import ( get_sales_orders, get_warehouse_list, ) +from erpnext.manufacturing.doctype.work_order.work_order import OverProductionError from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.stock.doctype.item.test_item import create_item from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry @@ -466,26 +467,29 @@ class TestProductionPlan(ERPNextTestCase): bom = make_bom(item=item, raw_materials=raw_materials) # Create Production Plan - pln = create_production_plan(item_code=bom.item, planned_qty=10) + pln = create_production_plan(item_code=bom.item, planned_qty=5) # All the created Work Orders wo_list = [] - # Create and Submit 1st Work Order for 5 qty - create_work_order(item, pln, 5) + # Create and Submit 1st Work Order for 3 qty + create_work_order(item, pln, 3) + pln.reload() + self.assertEqual(pln.po_items[0].ordered_qty, 3) + + # Create and Submit 2nd Work Order for 2 qty + create_work_order(item, pln, 2) pln.reload() self.assertEqual(pln.po_items[0].ordered_qty, 5) - # Create and Submit 2nd Work Order for 3 qty - create_work_order(item, pln, 3) - pln.reload() - self.assertEqual(pln.po_items[0].ordered_qty, 8) + # Overproduction + self.assertRaises(OverProductionError, create_work_order, item=item, pln=pln, qty=2) # Cancel 1st Work Order wo1 = frappe.get_doc("Work Order", wo_list[0]) wo1.cancel() pln.reload() - self.assertEqual(pln.po_items[0].ordered_qty, 3) + self.assertEqual(pln.po_items[0].ordered_qty, 2) # Cancel 2nd Work Order wo2 = frappe.get_doc("Work Order", wo_list[1]) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index f50c82c66b6..204a6df6289 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -632,6 +632,21 @@ class WorkOrder(Document): if not self.qty > 0: frappe.throw(_("Quantity to Manufacture must be greater than 0.")) + if self.production_plan and self.production_plan_item: + qty_dict = frappe.db.get_value("Production Plan Item", self.production_plan_item, ["planned_qty", "ordered_qty"], as_dict=1) + + allowance_qty =flt(frappe.db.get_single_value("Manufacturing Settings", + "overproduction_percentage_for_work_order"))/100 * qty_dict.get("planned_qty", 0) + + max_qty = qty_dict.get("planned_qty", 0) + allowance_qty - qty_dict.get("ordered_qty", 0) + + if max_qty < 1: + frappe.throw(_("Cannot produce more item for {0}") + .format(self.production_item), OverProductionError) + elif self.qty > max_qty: + frappe.throw(_("Cannot produce more than {0} items for {1}") + .format(max_qty, self.production_item), OverProductionError) + def validate_transfer_against(self): if not self.docstatus == 1: # let user configure operations until they're ready to submit From 5d69a182f604e0f4b2ed75891a7b21e64ff25ea5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 26 Feb 2022 12:12:10 +0530 Subject: [PATCH 6/6] fix(ux): make "allow zero valuation rate" readonly if "s_warehouse" is set (#29681) (#30002) * chore: make allow zero valuation rate readonly if s_warehouse is set * fix: setting the checkbox to zero whenever the source warehouse is set * fix: remove allow_on_submit and refresh trigger Co-authored-by: Ankush Menat (cherry picked from commit 77ffcd3aed9b6fb99bc6f508897d3ebe6880de15) Co-authored-by: Sagar Sharma --- erpnext/stock/doctype/stock_entry/stock_entry.js | 6 ++++++ .../stock_entry_detail/stock_entry_detail.json | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index fc9d1ed98f7..61466cff032 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -627,6 +627,12 @@ frappe.ui.form.on('Stock Entry Detail', { frm.events.set_serial_no(frm, cdt, cdn, () => { frm.events.get_warehouse_details(frm, cdt, cdn); }); + + // set allow_zero_valuation_rate to 0 if s_warehouse is selected. + let item = frappe.get_doc(cdt, cdn); + if (item.s_warehouse) { + item.allow_zero_valuation_rate = 0; + } }, t_warehouse: function(frm, cdt, cdn) { diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index 2282b6aa167..a6b21891715 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -1,7 +1,7 @@ { "actions": [], "autoname": "hash", - "creation": "2013-03-29 18:22:12", + "creation": "2022-02-05 00:17:49.860824", "doctype": "DocType", "document_type": "Other", "editable_grid": 1, @@ -340,13 +340,13 @@ "label": "More Information" }, { - "allow_on_submit": 1, "default": "0", "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "label": "Allow Zero Valuation Rate", "no_copy": 1, - "print_hide": 1 + "print_hide": 1, + "read_only_depends_on": "eval:doc.s_warehouse" }, { "allow_on_submit": 1, @@ -556,12 +556,14 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-06-22 16:47:11.268975", + "modified": "2022-02-26 00:51:24.963653", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail", + "naming_rule": "Random", "owner": "Administrator", "permissions": [], "sort_field": "modified", - "sort_order": "ASC" + "sort_order": "ASC", + "states": [] } \ No newline at end of file