From 3e7a8abf296897eda59cd4500847564311c5bbbc Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 7 Apr 2020 21:00:57 +0530 Subject: [PATCH 01/15] feat: Provision to set Default Item Manufacturer - Is Default checkbox added in Item Manufacturer - Default Item Manufacturer and Part No fields added to Item Master - Manufacturer Part No field editable in all child tables with validation - Manufacturer and Part No auto fetched via get_item_details in child table --- .../purchase_invoice_item.json | 5 +-- .../purchase_order_item.json | 5 +-- .../supplier_quotation_item.json | 7 ++-- erpnext/public/js/controllers/buying.js | 26 ++++++++++++- erpnext/stock/doctype/item/item.json | 16 +++++++- .../item_manufacturer/item_manufacturer.json | 14 ++++++- .../item_manufacturer/item_manufacturer.py | 38 +++++++++++++++++++ .../material_request_item.json | 5 +-- .../purchase_receipt_item.json | 5 +-- erpnext/stock/get_item_details.py | 3 ++ 10 files changed, 105 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 9c974260a25..db3f72ada08 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -754,8 +754,7 @@ { "fieldname": "manufacturer_part_no", "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 1 + "label": "Manufacturer Part Number" }, { "depends_on": "is_fixed_asset", @@ -777,7 +776,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-04-01 14:20:17.297284", + "modified": "2020-04-07 18:34:35.104178", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json index 6768dfabfea..e37e1dd99d8 100644 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.json @@ -702,8 +702,7 @@ { "fieldname": "manufacturer_part_no", "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 1 + "label": "Manufacturer Part Number" }, { "default": "0", @@ -723,7 +722,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2019-12-06 13:17:12.142799", + "modified": "2020-04-07 18:35:17.558928", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order Item", diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json index 7d7d6f4d3db..b50e834ec73 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json @@ -1,4 +1,5 @@ { + "actions": [], "autoname": "hash", "creation": "2013-05-22 12:43:10", "doctype": "DocType", @@ -522,8 +523,7 @@ { "fieldname": "manufacturer_part_no", "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 1 + "label": "Manufacturer Part Number" }, { "fieldname": "column_break_15", @@ -532,7 +532,8 @@ ], "idx": 1, "istable": 1, - "modified": "2019-06-02 05:32:46.019237", + "links": [], + "modified": "2020-04-07 18:35:51.175947", "modified_by": "Administrator", "module": "Buying", "name": "Supplier Quotation Item", diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 27a9de95e0e..afbdbc661d3 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -379,7 +379,31 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }); } - } + }, + + manufacturer_part_no: function(doc, cdt, cdn) { + const row = locals[cdt][cdn]; + + if (row.manufacturer_part_no) { + frappe.model.get_value('Item Manufacturer', + { + 'item_code': row.item_code, + 'manufacturer': row.manufacturer, + 'manufacturer_part_no': row.manufacturer_part_no + }, + 'name', + function(data) { + if (!data) { + let msg = { + message: __("Manufacturer Part Number {0} is invalid", [row.manufacturer_part_no]), + title: __("Invalid Part Number") + } + frappe.throw(msg); + } + }); + + } + } }); cur_frm.add_fetch('project', 'cost_center', 'cost_center'); diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index aa6b2fedd7c..7d2e3112fb3 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -114,6 +114,8 @@ "is_sub_contracted_item", "column_break_74", "customer_code", + "default_item_manufacturer", + "default_manufacturer_part_no", "website_section", "show_in_website", "show_variant_in_website", @@ -1038,6 +1040,18 @@ "fieldname": "auto_create_assets", "fieldtype": "Check", "label": "Auto Create Assets on Purchase" + }, + { + "fieldname": "default_item_manufacturer", + "fieldtype": "Data", + "label": "Default Item Manufacturer", + "read_only": 1 + }, + { + "fieldname": "default_manufacturer_part_no", + "fieldtype": "Data", + "label": "Default Manufacturer Part No", + "read_only": 1 } ], "has_web_view": 1, @@ -1046,7 +1060,7 @@ "image_field": "image", "links": [], "max_attachments": 1, - "modified": "2020-03-24 16:14:36.950677", + "modified": "2020-04-07 15:56:06.195722", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json index 956c92e6738..0cef6eafaef 100644 --- a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json +++ b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "creation": "2019-06-02 04:41:37.332911", "doctype": "DocType", @@ -10,7 +11,8 @@ "manufacturer_part_no", "column_break_3", "item_name", - "description" + "description", + "is_default" ], "fields": [ { @@ -52,9 +54,17 @@ "fieldtype": "Small Text", "label": "Description", "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_default", + "fieldtype": "Check", + "in_list_view": 1, + "label": "Is Default" } ], - "modified": "2019-06-06 19:07:31.175919", + "links": [], + "modified": "2020-04-07 20:25:55.507905", "modified_by": "Administrator", "module": "Stock", "name": "Item Manufacturer", diff --git a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py index 67eab82d970..c27d1be7892 100644 --- a/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py +++ b/erpnext/stock/doctype/item_manufacturer/item_manufacturer.py @@ -11,6 +11,10 @@ from frappe.model.document import Document class ItemManufacturer(Document): def validate(self): self.validate_duplicate_entry() + self.manage_default_item_manufacturer() + + def on_trash(self): + self.manage_default_item_manufacturer(delete=True) def validate_duplicate_entry(self): if self.is_new(): @@ -24,6 +28,40 @@ class ItemManufacturer(Document): frappe.throw(_("Duplicate entry against the item code {0} and manufacturer {1}") .format(self.item_code, self.manufacturer)) + def manage_default_item_manufacturer(self, delete=False): + from frappe.model.utils import set_default + + item = frappe.get_doc("Item", self.item_code) + default_manufacturer = item.default_item_manufacturer + default_part_no = item.default_manufacturer_part_no + + if not self.is_default: + # if unchecked and default in Item master, clear it. + if default_manufacturer == self.manufacturer and default_part_no == self.manufacturer_part_no: + frappe.db.set_value("Item", item.name, + { + "default_item_manufacturer": None, + "default_manufacturer_part_no": None + }) + + elif self.is_default: + set_default(self, "item_code") + manufacturer, manufacturer_part_no = default_manufacturer, default_part_no + + if delete: + manufacturer, manufacturer_part_no = None, None + + elif (default_manufacturer != self.manufacturer) or \ + (default_manufacturer == self.manufacturer and default_part_no != self.manufacturer_part_no): + manufacturer = self.manufacturer + manufacturer_part_no = self.manufacturer_part_no + + frappe.db.set_value("Item", item.name, + { + "default_item_manufacturer": manufacturer, + "default_manufacturer_part_no": manufacturer_part_no + }) + @frappe.whitelist() def get_item_manufacturer_part_no(item_code, manufacturer): return frappe.db.get_value("Item Manufacturer", diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.json b/erpnext/stock/doctype/material_request_item/material_request_item.json index 9d1dafb136b..30206b62d0c 100644 --- a/erpnext/stock/doctype/material_request_item/material_request_item.json +++ b/erpnext/stock/doctype/material_request_item/material_request_item.json @@ -404,14 +404,13 @@ { "fieldname": "manufacturer_part_no", "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 1 + "label": "Manufacturer Part Number" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2020-02-25 03:09:10.698967", + "modified": "2020-04-07 18:37:54.495112", "modified_by": "Administrator", "module": "Stock", "name": "Material Request Item", diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index a8b9c81ff0e..b15f23c3038 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -801,8 +801,7 @@ { "fieldname": "manufacturer_part_no", "fieldtype": "Data", - "label": "Manufacturer Part Number", - "read_only": 1 + "label": "Manufacturer Part Number" }, { "depends_on": "is_fixed_asset", @@ -832,7 +831,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2020-03-11 14:19:48.799370", + "modified": "2020-04-07 18:38:21.141558", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index b1bfc90588f..61429cc1c11 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -341,6 +341,9 @@ def get_basic_details(args, item, overwrite_warehouse=True): else: out["manufacturer_part_no"] = None out["manufacturer"] = None + else: + out["manufacturer"], out["manufacturer_part_no"] = frappe.get_value("Item", item.name, + ["default_item_manufacturer", "default_manufacturer_part_no"] ) child_doctype = args.doctype + ' Item' meta = frappe.get_meta(child_doctype) From 10a6a2d77f4e62eda27e04348958a483943cabcb Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Mon, 13 Apr 2020 16:40:13 +0530 Subject: [PATCH 02/15] fix: show positive taxes in credit notes --- erpnext/controllers/taxes_and_totals.py | 3 +-- erpnext/templates/includes/itemised_tax_breakup.html | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 95e661aa221..4e568e2795a 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -667,8 +667,7 @@ def get_itemised_tax_breakup_html(doc): itemised_tax=itemised_tax, itemised_taxable_amount=itemised_taxable_amount, tax_accounts=tax_accounts, - conversion_rate=doc.conversion_rate, - currency=doc.currency + doc=doc ) ) diff --git a/erpnext/templates/includes/itemised_tax_breakup.html b/erpnext/templates/includes/itemised_tax_breakup.html index c27e4cede0d..c2f13539cdf 100644 --- a/erpnext/templates/includes/itemised_tax_breakup.html +++ b/erpnext/templates/includes/itemised_tax_breakup.html @@ -16,7 +16,11 @@ {{ item }} - {{ frappe.utils.fmt_money(itemised_taxable_amount.get(item, 0), None, currency) }} + {% if doc.get('is_return') %} + {{ frappe.utils.fmt_money((itemised_taxable_amount.get(item, 0))|abs, None, doc.currency) }} + {% else %} + {{ frappe.utils.fmt_money(itemised_taxable_amount.get(item, 0), None, doc.currency) }} + {% endif %} {% for tax_account in tax_accounts %} {% set tax_details = taxes.get(tax_account) %} @@ -25,7 +29,11 @@ {% if tax_details.tax_rate or not tax_details.tax_amount %} ({{ tax_details.tax_rate }}%) {% endif %} - {{ frappe.utils.fmt_money(tax_details.tax_amount / conversion_rate, None, currency) }} + {% if doc.get('is_return') %} + {{ frappe.utils.fmt_money((tax_details.tax_amount / doc.conversion_rate)|abs, None, doc.currency) }} + {% else %} + {{ frappe.utils.fmt_money(tax_details.tax_amount / doc.conversion_rate, None, doc.currency) }} + {% endif %} {% else %} From fc31dbef1244660c45a5b2ccb6416bd5a1193cc9 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 14 Apr 2020 12:53:54 +0530 Subject: [PATCH 03/15] fix: on changing qty free item not removed (#21251) --- .../accounts/doctype/pricing_rule/utils.py | 7 ++--- erpnext/public/js/controllers/transaction.js | 26 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 2ffa27f6d99..100bb1d3e38 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -178,7 +178,8 @@ def filter_pricing_rules(args, pricing_rules, doc=None): if pricing_rules[0].mixed_conditions and doc: stock_qty, amount, items = get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args) - pricing_rules[0].apply_rule_on_other_items = items + for pricing_rule_args in pricing_rules: + pricing_rule_args.apply_rule_on_other_items = items elif pricing_rules[0].is_cumulative: items = [args.get(frappe.scrub(pr_doc.get('apply_on')))] @@ -329,9 +330,9 @@ def get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args): if pr_doc.mixed_conditions: amt = args.get('qty') * args.get("price_list_rate") if args.get("item_code") != row.get("item_code"): - amt = row.get('qty') * row.get("price_list_rate") + amt = row.get('qty') * (row.get("price_list_rate") or args.get("rate")) - sum_qty += row.get("stock_qty") or args.get("stock_qty") + sum_qty += row.get("stock_qty") or args.get("stock_qty") or args.get("qty") sum_amt += amt if pr_doc.is_cumulative: diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 0c63c33f7ab..8e8c48feb0d 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -559,7 +559,13 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, () => me.conversion_factor(doc, cdt, cdn, true), - () => me.remove_pricing_rule(item) + () => me.remove_pricing_rule(item), + () => { + if (item.apply_rule_on_other_items) { + let key = item.name; + me.apply_rule_on_other_items({key: item}); + } + } ]); } } @@ -1394,20 +1400,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ apply_rule_on_other_items: function(args) { const me = this; - const fields = ["discount_percentage", "discount_amount", "rate"]; + const fields = ["discount_percentage", "pricing_rules", "discount_amount", "rate"]; for(var k in args) { let data = args[k]; - me.frm.doc.items.forEach(d => { - if (in_list(data.apply_rule_on_other_items, d[data.apply_rule_on])) { - for(var k in data) { - if (in_list(fields, k)) { - frappe.model.set_value(d.doctype, d.name, k, data[k]); + if (data && data.apply_rule_on_other_items) { + me.frm.doc.items.forEach(d => { + if (in_list(data.apply_rule_on_other_items, d[data.apply_rule_on])) { + for(var k in data) { + if (in_list(fields, k) && data[k]) { + frappe.model.set_value(d.doctype, d.name, k, data[k]); + } } } - } - }); + }); + } } }, From b84333f26e366078be6fa331f5372e02ae055d6a Mon Sep 17 00:00:00 2001 From: Himanshu Date: Tue, 14 Apr 2020 13:02:03 +0530 Subject: [PATCH 04/15] fix: move to hooks (#21205) --- erpnext/hooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 2f07e15f1e3..6b6d1e22581 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -347,6 +347,8 @@ get_site_info = 'erpnext.utilities.get_site_info' payment_gateway_enabled = "erpnext.accounts.utils.create_payment_gateway_account" +communication_doctypes = ["Customer", "Supplier"] + regional_overrides = { 'France': { 'erpnext.tests.test_regional.test_method': 'erpnext.regional.france.utils.test_method' From a1b747c3f3c863e659d834a9ae653223f494e66e Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Tue, 14 Apr 2020 14:05:14 +0530 Subject: [PATCH 05/15] fix: show stock UOM in POS --- .../page/point_of_sale/point_of_sale.js | 2 +- .../page/point_of_sale/point_of_sale.py | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index df487833a8c..f175687f26c 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -1176,7 +1176,7 @@ class POSCart { return `
+ data-batch-no="${batch_no}" title="Item: ${item.item_name} Available Qty: ${item.actual_qty} ${item.stock_uom}">
${item.item_name}
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index 17136e04723..dfa0f7f2dbf 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -37,20 +37,33 @@ def get_items(start, page_length, price_list, item_group, search_value="", pos_p lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt']) # locate function is used to sort by closest match from the beginning of the value - result = [] - items_data = frappe.db.sql(""" SELECT name as item_code, - item_name, image as item_image, idx as idx,is_stock_item + items_data = frappe.db.sql(""" + SELECT + name AS item_code, + item_name, + stock_uom, + image AS item_image, + idx AS idx, + is_stock_item FROM `tabItem` WHERE - disabled = 0 and has_variants = 0 and is_sales_item = 1 - and item_group in (select name from `tabItem Group` where lft >= {lft} and rgt <= {rgt}) - and {condition} order by idx desc limit {start}, {page_length}""" + disabled = 0 + AND has_variants = 0 + AND is_sales_item = 1 + AND item_group in (SELECT name FROM `tabItem Group` WHERE lft >= {lft} AND rgt <= {rgt}) + AND {condition} + ORDER BY + idx desc + LIMIT + {start}, {page_length}""" .format( - start=start, page_length=page_length, - lft=lft, rgt=rgt, + start=start, + page_length=page_length, + lft=lft, + rgt=rgt, condition=condition ), as_dict=1) From 10a6f4bd058f7944ce7897c7288c0b23b3098249 Mon Sep 17 00:00:00 2001 From: vishdha Date: Mon, 13 Apr 2020 08:22:34 +0530 Subject: [PATCH 06/15] fix: Chart of account importer UX improved --- erpnext/accounts/doctype/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 0a72d4fa4e6..bd013dc60e3 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -89,7 +89,7 @@ class Account(NestedSet): throw(_("Root cannot be edited."), RootNotEditable) if not self.parent_account and not self.is_group: - frappe.throw(_("Root Account must be a group")) + frappe.throw(_("Root Account must be a group for {0}".format(self.name))) def validate_root_company_and_sync_account_to_children(self): # ignore validation while creating new compnay or while syncing to child companies From 5008be1db58e5c40a8a91ff172e1d57ce63fcf38 Mon Sep 17 00:00:00 2001 From: vishdha Date: Mon, 13 Apr 2020 18:43:14 +0530 Subject: [PATCH 07/15] fix: message bold --- erpnext/accounts/doctype/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index bd013dc60e3..9e29ce6748f 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -89,7 +89,7 @@ class Account(NestedSet): throw(_("Root cannot be edited."), RootNotEditable) if not self.parent_account and not self.is_group: - frappe.throw(_("Root Account must be a group for {0}".format(self.name))) + frappe.throw(_("Root Account must be a group for {0}".format(frappe.bold(self.name)))) def validate_root_company_and_sync_account_to_children(self): # ignore validation while creating new compnay or while syncing to child companies From 9e9d44d1392c765739025c7f273974005d08c12d Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 15 Apr 2020 11:20:24 +0530 Subject: [PATCH 08/15] fix: Loan topup test --- .../loan_disbursement/test_loan_disbursement.py | 14 ++++++-------- .../doctype/loan_type/loan_type.json | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py b/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py index 189b2f5afff..0c1578ffef5 100644 --- a/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py +++ b/erpnext/loan_management/doctype/loan_disbursement/test_loan_disbursement.py @@ -58,18 +58,16 @@ class TestLoanDisbursement(unittest.TestCase): process_loan_interest_accrual_for_demand_loans(posting_date=add_days(last_date, 1)) - # Paid 511095.89 amount includes 5,00,000 principal amount and 11095.89 interest amount + # Should not be able to create loan disbursement entry before repayment + self.assertRaises(frappe.ValidationError, make_loan_disbursement_entry, loan.name, + 500000, first_date) + repayment_entry = create_repayment_entry(loan.name, self.applicant, add_days(get_last_day(nowdate()), 5), "Regular Payment", 611095.89) - repayment_entry.submit() + repayment_entry.submit() loan.reload() + # After repayment loan disbursement entry should go through make_loan_disbursement_entry(loan.name, 500000, disbursement_date=add_days(last_date, 16)) - total_principal_paid = loan.total_principal_paid - - loan.reload() - - # Loan Topup will result in decreasing the Total Principal Paid - self.assertEqual(flt(loan.total_principal_paid, 2), flt(total_principal_paid - 500000, 2)) diff --git a/erpnext/loan_management/doctype/loan_type/loan_type.json b/erpnext/loan_management/doctype/loan_type/loan_type.json index a3525db9a56..51c5cb98a63 100644 --- a/erpnext/loan_management/doctype/loan_type/loan_type.json +++ b/erpnext/loan_management/doctype/loan_type/loan_type.json @@ -119,6 +119,7 @@ "label": "Penalty Interest Rate (%) Per Day" }, { + "description": "No. of days from due date until which penalty won't be charged in case of delay in loan repayment", "fieldname": "grace_period_in_days", "fieldtype": "Int", "label": "Grace Period in Days" @@ -142,7 +143,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2020-02-03 05:03:00.334813", + "modified": "2020-04-15 00:24:43.259963", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Type", From 11121f49052313754790527e64eb0fc4be9780f9 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 15 Apr 2020 11:53:39 +0530 Subject: [PATCH 09/15] fix: patch for Healthcare Refactoring --- erpnext/patches/v12_0/update_healthcare_refactored_changes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v12_0/update_healthcare_refactored_changes.py b/erpnext/patches/v12_0/update_healthcare_refactored_changes.py index 02378e09223..d06c5713d23 100644 --- a/erpnext/patches/v12_0/update_healthcare_refactored_changes.py +++ b/erpnext/patches/v12_0/update_healthcare_refactored_changes.py @@ -100,7 +100,7 @@ def execute(): for entry in encounter_details: doc = frappe.get_doc('Patient Encounter', entry.name) - symptoms = entry.symptoms.split('\n') + symptoms = entry.symptoms.split('\n') if entry.symptoms else [] for symptom in symptoms: if not frappe.db.exists('Complaint', symptom): frappe.get_doc({ @@ -112,7 +112,7 @@ def execute(): }) row.db_update() - diagnosis = entry.diagnosis.split('\n') + diagnosis = entry.diagnosis.split('\n') if entry.diagnosis else [] for d in diagnosis: if not frappe.db.exists('Diagnosis', d): frappe.get_doc({ From c4c44a9a2bb71b2e91b3ee56417328d0d27f79e0 Mon Sep 17 00:00:00 2001 From: Anupam K Date: Wed, 15 Apr 2020 12:58:24 +0530 Subject: [PATCH 10/15] Initial JS setup --- .../crm/doctype/opportunity/opportunity_calendar.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 erpnext/crm/doctype/opportunity/opportunity_calendar.js diff --git a/erpnext/crm/doctype/opportunity/opportunity_calendar.js b/erpnext/crm/doctype/opportunity/opportunity_calendar.js new file mode 100644 index 00000000000..983be9bf2da --- /dev/null +++ b/erpnext/crm/doctype/opportunity/opportunity_calendar.js @@ -0,0 +1,12 @@ +// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt +frappe.views.calendar["Opportunity"] = { + field_map: { + "start": "contact_date", + "end": "contact_date", + "id": "name", + "title": "customer_name", + "allDay": "allDay" + }, + get_events_method: 'frappe.desk.doctype.event.event.get_events' +} From 9ee81104110b735df1e592c7fd001464f06e9e9d Mon Sep 17 00:00:00 2001 From: Anupam K Date: Wed, 15 Apr 2020 18:37:35 +0530 Subject: [PATCH 11/15] Adding Calendar view for Opportunity --- .../crm/doctype/opportunity/opportunity.py | 24 +++++++++++++++++++ .../opportunity/opportunity_calendar.js | 11 +++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index 5e640e78c8a..1b071ea1b70 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -336,3 +336,27 @@ def make_opportunity_from_communication(communication, ignore_communication_link link_communication_to_document(doc, "Opportunity", opportunity.name, ignore_communication_links) return opportunity.name +@frappe.whitelist() +def get_events(start, end, filters=None): + """Returns events for Gantt / Calendar view rendering. + :param start: Start date-time. + :param end: End date-time. + :param filters: Filters (JSON). + """ + from frappe.desk.calendar import get_event_conditions + conditions = get_event_conditions("Opportunity", filters) + + data = frappe.db.sql(""" + select + distinct `tabOpportunity`.name, `tabOpportunity`.customer_name, `tabOpportunity`.opportunity_amount, + `tabOpportunity`.title, `tabOpportunity`.contact_date + from + `tabOpportunity` + where + (`tabOpportunity`.contact_date between %(start)s and %(end)s) + {conditions} + """.format(conditions=conditions), { + "start": start, + "end": end + }, as_dict=True, update={"allDay": 0}) + return data \ No newline at end of file diff --git a/erpnext/crm/doctype/opportunity/opportunity_calendar.js b/erpnext/crm/doctype/opportunity/opportunity_calendar.js index 983be9bf2da..58fa2b8cd86 100644 --- a/erpnext/crm/doctype/opportunity/opportunity_calendar.js +++ b/erpnext/crm/doctype/opportunity/opportunity_calendar.js @@ -7,6 +7,13 @@ frappe.views.calendar["Opportunity"] = { "id": "name", "title": "customer_name", "allDay": "allDay" - }, - get_events_method: 'frappe.desk.doctype.event.event.get_events' + }, + options: { + header: { + left: 'prev,next today', + center: 'title', + right: 'month' + } + }, + get_events_method: 'erpnext.crm.doctype.opportunity.opportunity.get_events' } From 0b98a6296b69c6e548e0b9a76b322684720ea88b Mon Sep 17 00:00:00 2001 From: marination Date: Wed, 15 Apr 2020 21:19:04 +0530 Subject: [PATCH 12/15] fix: Fetch Material Requests with type Issue as well in Stock Entry via Get Items from --- erpnext/stock/doctype/stock_entry/stock_entry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 3bb941573b6..d1048fc195f 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -220,8 +220,8 @@ frappe.ui.form.on('Stock Entry', { }, get_query_filters: { docstatus: 1, - material_request_type: "Material Transfer", - status: ['!=', 'Transferred'] + material_request_type: ["in", ["Material Transfer", "Material Issue"]], + status: ["not in", ["Transferred", "Issued"]] } }) }, __("Get items from")); From 34640777cd3a734cdccd792bfd71d54376a8da2b Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 15 Apr 2020 22:08:04 +0530 Subject: [PATCH 13/15] fix: pos not accessible without default customer --- .../accounts/doctype/sales_invoice/sales_invoice.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 82aedb62479..3c40112ae6f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -440,11 +440,12 @@ class SalesInvoice(SellingController): if pos.get("company_address"): self.company_address = pos.get("company_address") - customer_price_list, customer_group = frappe.get_value("Customer", self.customer, ['default_price_list', 'customer_group']) - - customer_group_price_list = frappe.get_value("Customer Group", customer_group, 'default_price_list') - - selling_price_list = customer_price_list or customer_group_price_list or pos.get('selling_price_list') + if self.customer: + customer_price_list, customer_group = frappe.get_value("Customer", self.customer, ['default_price_list', 'customer_group']) + customer_group_price_list = frappe.get_value("Customer Group", customer_group, 'default_price_list') + selling_price_list = customer_price_list or customer_group_price_list or pos.get('selling_price_list') + else: + selling_price_list = pos.get('selling_price_list') if selling_price_list: self.set('selling_price_list', selling_price_list) From f53299e98a3bb82c85e6b5c3be1b49bd0d5ca408 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 15 Apr 2020 22:08:12 +0530 Subject: [PATCH 14/15] fix: warehouse unset when cannot find item warehouse * cannot set delivery date when all items gets deleted and new are added --- erpnext/controllers/accounts_controller.py | 24 ++++---- erpnext/public/js/utils.js | 69 +++++++++++++--------- 2 files changed, 55 insertions(+), 38 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index d95753df900..4045250c330 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1123,36 +1123,39 @@ def get_supplier_block_status(party_name): } return info -def set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname, item_code): +def set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname, trans_item): """ Returns a Sales Order Item child item containing the default values """ p_doc = frappe.get_doc(parent_doctype, parent_doctype_name) child_item = frappe.new_doc('Sales Order Item', p_doc, child_docname) - item = frappe.get_doc("Item", item_code) + item = frappe.get_doc("Item", trans_item.get('item_code')) child_item.item_code = item.item_code child_item.item_name = item.item_name child_item.description = item.description - child_item.reqd_by_date = p_doc.delivery_date + child_item.delivery_date = trans_item.get('delivery_date') or p_doc.delivery_date child_item.uom = item.stock_uom - child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0 + child_item.conversion_factor = get_conversion_factor(item.item_code, item.stock_uom).get("conversion_factor") or 1.0 child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True) + if not child_item.warehouse: + frappe.throw(_("Cannot find {} for item {}. Please set the same in Item Master or Stock Settings.") + .format(frappe.bold("default warehouse"), frappe.bold(item.item_code))) return child_item -def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docname, item_code): +def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docname, trans_item): """ Returns a Purchase Order Item child item containing the default values """ p_doc = frappe.get_doc(parent_doctype, parent_doctype_name) child_item = frappe.new_doc('Purchase Order Item', p_doc, child_docname) - item = frappe.get_doc("Item", item_code) + item = frappe.get_doc("Item", trans_item.get('item_code')) child_item.item_code = item.item_code child_item.item_name = item.item_name child_item.description = item.description - child_item.schedule_date = p_doc.schedule_date + child_item.schedule_date = trans_item.get('schedule_date') or p_doc.schedule_date child_item.uom = item.stock_uom - child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0 + child_item.conversion_factor = get_conversion_factor(item.item_code, item.stock_uom).get("conversion_factor") or 1.0 child_item.base_rate = 1 # Initiallize value will update in parent validation child_item.base_amount = 1 # Initiallize value will update in parent validation return child_item @@ -1196,9 +1199,9 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil if not d.get("docname"): new_child_flag = True if parent_doctype == "Sales Order": - child_item = set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname, d.get("item_code")) + child_item = set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname, d) if parent_doctype == "Purchase Order": - child_item = set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docname, d.get("item_code")) + child_item = set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docname, d) else: child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname")) if flt(child_item.get("rate")) == flt(d.get("rate")) and flt(child_item.get("qty")) == flt(d.get("qty")): @@ -1243,6 +1246,7 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil child_item.flags.ignore_validate_update_after_submit = True if new_child_flag: + parent.load_from_db() child_item.idx = len(parent.items) + 1 child_item.insert() else: diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 4d44eae086e..58969f2a9fd 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -436,6 +436,44 @@ erpnext.utils.update_child_items = function(opts) { const cannot_add_row = (typeof opts.cannot_add_row === 'undefined') ? true : opts.cannot_add_row; const child_docname = (typeof opts.cannot_add_row === 'undefined') ? "items" : opts.child_docname; this.data = []; + const fields = [{ + fieldtype:'Data', + fieldname:"docname", + read_only: 1, + hidden: 1, + }, { + fieldtype:'Link', + fieldname:"item_code", + options: 'Item', + in_list_view: 1, + read_only: 0, + disabled: 0, + label: __('Item Code') + }, { + fieldtype:'Float', + fieldname:"qty", + default: 0, + read_only: 0, + in_list_view: 1, + label: __('Qty') + }, { + fieldtype:'Currency', + fieldname:"rate", + default: 0, + read_only: 0, + in_list_view: 1, + label: __('Rate') + }]; + + if (frm.doc.doctype == 'Sales Order' || frm.doc.doctype == 'Purchase Order' ) { + fields.splice(2, 0, { + fieldtype: 'Date', + fieldname: frm.doc.doctype == 'Sales Order' ? "delivery_date" : "schedule_date", + in_list_view: 1, + label: frm.doc.doctype == 'Sales Order' ? __("Delivery Date") : __("Reqd by date") + }) + } + const dialog = new frappe.ui.Dialog({ title: __("Update Items"), fields: [ @@ -450,34 +488,7 @@ erpnext.utils.update_child_items = function(opts) { get_data: () => { return this.data; }, - fields: [{ - fieldtype:'Data', - fieldname:"docname", - read_only: 1, - hidden: 1, - }, { - fieldtype:'Link', - fieldname:"item_code", - options: 'Item', - in_list_view: 1, - read_only: 0, - disabled: 0, - label: __('Item Code') - }, { - fieldtype:'Float', - fieldname:"qty", - default: 0, - read_only: 0, - in_list_view: 1, - label: __('Qty') - }, { - fieldtype:'Currency', - fieldname:"rate", - default: 0, - read_only: 0, - in_list_view: 1, - label: __('Rate') - }] + fields: fields }, ], primary_action: function() { @@ -506,6 +517,8 @@ erpnext.utils.update_child_items = function(opts) { "docname": d.name, "name": d.name, "item_code": d.item_code, + "delivery_date": d.delivery_date, + "schedule_date": d.schedule_date, "qty": d.qty, "rate": d.rate, }); From 5b36d15927b56ec9aa01bbd0eb45695124f95aa3 Mon Sep 17 00:00:00 2001 From: vishdha Date: Thu, 16 Apr 2020 11:09:54 +0530 Subject: [PATCH 15/15] fix: fix Transalation --- erpnext/accounts/doctype/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 9e29ce6748f..c6de6410ebc 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -89,7 +89,7 @@ class Account(NestedSet): throw(_("Root cannot be edited."), RootNotEditable) if not self.parent_account and not self.is_group: - frappe.throw(_("Root Account must be a group for {0}".format(frappe.bold(self.name)))) + frappe.throw(_("The root account {0} must be a group").format(frappe.bold(self.name))) def validate_root_company_and_sync_account_to_children(self): # ignore validation while creating new compnay or while syncing to child companies