From 1d04ea121239f86810bb2398f158968c266d3e0e Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Fri, 22 Mar 2019 17:47:57 +0530 Subject: [PATCH 01/23] fix: include fiscal code in invoice xml if present --- erpnext/regional/italy/e-invoice.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml index c886ee9aa8..c789808fab 100644 --- a/erpnext/regional/italy/e-invoice.xml +++ b/erpnext/regional/italy/e-invoice.xml @@ -95,14 +95,13 @@ {{ doc.customer_data.last_name }} {%- else %} - {%- if doc.customer_data.is_public_administration %} - {{ doc.customer_data.fiscal_code }} - {%- else %} + {%- if doc.customer_data.fiscal_code %} + {{ doc.customer_data.fiscal_code }} + {%- endif %} {{ doc.customer_address_data.country_code }} {{ doc.tax_id | replace("IT","") }} - {%- endif %} {{ doc.customer_name }} From 138e030055481807baa038e8dc5ba6af39dcc836 Mon Sep 17 00:00:00 2001 From: Himanshu Date: Fri, 22 Mar 2019 23:22:52 +0530 Subject: [PATCH 02/23] CodiceFiscale should be after IdFiscaleIVA --- erpnext/regional/italy/e-invoice.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml index c789808fab..912b7899d6 100644 --- a/erpnext/regional/italy/e-invoice.xml +++ b/erpnext/regional/italy/e-invoice.xml @@ -95,13 +95,13 @@ {{ doc.customer_data.last_name }} {%- else %} - {%- if doc.customer_data.fiscal_code %} - {{ doc.customer_data.fiscal_code }} - {%- endif %} {{ doc.customer_address_data.country_code }} {{ doc.tax_id | replace("IT","") }} + {%- if doc.customer_data.fiscal_code %} + {{ doc.customer_data.fiscal_code }} + {%- endif %} {{ doc.customer_name }} From 9673d0ddaed04beac11d9be88664d047976f024c Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Sun, 24 Mar 2019 12:19:58 +0530 Subject: [PATCH 03/23] fix: description missing in the XML (#16985) --- erpnext/regional/italy/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py index f39b144cdc..e56c98b271 100644 --- a/erpnext/regional/italy/utils.py +++ b/erpnext/regional/italy/utils.py @@ -134,6 +134,7 @@ def get_invoice_summary(items, taxes): idx=len(items)+1, item_code=reference_row.description, item_name=reference_row.description, + description=reference_row.description, rate=reference_row.tax_amount, qty=1.0, amount=reference_row.tax_amount, From 67876d1026265e87819b30e7e8327bbaafab66ee Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 22 Mar 2019 14:27:37 +0530 Subject: [PATCH 04/23] fix: Show amount of entry based on diff of credit and debit --- .../doctype/bank_reconciliation/bank_reconciliation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 0aaed8f530..23e2518306 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -62,8 +62,12 @@ class BankReconciliation(Document): for d in entries: row = self.append('payment_entries', {}) - amount = d.debit if d.debit else d.credit - d.amount = fmt_money(amount, 2, d.account_currency) + " " + (_("Dr") if d.debit else _("Cr")) + + amount = d.get('debit', 0) - d.get('credit', 0) + + formatted_amount = fmt_money(abs(amount), 2, d.account_currency) + d.amount = formatted_amount + " " + (_("Dr") if amount > 0 else _("Cr")) + d.pop("credit") d.pop("debit") d.pop("account_currency") From 4f9ac0ad55801d5b5aef85e519f30009cc4e265a Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 25 Mar 2019 11:39:25 +0530 Subject: [PATCH 05/23] fix: Child company account currency fix --- erpnext/accounts/doctype/account/account.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 427f3dba20..472196e67d 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -98,7 +98,10 @@ class Account(NestedSet): ancestors = get_root_company(self.company) if ancestors: - frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) + account = frappe.db.exists("Account", {"company": ancestors[0], "account_name": self.account_name}) + + if not account: + frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) else: descendants = get_descendants_of('Company', self.company) if not descendants: return From 4ed7d035cbda7b17fae02070608ae9263a4c96b6 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 25 Mar 2019 15:37:25 +0530 Subject: [PATCH 06/23] fix: incorrect paid amount in accounts receivable summary report --- erpnext/accounts/party.py | 10 +++++++--- .../accounts_receivable_summary.py | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 70e4800784..67bd0bd8c7 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -573,13 +573,17 @@ def get_party_shipping_address(doctype, name): else: return '' -def get_partywise_advanced_payment_amount(party_type="Customer"): +def get_partywise_advanced_payment_amount(party_type, posting_date = None): + cond = "1=1" + if posting_date: + cond = "posting_date <= '{0}'".format(posting_date) + data = frappe.db.sql(""" SELECT party, sum({0}) as amount FROM `tabGL Entry` WHERE party_type = %s and against_voucher is null - GROUP BY party""" - .format(("credit") if party_type == "Customer" else "debit") , party_type) + and {1} GROUP BY party""" + .format(("credit") if party_type == "Customer" else "debit", cond) , party_type) if data: return frappe._dict(data) \ No newline at end of file diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index 8cb5ac1090..ffd19948ce 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -136,7 +136,8 @@ class AccountsReceivableSummary(ReceivablePayableReport): partywise_total = self.get_partywise_total(party_naming_by, args) - partywise_advance_amount = get_partywise_advanced_payment_amount(args.get("party_type")) or {} + partywise_advance_amount = get_partywise_advanced_payment_amount(args.get("party_type"), + self.filters.get("report_date")) or {} for party, party_dict in iteritems(partywise_total): row = [party] @@ -144,7 +145,9 @@ class AccountsReceivableSummary(ReceivablePayableReport): row += [self.get_party_name(args.get("party_type"), party)] row += [partywise_advance_amount.get(party, 0)] - paid_amt = flt(party_dict.paid_amt - partywise_advance_amount.get(party, 0)) + + if party_dict.paid_amt > 0: + paid_amt = flt(party_dict.paid_amt - partywise_advance_amount.get(party, 0)) row += [ party_dict.invoiced_amt, paid_amt, party_dict.credit_amt, party_dict.outstanding_amt, From 843b7f6dd53183018a4eca36f5ee40ce3662df15 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 25 Mar 2019 15:50:36 +0530 Subject: [PATCH 07/23] fix: Reorder Currency column to fix print (#17008) Every Financial Report's 2nd column is Currency, which is an implicit requirement to Print them properly. In this case, Income column was not printed. This fixes that. --- .../profitability_analysis.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py index 39706acde0..a0d8c5f0e4 100644 --- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py +++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py @@ -133,6 +133,13 @@ def get_columns(filters): "options": filters.get("based_on"), "width": 300 }, + { + "fieldname": "currency", + "label": _("Currency"), + "fieldtype": "Link", + "options": "Currency", + "hidden": 1 + }, { "fieldname": "income", "label": _("Income"), @@ -153,13 +160,6 @@ def get_columns(filters): "fieldtype": "Currency", "options": "currency", "width": 120 - }, - { - "fieldname": "currency", - "label": _("Currency"), - "fieldtype": "Link", - "options": "Currency", - "hidden": 1 } ] @@ -191,4 +191,4 @@ def set_gl_entries_by_account(company, from_date, to_date, based_on, gl_entries_ for entry in gl_entries: gl_entries_by_account.setdefault(entry.based_on, []).append(entry) - return gl_entries_by_account \ No newline at end of file + return gl_entries_by_account From 1c785a99b1c8a4814e33b401b060e58fc17a5c8a Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 25 Mar 2019 22:32:29 +0530 Subject: [PATCH 08/23] fix: Added setting in company to ignore root company validation --- erpnext/accounts/doctype/account/account.py | 8 +- erpnext/setup/doctype/company/company.json | 126 +++++++++++++++++++- 2 files changed, 129 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 472196e67d..9b698b40c1 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -96,12 +96,12 @@ class Account(NestedSet): if frappe.local.flags.ignore_root_company_validation or self.flags.ignore_root_company_validation: return + if frappe.get_value("Company", self.company, "ignore_root_company_validation"): + return + ancestors = get_root_company(self.company) if ancestors: - account = frappe.db.exists("Account", {"company": ancestors[0], "account_name": self.account_name}) - - if not account: - frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) + frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) else: descendants = get_descendants_of('Company', self.company) if not descendants: return diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 77c371e0cd..66ea7da6a5 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -22,6 +22,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "details", "fieldtype": "Section Break", "hidden": 0, @@ -54,6 +55,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "company_name", "fieldtype": "Data", "hidden": 0, @@ -88,6 +90,7 @@ "collapsible": 0, "columns": 0, "description": "", + "fetch_if_empty": 0, "fieldname": "abbr", "fieldtype": "Data", "hidden": 0, @@ -122,6 +125,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal && in_list(frappe.user_roles, \"System Manager\")", + "fetch_if_empty": 0, "fieldname": "change_abbr", "fieldtype": "Button", "hidden": 0, @@ -153,6 +157,7 @@ "bold": 1, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "is_group", "fieldtype": "Check", "hidden": 0, @@ -185,6 +190,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_finance_book", "fieldtype": "Link", "hidden": 0, @@ -218,6 +224,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "cb0", "fieldtype": "Column Break", "hidden": 0, @@ -248,6 +255,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "domain", "fieldtype": "Link", "hidden": 0, @@ -280,6 +288,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "parent_company", "fieldtype": "Link", "hidden": 0, @@ -313,6 +322,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "sb_about", "fieldtype": "Section Break", "hidden": 0, @@ -345,6 +355,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "company_logo", "fieldtype": "Attach Image", "hidden": 0, @@ -377,6 +388,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "company_description", "fieldtype": "Text Editor", "hidden": 0, @@ -409,6 +421,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "sales_settings", "fieldtype": "Section Break", "hidden": 0, @@ -441,6 +454,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "sales_monthly_history", "fieldtype": "Small Text", "hidden": 1, @@ -473,6 +487,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "transactions_annual_history", "fieldtype": "Code", "hidden": 1, @@ -505,6 +520,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "monthly_sales_target", "fieldtype": "Currency", "hidden": 0, @@ -538,6 +554,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_goals", "fieldtype": "Column Break", "hidden": 0, @@ -569,6 +586,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "total_monthly_sales", "fieldtype": "Currency", "hidden": 0, @@ -602,6 +620,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "charts_section", "fieldtype": "Section Break", "hidden": 0, @@ -633,6 +652,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_currency", "fieldtype": "Link", "hidden": 0, @@ -665,6 +685,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_letter_head", "fieldtype": "Link", "hidden": 0, @@ -698,6 +719,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_holiday_list", "fieldtype": "Link", "hidden": 0, @@ -731,6 +753,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "standard_working_hours", "fieldtype": "Float", "hidden": 0, @@ -763,6 +786,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_terms", "fieldtype": "Link", "hidden": 0, @@ -795,6 +819,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_10", "fieldtype": "Column Break", "hidden": 0, @@ -826,6 +851,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "country", "fieldtype": "Link", "hidden": 0, @@ -858,6 +884,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "create_chart_of_accounts_based_on", "fieldtype": "Select", "hidden": 0, @@ -892,6 +919,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:doc.create_chart_of_accounts_based_on===\"Standard Template\"", + "fetch_if_empty": 0, "fieldname": "chart_of_accounts", "fieldtype": "Select", "hidden": 0, @@ -926,6 +954,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:doc.create_chart_of_accounts_based_on===\"Existing Company\"", + "fetch_if_empty": 0, "fieldname": "existing_company", "fieldtype": "Link", "hidden": 0, @@ -959,6 +988,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "tax_id", "fieldtype": "Data", "hidden": 0, @@ -991,6 +1021,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "date_of_establishment", "fieldtype": "Date", "hidden": 0, @@ -1023,6 +1054,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_settings", "fieldtype": "Section Break", "hidden": 0, @@ -1056,6 +1088,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_bank_account", "fieldtype": "Link", "hidden": 0, @@ -1091,6 +1124,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_cash_account", "fieldtype": "Link", "hidden": 0, @@ -1124,6 +1158,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_receivable_account", "fieldtype": "Link", "hidden": 0, @@ -1158,6 +1193,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "round_off_account", "fieldtype": "Link", "hidden": 0, @@ -1191,6 +1227,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "round_off_cost_center", "fieldtype": "Link", "hidden": 0, @@ -1224,6 +1261,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "write_off_account", "fieldtype": "Link", "hidden": 0, @@ -1257,6 +1295,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "discount_allowed_account", "fieldtype": "Link", "hidden": 0, @@ -1290,6 +1329,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "discount_received_account", "fieldtype": "Link", "hidden": 0, @@ -1323,6 +1363,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "exchange_gain_loss_account", "fieldtype": "Link", "hidden": 0, @@ -1356,6 +1397,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "unrealized_exchange_gain_loss_account", "fieldtype": "Link", "hidden": 0, @@ -1389,6 +1431,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break0", "fieldtype": "Column Break", "hidden": 0, @@ -1414,6 +1457,40 @@ "unique": 0, "width": "50%" }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.parent_company", + "fetch_if_empty": 0, + "fieldname": "ignore_root_company_validation", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Ignore Root Company Validation", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -1422,6 +1499,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_payable_account", "fieldtype": "Link", "hidden": 0, @@ -1456,6 +1534,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_employee_advance_account", "fieldtype": "Link", "hidden": 0, @@ -1490,6 +1569,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_expense_account", "fieldtype": "Link", "hidden": 0, @@ -1523,6 +1603,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_income_account", "fieldtype": "Link", "hidden": 0, @@ -1556,6 +1637,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_deferred_revenue_account", "fieldtype": "Link", "hidden": 0, @@ -1590,6 +1672,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_deferred_expense_account", "fieldtype": "Link", "hidden": 0, @@ -1624,6 +1707,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_payroll_payable_account", "fieldtype": "Link", "hidden": 0, @@ -1658,6 +1742,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "default_expense_claim_payable_account", "fieldtype": "Link", "hidden": 0, @@ -1691,6 +1776,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "section_break_22", "fieldtype": "Section Break", "hidden": 0, @@ -1723,6 +1809,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "cost_center", "fieldtype": "Link", "hidden": 0, @@ -1755,6 +1842,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_26", "fieldtype": "Column Break", "hidden": 0, @@ -1787,6 +1875,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "credit_limit", "fieldtype": "Currency", "hidden": 0, @@ -1822,6 +1911,7 @@ "collapsible": 0, "columns": 0, "depends_on": "", + "fetch_if_empty": 0, "fieldname": "payment_terms", "fieldtype": "Link", "hidden": 0, @@ -1856,6 +1946,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:!doc.__islocal", + "fetch_if_empty": 0, "fieldname": "auto_accounting_for_stock_settings", "fieldtype": "Section Break", "hidden": 0, @@ -1888,6 +1979,7 @@ "collapsible": 0, "columns": 0, "default": "1", + "fetch_if_empty": 0, "fieldname": "enable_perpetual_inventory", "fieldtype": "Check", "hidden": 0, @@ -1920,6 +2012,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "default_inventory_account", "fieldtype": "Link", "hidden": 0, @@ -1953,6 +2046,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "stock_adjustment_account", "fieldtype": "Link", "hidden": 0, @@ -1985,6 +2079,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_32", "fieldtype": "Column Break", "hidden": 0, @@ -2016,6 +2111,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "stock_received_but_not_billed", "fieldtype": "Link", "hidden": 0, @@ -2048,6 +2144,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "expenses_included_in_valuation", "fieldtype": "Link", "hidden": 0, @@ -2080,6 +2177,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "fixed_asset_depreciation_settings", "fieldtype": "Section Break", "hidden": 0, @@ -2112,6 +2210,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "accumulated_depreciation_account", "fieldtype": "Link", "hidden": 0, @@ -2145,6 +2244,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "depreciation_expense_account", "fieldtype": "Link", "hidden": 0, @@ -2178,6 +2278,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "series_for_depreciation_entry", "fieldtype": "Data", "hidden": 0, @@ -2210,6 +2311,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "expenses_included_in_asset_valuation", "fieldtype": "Link", "hidden": 0, @@ -2243,6 +2345,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_40", "fieldtype": "Column Break", "hidden": 0, @@ -2274,6 +2377,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "disposal_account", "fieldtype": "Link", "hidden": 0, @@ -2307,6 +2411,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "depreciation_cost_center", "fieldtype": "Link", "hidden": 0, @@ -2340,6 +2445,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "capital_work_in_progress_account", "fieldtype": "Link", "hidden": 0, @@ -2373,6 +2479,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "asset_received_but_not_billed", "fieldtype": "Link", "hidden": 0, @@ -2406,6 +2513,7 @@ "bold": 0, "collapsible": 1, "columns": 0, + "fetch_if_empty": 0, "fieldname": "budget_detail", "fieldtype": "Section Break", "hidden": 0, @@ -2438,6 +2546,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "exception_budget_approver_role", "fieldtype": "Link", "hidden": 0, @@ -2472,6 +2581,7 @@ "collapsible": 0, "columns": 0, "description": "For reference only.", + "fetch_if_empty": 0, "fieldname": "company_info", "fieldtype": "Section Break", "hidden": 0, @@ -2503,6 +2613,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "date_of_incorporation", "fieldtype": "Date", "hidden": 0, @@ -2535,6 +2646,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "address_html", "fieldtype": "HTML", "hidden": 0, @@ -2566,6 +2678,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break1", "fieldtype": "Column Break", "hidden": 0, @@ -2599,6 +2712,7 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:doc.date_of_incorporation", + "fetch_if_empty": 0, "fieldname": "date_of_commencement", "fieldtype": "Date", "hidden": 0, @@ -2631,6 +2745,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "phone_no", "fieldtype": "Data", "hidden": 0, @@ -2665,6 +2780,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "fax", "fieldtype": "Data", "hidden": 0, @@ -2699,6 +2815,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "email", "fieldtype": "Data", "hidden": 0, @@ -2733,6 +2850,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "website", "fieldtype": "Data", "hidden": 0, @@ -2767,6 +2885,7 @@ "collapsible": 0, "columns": 0, "description": "", + "fetch_if_empty": 0, "fieldname": "registration_info", "fieldtype": "Section Break", "hidden": 0, @@ -2801,6 +2920,7 @@ "collapsible": 0, "columns": 0, "description": "Company registration numbers for your reference. Tax numbers etc.", + "fetch_if_empty": 0, "fieldname": "registration_details", "fieldtype": "Code", "hidden": 0, @@ -2834,6 +2954,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "delete_company_transactions", "fieldtype": "Button", "hidden": 0, @@ -2866,6 +2987,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "lft", "fieldtype": "Int", "hidden": 1, @@ -2898,6 +3020,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "rgt", "fieldtype": "Int", "hidden": 1, @@ -2930,6 +3053,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "old_parent", "fieldtype": "Data", "hidden": 1, @@ -2969,7 +3093,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2019-01-15 13:29:54.510379", + "modified": "2019-03-25 22:13:08.721452", "modified_by": "Administrator", "module": "Setup", "name": "Company", From fdbb516a1bd63f68c11f3c6fe00f61195270d02a Mon Sep 17 00:00:00 2001 From: Raffael Meyer Date: Tue, 26 Mar 2019 08:17:36 +0100 Subject: [PATCH 09/23] fix(projects): Auto-set employee and company in Timesheet (#16743) * fix(projects): auto-set employee and company * only set employee and company if document is unsaved * use frm.set_value() --- .../projects/doctype/timesheet/timesheet.js | 71 ++++++++++++------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 8811ab9543..8ffc10ee97 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -10,8 +10,8 @@ frappe.ui.form.on("Timesheet", { filters:{ 'status': 'Active' } - } - } + }; + }; frm.fields_dict['time_logs'].grid.get_field('task').get_query = function(frm, cdt, cdn) { var child = locals[cdt][cdn]; @@ -20,33 +20,37 @@ frappe.ui.form.on("Timesheet", { 'project': child.project, 'status': ["!=", "Cancelled"] } - } - } + }; + }; frm.fields_dict['time_logs'].grid.get_field('project').get_query = function() { return{ filters: { 'company': frm.doc.company } - } - } + }; + }; }, onload: function(frm){ if (frm.doc.__islocal && frm.doc.time_logs) { calculate_time_and_amount(frm); } + + if (frm.is_new()) { + set_employee_and_company(frm); + } }, refresh: function(frm) { if(frm.doc.docstatus==1) { if(frm.doc.per_billed < 100 && frm.doc.total_billable_hours && frm.doc.total_billable_hours > frm.doc.total_billed_hours){ - frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") }, + frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice"); }, "fa fa-file-alt"); } if(!frm.doc.salary_slip && frm.doc.employee){ - frm.add_custom_button(__("Make Salary Slip"), function() { frm.trigger("make_salary_slip") }, + frm.add_custom_button(__("Make Salary Slip"), function() { frm.trigger("make_salary_slip"); }, "fa fa-file-alt"); } } @@ -58,7 +62,7 @@ frappe.ui.form.on("Timesheet", { if ((row.from_time <= frappe.datetime.now_datetime()) && !row.completed) { button = 'Resume Timer'; } - }) + }); frm.add_custom_button(__(button), function() { var flag = true; @@ -77,7 +81,7 @@ frappe.ui.form.on("Timesheet", { erpnext.timesheet.timer(frm, row, timestamp); flag = false; } - }) + }); // If no activities found to start a timer, create new if (flag) { erpnext.timesheet.timer(frm); @@ -94,7 +98,7 @@ frappe.ui.form.on("Timesheet", { frappe.db.get_value('Company', { 'company_name' : frm.doc.company }, 'standard_working_hours') .then(({ message }) => { (frappe.working_hours = message.standard_working_hours || 0); - }); + }); }, make_invoice: function(frm) { @@ -125,8 +129,8 @@ frappe.ui.form.on("Timesheet", { frappe.set_route("Form", r.message.doctype, r.message.name); } } - }) - }) + }); + }); dialog.show(); }, @@ -136,7 +140,7 @@ frappe.ui.form.on("Timesheet", { frm: frm }); }, -}) +}); frappe.ui.form.on("Timesheet Detail", { time_logs_remove: function(frm) { @@ -171,22 +175,22 @@ frappe.ui.form.on("Timesheet Detail", { .find('[data-fieldname="timer"]') .append(frappe.render_template("timesheet")); frm.trigger("control_timer"); - }) + }); }, hours: function(frm, cdt, cdn) { - calculate_end_time(frm, cdt, cdn) + calculate_end_time(frm, cdt, cdn); }, billing_hours: function(frm, cdt, cdn) { - calculate_billing_costing_amount(frm, cdt, cdn) + calculate_billing_costing_amount(frm, cdt, cdn); }, billing_rate: function(frm, cdt, cdn) { - calculate_billing_costing_amount(frm, cdt, cdn) + calculate_billing_costing_amount(frm, cdt, cdn); }, costing_rate: function(frm, cdt, cdn) { - calculate_billing_costing_amount(frm, cdt, cdn) + calculate_billing_costing_amount(frm, cdt, cdn); }, billable: function(frm, cdt, cdn) { @@ -212,7 +216,7 @@ frappe.ui.form.on("Timesheet Detail", { calculate_billing_costing_amount(frm, cdt, cdn); } } - }) + }); } }); @@ -240,23 +244,23 @@ var calculate_end_time = function(frm, cdt, cdn) { frm._setting_hours = true; frappe.model.set_value(cdt, cdn, "to_time", d.format(frappe.defaultDatetimeFormat)).then(() => { - frm._setting_hours = false; - }); + frm._setting_hours = false; + }); } } -} +}; var update_billing_hours = function(frm, cdt, cdn){ var child = locals[cdt][cdn]; if(!child.billable) frappe.model.set_value(cdt, cdn, 'billing_hours', 0.0); -} +}; var update_time_rates = function(frm, cdt, cdn){ var child = locals[cdt][cdn]; if(!child.billable){ frappe.model.set_value(cdt, cdn, 'billing_rate', 0.0); } -} +}; var calculate_billing_costing_amount = function(frm, cdt, cdn){ var child = locals[cdt][cdn]; @@ -270,7 +274,7 @@ var calculate_billing_costing_amount = function(frm, cdt, cdn){ frappe.model.set_value(cdt, cdn, 'billing_amount', billing_amount); frappe.model.set_value(cdt, cdn, 'costing_amount', costing_amount); calculate_time_and_amount(frm); -} +}; var calculate_time_and_amount = function(frm) { var tl = frm.doc.time_logs || []; @@ -294,4 +298,17 @@ var calculate_time_and_amount = function(frm) { frm.set_value("total_hours", total_working_hr); frm.set_value("total_billable_amount", total_billable_amount); frm.set_value("total_costing_amount", total_costing_amount); -} \ No newline at end of file +}; + +// set employee (and company) to the one that's currently logged in +const set_employee_and_company = function(frm) { + const options = { user_id: frappe.session.user }; + const fields = ['name', 'company']; + frappe.db.get_value('Employee', options, fields).then(({ message }) => { + if (message) { + // there is an employee with the currently logged in user_id + frm.set_value("employee", message.name); + frm.set_value("company", message.company); + } + }); +}; From 7aefc15352221e5c7614956a10bb76bc25113655 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 26 Mar 2019 15:09:29 +0530 Subject: [PATCH 10/23] fix: Allow to add child account if ignore validation checked --- erpnext/accounts/doctype/account/account_tree.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index df0486cc27..6b35fcbc0b 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -23,6 +23,10 @@ frappe.treeview_settings["Account"] = { if(r.message) { let root_company = r.message.length ? r.message[0] : ""; me.page.fields_dict.root_company.set_value(root_company); + + frappe.db.get_value("Company", {"name": company}, "ignore_root_company_validation", (r) => { + frappe.flags.ignore_root_company_validation = r.ignore_root_company_validation; + }) } } }); @@ -133,9 +137,10 @@ frappe.treeview_settings["Account"] = { { label:__("Add Child"), condition: function(node) { - return frappe.boot.user.can_create.indexOf("Account") !== -1 && - !frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value() && - node.expandable && !node.hide_add; + return frappe.boot.user.can_create.indexOf("Account") !== -1 + && (!frappe.treeview_settings['Account'].treeview.page.fields_dict.root_company.get_value() + || frappe.flags.ignore_root_company_validation) + && node.expandable && !node.hide_add; }, click: function() { var me = frappe.treeview_settings['Account'].treeview; From c45c2bdabb7aa2b9b1db14a5f507857cbb3d084b Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 26 Mar 2019 15:38:38 +0530 Subject: [PATCH 11/23] fix: Missing semicolon --- erpnext/accounts/doctype/account/account_tree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index 6b35fcbc0b..c98aef83ee 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -25,8 +25,8 @@ frappe.treeview_settings["Account"] = { me.page.fields_dict.root_company.set_value(root_company); frappe.db.get_value("Company", {"name": company}, "ignore_root_company_validation", (r) => { - frappe.flags.ignore_root_company_validation = r.ignore_root_company_validation; - }) + frappe.flags.ignore_root_company_validation = r.ignore_root_company_validation; + }); } } }); From 8aaee5792180753b51fce06bf82da39432c445ed Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 24 Oct 2018 17:00:20 +0530 Subject: [PATCH 12/23] fix(uom): Get items as per UOM defined in BOM, fixes #15081 --- erpnext/manufacturing/doctype/bom/bom.py | 12 +++++++----- erpnext/stock/doctype/stock_entry/stock_entry.py | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index ea6b7ede92..be4d74be89 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -580,7 +580,7 @@ def get_list_context(context): context.title = _("Bill of Materials") # context.introduction = _('Boms') -def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_items=0, include_non_stock_items=False): +def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_items=0, include_non_stock_items=False, fetch_qty_in_stock_uom=True): item_dict = {} # Did not use qty_consumed_per_unit in the query, as it leads to rounding loss @@ -588,7 +588,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite bom_item.item_code, bom_item.idx, item.item_name, - sum(bom_item.stock_qty/ifnull(bom.quantity, 1)) * %(qty)s as qty, + sum(bom_item.{qty_field}/ifnull(bom.quantity, 1)) * %(qty)s as qty, item.description, item.image, item.stock_uom, @@ -616,16 +616,18 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite query = query.format(table="BOM Explosion Item", where_conditions="", is_stock_item=is_stock_item, - select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.include_item_in_manufacturing, + qty_field="stock_qty", + select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.allow_transfer_for_manufacture, (Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx""") items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom, "company": company }, as_dict=True) elif fetch_scrap_items: - query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx", is_stock_item=is_stock_item) + query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx", is_stock_item=is_stock_item, qty_field="stock_qty") items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True) else: query = query.format(table="BOM Item", where_conditions="", is_stock_item=is_stock_item, - select_columns = ", bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing") + qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty", + select_columns = ", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.allow_transfer_for_manufacture") items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True) for item in items: diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3a5253019a..dc9c4fc3fe 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -802,7 +802,7 @@ class StockEntry(StockController): # item dict = { item_code: {qty, description, stock_uom} } item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty, - fetch_exploded = self.use_multi_level_bom) + fetch_exploded = self.use_multi_level_bom, fetch_qty_in_stock_uom=False) used_alternative_items = get_used_alternative_items(work_order = self.work_order) for item in itervalues(item_dict): @@ -1031,7 +1031,7 @@ class StockEntry(StockController): se_child.item_code = item_dict[d].get('item_code') or cstr(d) se_child.item_name = item_dict[d]["item_name"] se_child.description = item_dict[d]["description"] - se_child.uom = stock_uom + se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom se_child.stock_uom = stock_uom se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty")) se_child.expense_account = item_dict[d].get("expense_account") or expense_account @@ -1049,8 +1049,9 @@ class StockEntry(StockController): se_child.t_warehouse = self.to_warehouse # in stock uom - se_child.transfer_qty = flt(item_dict[d]["qty"], se_child.precision("qty")) - se_child.conversion_factor = 1.00 + se_child.conversion_factor = flt(item_dict[d].get("conversion_factor")) or 1 + se_child.transfer_qty = flt(item_dict[d]["qty"]*se_child.conversion_factor, se_child.precision("qty")) + # to be assigned for finished item se_child.bom_no = bom_no From a0927c1ba60c53bd0ccffa13e13c4129b798c55a Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Fri, 22 Mar 2019 14:58:22 +0530 Subject: [PATCH 13/23] fix: correct use of include_item_in_manufacturing --- erpnext/manufacturing/doctype/bom/bom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index be4d74be89..db94350d67 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -617,7 +617,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite where_conditions="", is_stock_item=is_stock_item, qty_field="stock_qty", - select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.allow_transfer_for_manufacture, + select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.include_item_in_manufacturing, (Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s ) as idx""") items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom, "company": company }, as_dict=True) @@ -627,7 +627,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite else: query = query.format(table="BOM Item", where_conditions="", is_stock_item=is_stock_item, qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty", - select_columns = ", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.allow_transfer_for_manufacture") + select_columns = ", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing") items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True) for item in items: From 3eeb1cacb0aef9716e0b32848c2b775b81e32f8b Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 26 Mar 2019 17:18:06 +0530 Subject: [PATCH 14/23] fix: Change name to Allow Account Creation against Child Company in company master --- erpnext/accounts/doctype/account/account.py | 5 ++--- erpnext/accounts/doctype/account/account_tree.js | 4 ++-- erpnext/setup/doctype/company/company.json | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 9b698b40c1..ac74b4516a 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -96,11 +96,10 @@ class Account(NestedSet): if frappe.local.flags.ignore_root_company_validation or self.flags.ignore_root_company_validation: return - if frappe.get_value("Company", self.company, "ignore_root_company_validation"): - return - ancestors = get_root_company(self.company) if ancestors: + if frappe.get_value("Company", self.company, "allow_account_creation_against_child_company"): + return frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) else: descendants = get_descendants_of('Company', self.company) diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index c98aef83ee..27f5349e2b 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -24,8 +24,8 @@ frappe.treeview_settings["Account"] = { let root_company = r.message.length ? r.message[0] : ""; me.page.fields_dict.root_company.set_value(root_company); - frappe.db.get_value("Company", {"name": company}, "ignore_root_company_validation", (r) => { - frappe.flags.ignore_root_company_validation = r.ignore_root_company_validation; + frappe.db.get_value("Company", {"name": company}, "allow_account_creation_against_child_company", (r) => { + frappe.flags.ignore_root_company_validation = r.allow_account_creation_against_child_company; }); } } diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 66ea7da6a5..dbd7c4149f 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -1466,7 +1466,7 @@ "columns": 0, "depends_on": "eval:doc.parent_company", "fetch_if_empty": 0, - "fieldname": "ignore_root_company_validation", + "fieldname": "allow_account_creation_against_child_company", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1475,7 +1475,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Ignore Root Company Validation", + "label": "Allow Account Creation Against Child Company", "length": 0, "no_copy": 0, "permlevel": 0, @@ -3093,7 +3093,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2019-03-25 22:13:08.721452", + "modified": "2019-03-26 17:15:50.390548", "modified_by": "Administrator", "module": "Setup", "name": "Company", From 1df62097f6be69e9177b0e83b154c5344c329a6a Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 26 Mar 2019 19:12:25 +0530 Subject: [PATCH 15/23] fix: offline pos, duplicate records creating --- erpnext/accounts/page/pos/pos.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index c3274b9fb5..4550dedba9 100755 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -333,6 +333,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var me = this; this.frm = {} this.load_data(true); + this.frm.doc.offline_pos_name = ''; this.setup(); this.set_default_customer() }, @@ -345,7 +346,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if (load_doc) { this.frm.doc = JSON.parse(localStorage.getItem('doc')); - this.frm.doc.offline_pos_name = null; } $.each(this.meta, function (i, data) { @@ -641,7 +641,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.list_customers_btn.toggleClass("view_customer"); me.pos_bill.show(); me.list_customers_btn.show(); - me.frm.doc.offline_pos_name = $(this).parents().attr('invoice-name') + me.frm.doc.offline_pos_name = $(this).parents().attr('invoice-name'); me.edit_record(); }) @@ -984,7 +984,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ } if(!this.customer_doc.fields_dict.customer_pos_id.value) { - this.customer_doc.set_value("customer_pos_id", $.now()) + this.customer_doc.set_value("customer_pos_id", frappe.datetime.now_datetime()) } }, @@ -1686,10 +1686,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ create_invoice: function () { var me = this; + var existing_pos_list = []; var invoice_data = {}; this.si_docs = this.get_doc_from_localstorage(); - if (this.frm.doc.offline_pos_name) { + if(this.si_docs) { + this.si_docs.forEach((row) => { + existing_pos_list.push(Object.keys(row)); + }); + } + + if (this.frm.doc.offline_pos_name + && in_list(existing_pos_list, this.frm.doc.offline_pos_name)) { this.update_invoice() //to retrieve and set the default payment invoice_data[this.frm.doc.offline_pos_name] = this.frm.doc; @@ -1698,8 +1706,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.frm.doc.paid_amount = this.frm.doc.net_total this.frm.doc.outstanding_amount = 0 - } else { - this.frm.doc.offline_pos_name = $.now(); + } else if(!this.frm.doc.offline_pos_name) { + this.frm.doc.offline_pos_name = frappe.datetime.now_datetime(); this.frm.doc.posting_date = frappe.datetime.get_today(); this.frm.doc.posting_time = frappe.datetime.now_time(); this.frm.doc.pos_total_qty = this.frm.doc.qty_total; From 22ebaf1b11a52fcbe9c4c3d7dacf101c9038fa58 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 7 Mar 2019 15:18:49 +0530 Subject: [PATCH 16/23] fix: added tags for discount amount, multiple customer po no, delivery notes --- erpnext/patches.txt | 4 +- .../v11_0/make_italian_localization_fields.py | 2 +- erpnext/regional/italy/e-invoice.xml | 44 +++++++++++++++---- erpnext/regional/italy/setup.py | 18 +++++++- 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7d49ad5fe3..e4a43df781 100755 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -587,5 +587,5 @@ erpnext.patches.v11_1.setup_guardian_role execute:frappe.delete_doc('DocType', 'Notification Control') erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 -erpnext.patches.v11_0.make_italian_localization_fields # 01-03-2019 -erpnext.patches.v11_1.make_job_card_time_logs \ No newline at end of file +erpnext.patches.v11_0.make_italian_localization_fields # 07-03-2019 +erpnext.patches.v11_1.make_job_card_time_logs diff --git a/erpnext/patches/v11_0/make_italian_localization_fields.py b/erpnext/patches/v11_0/make_italian_localization_fields.py index 44a281f86f..8fb2e5446b 100644 --- a/erpnext/patches/v11_0/make_italian_localization_fields.py +++ b/erpnext/patches/v11_0/make_italian_localization_fields.py @@ -6,7 +6,6 @@ from erpnext.regional.italy.setup import make_custom_fields, setup_report from erpnext.regional.italy import state_codes import frappe - def execute(): company = frappe.get_all('Company', filters = {'country': 'Italy'}) if not company: @@ -27,4 +26,5 @@ def execute(): frappe.db.sql(""" UPDATE tabAddress set {condition} country_code = UPPER(ifnull((select code from `tabCountry` where name = `tabAddress`.country), '')) + where country_code is null and state_code is null """.format(condition=condition)) diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml index 912b7899d6..4bff45f49b 100644 --- a/erpnext/regional/italy/e-invoice.xml +++ b/erpnext/regional/italy/e-invoice.xml @@ -127,22 +127,46 @@ {{ format_float(doc.stamp_duty) }} {%- endif %} - {{ format_float(doc.grand_total) }} + {%- if doc.discount_amount %} + + {%- if doc.discount_amount > 0.0 %} + SC + {%- else %} + MG + {%- endif %} + {%- if doc.additional_discount_percentage > 0.0 %} + {{ format_float(doc.additional_discount_percentage) }} + {%- endif %} + {{ format_float(doc.discount_amount) }} + + {%- endif %} + {{ format_float(doc.rounded_total or doc.grand_total) }} VENDITA - {%- if doc.po_no %} - - {{ doc.po_no }} - {%- if doc.po_date %} - {{ doc.po_date }} + {%- for row in doc.e_invoice_items %} + {%- if row.customer_po_no %} + + {{ row.customer_po_no }} + {%- if row.customer_po_date %} + {{ row.customer_po_date }} + {%- endif %} + {%- endif %} - - {%- endif %} + {%- endfor %} {%- if doc.is_return and doc.return_against_unamended %} {{ doc.return_against_unamended }} {%- endif %} + {%- for row in doc.e_invoice_items %} + {%- if row.delivery_note %} + + {{ row.delivery_note }} + {{ frappe.db.get_value('Delivery Note', row.delivery_note, 'posting_date') }} + {{ row.idx }} + + {%- endif %} + {%- endfor %} {%- if doc.shipping_address_data %} @@ -198,7 +222,9 @@ {{ payment_term.mode_of_payment_code.split("-")[0] }} {{ payment_term.due_date }} {{ format_float(payment_term.payment_amount) }} - {{ payment_term.bank_account_name }} + {%- if payment_term.bank_account_name %} + {{ payment_term.bank_account_name }} + {%- endif %} {%- if payment_term.bank_account_iban %} {{ payment_term.bank_account_iban }} {{ payment_term.bank_account_iban[5:10] }} diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py index 2b6e3af52a..b34f5e464b 100644 --- a/erpnext/regional/italy/setup.py +++ b/erpnext/regional/italy/setup.py @@ -26,6 +26,22 @@ def make_custom_fields(update=True): print_hide=1, hidden=1, read_only=1, options="currency") ] + customer_po_fields = [ + dict(fieldname='customer_po_details', label='Customer PO', + fieldtype='Section Break', insert_after='image'), + dict(fieldname='customer_po_no', label='Customer PO No', + fieldtype='Data', insert_after='customer_po_details', + fetch_from = 'sales_order.po_no', + print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1), + dict(fieldname='customer_po_clm_brk', label='', + fieldtype='Column Break', insert_after='customer_po_no', + print_hide=1, read_only=1), + dict(fieldname='customer_po_date', label='Customer PO Date', + fieldtype='Date', insert_after='customer_po_clm_brk', + fetch_from = 'sales_order.po_date', + print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1) + ] + custom_fields = { 'Company': [ dict(fieldname='sb_e_invoicing', label='E-Invoicing', @@ -128,7 +144,7 @@ def make_custom_fields(update=True): 'Purchase Invoice Item': invoice_item_fields, 'Sales Order Item': invoice_item_fields, 'Delivery Note Item': invoice_item_fields, - 'Sales Invoice Item': invoice_item_fields, + 'Sales Invoice Item': invoice_item_fields + customer_po_fields, 'Quotation Item': invoice_item_fields, 'Purchase Order Item': invoice_item_fields, 'Purchase Receipt Item': invoice_item_fields, From e43b6beff0228f5283f0cf3b9a222455d235df80 Mon Sep 17 00:00:00 2001 From: Himanshu Date: Tue, 26 Mar 2019 21:42:12 +0530 Subject: [PATCH 17/23] fix(Leave Balance Report): total allocated leaves not calculated properly (#16969) * fix: total alloted leaves not calculated properly * fix: Possible SQL injection * typo fix in sql query * prevent sql injection again ? * Use ORM for query --- .../leave_application/leave_application.py | 13 +++++++++ .../employee_leave_balance.py | 27 +++++++++---------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 692db8e1a5..b73d0e5b3f 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -399,6 +399,19 @@ def get_leave_balance_on(employee, leave_type, date, allocation_records=None, do return flt(allocation.total_leaves_allocated) - (flt(leaves_taken) + flt(leaves_encashed)) +def get_total_allocated_leaves(employee, leave_type, date): + filters= { + 'from_date': ['<=', date], + 'to_date': ['>=', date], + 'docstatus': 1, + 'leave_type': leave_type, + 'employee': employee + } + + leave_allocation_records = frappe.db.get_all('Leave Allocation', filters=filters, fields=['total_leaves_allocated']) + + return flt(leave_allocation_records[0]['total_leaves_allocated']) if leave_allocation_records else flt(0) + def get_leaves_for_period(employee, leave_type, from_date, to_date, status, docname=None): leave_applications = frappe.db.sql(""" select name, employee, leave_type, from_date, to_date, total_leave_days diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py index ed44d639f5..95cb30b791 100644 --- a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py +++ b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py @@ -5,21 +5,21 @@ from __future__ import unicode_literals import frappe from frappe import _ from erpnext.hr.doctype.leave_application.leave_application \ - import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period + import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period, get_total_allocated_leaves def execute(filters=None): leave_types = frappe.db.sql_list("select name from `tabLeave Type` order by name asc") - + columns = get_columns(leave_types) data = get_data(filters, leave_types) - + return columns, data - + def get_columns(leave_types): columns = [ - _("Employee") + ":Link/Employee:150", - _("Employee Name") + "::200", + _("Employee") + ":Link/Employee:150", + _("Employee Name") + "::200", _("Department") +"::150" ] @@ -27,18 +27,18 @@ def get_columns(leave_types): columns.append(_(leave_type) + " " + _("Opening") + ":Float:160") columns.append(_(leave_type) + " " + _("Taken") + ":Float:160") columns.append(_(leave_type) + " " + _("Balance") + ":Float:160") - + return columns - + def get_data(filters, leave_types): user = frappe.session.user allocation_records_based_on_to_date = get_leave_allocation_records(filters.to_date) allocation_records_based_on_from_date = get_leave_allocation_records(filters.from_date) - active_employees = frappe.get_all("Employee", - filters = { "status": "Active", "company": filters.company}, + active_employees = frappe.get_all("Employee", + filters = { "status": "Active", "company": filters.company}, fields = ["name", "employee_name", "department", "user_id"]) - + data = [] for employee in active_employees: leave_approvers = get_approvers(employee.department) @@ -51,8 +51,7 @@ def get_data(filters, leave_types): filters.from_date, filters.to_date) # opening balance - opening = get_leave_balance_on(employee.name, leave_type, filters.from_date, - allocation_records_based_on_from_date.get(employee.name, frappe._dict())) + opening = get_total_allocated_leaves(employee.name, leave_type, filters.to_date) # closing balance closing = get_leave_balance_on(employee.name, leave_type, filters.to_date, @@ -61,7 +60,7 @@ def get_data(filters, leave_types): row += [opening, leaves_taken, closing] data.append(row) - + return data def get_approvers(department): From 1b7059b867c998f7fa94b852ca80c064df9a25a3 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 12 Mar 2019 17:44:29 +0530 Subject: [PATCH 18/23] fix: ImponibileImporto calculation --- erpnext/patches.txt | 2 +- .../v11_0/make_italian_localization_fields.py | 7 +++++ erpnext/regional/italy/e-invoice.xml | 20 ++++++------- erpnext/regional/italy/sales_invoice.js | 29 +++++++++++++------ erpnext/regional/italy/setup.py | 4 +-- erpnext/regional/italy/utils.py | 17 +++++++++-- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e4a43df781..9d1e7b1453 100755 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -587,5 +587,5 @@ erpnext.patches.v11_1.setup_guardian_role execute:frappe.delete_doc('DocType', 'Notification Control') erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 -erpnext.patches.v11_0.make_italian_localization_fields # 07-03-2019 +erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019 erpnext.patches.v11_1.make_job_card_time_logs diff --git a/erpnext/patches/v11_0/make_italian_localization_fields.py b/erpnext/patches/v11_0/make_italian_localization_fields.py index 8fb2e5446b..79958b9189 100644 --- a/erpnext/patches/v11_0/make_italian_localization_fields.py +++ b/erpnext/patches/v11_0/make_italian_localization_fields.py @@ -28,3 +28,10 @@ def execute(): from `tabCountry` where name = `tabAddress`.country), '')) where country_code is null and state_code is null """.format(condition=condition)) + + frappe.db.sql(""" + UPDATE `tabSales Invoice Item` si, `tabSales Order` so + set si.customer_po_no = so.po_no, si.customer_po_date = so.po_date + WHERE + si.sales_order = so.name and so.po_no is not null + """) diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml index 4bff45f49b..935077b7be 100644 --- a/erpnext/regional/italy/e-invoice.xml +++ b/erpnext/regional/italy/e-invoice.xml @@ -143,15 +143,11 @@ {{ format_float(doc.rounded_total or doc.grand_total) }} VENDITA - {%- for row in doc.e_invoice_items %} - {%- if row.customer_po_no %} - - {{ row.customer_po_no }} - {%- if row.customer_po_date %} - {{ row.customer_po_date }} - {%- endif %} - - {%- endif %} + {%- for po_no, po_date in doc.customer_po_data.items() %} + + {{ po_no }} + {{ po_date }} + {%- endfor %} {%- if doc.is_return and doc.return_against_unamended %} @@ -188,7 +184,11 @@ {{ item.stock_uom }} {{ format_float(item.price_list_rate or item.rate) }} {{ render_discount_or_margin(item) }} - {{ format_float(item.amount) }} + {%- if (item.discount_amount or item.rate_with_margin) %} + {{ format_float(item.net_amount) }} + {%- else %} + {{ format_float(item.amount) }} + {%- endif %} {{ format_float(item.tax_rate) }} {%- if item.tax_exemption_reason %} {{ item.tax_exemption_reason.split("-")[0] }} diff --git a/erpnext/regional/italy/sales_invoice.js b/erpnext/regional/italy/sales_invoice.js index 3457f7161e..586a52937b 100644 --- a/erpnext/regional/italy/sales_invoice.js +++ b/erpnext/regional/italy/sales_invoice.js @@ -3,15 +3,26 @@ erpnext.setup_e_invoice_button = (doctype) => { refresh: (frm) => { if(frm.doc.docstatus == 1) { frm.add_custom_button('Generate E-Invoice', () => { - var w = window.open( - frappe.urllib.get_full_url( - "/api/method/erpnext.regional.italy.utils.generate_single_invoice?" - + "docname=" + frm.doc.name - ) - ) - if (!w) { - frappe.msgprint(__("Please enable pop-ups")); return; - } + frm.call({ + method: "erpnext.regional.italy.utils.generate_single_invoice", + args: { + docname: frm.doc.name + }, + callback: function(r) { + frm.reload_doc(); + if(r.message) { + var w = window.open( + frappe.urllib.get_full_url( + "/api/method/erpnext.regional.italy.utils.download_e_invoice_file?" + + "file_name=" + r.message + ) + ) + if (!w) { + frappe.msgprint(__("Please enable pop-ups")); return; + } + } + } + }); }); } } diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py index b34f5e464b..1526d6f62f 100644 --- a/erpnext/regional/italy/setup.py +++ b/erpnext/regional/italy/setup.py @@ -32,14 +32,14 @@ def make_custom_fields(update=True): dict(fieldname='customer_po_no', label='Customer PO No', fieldtype='Data', insert_after='customer_po_details', fetch_from = 'sales_order.po_no', - print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1), + print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1, no_copy=1), dict(fieldname='customer_po_clm_brk', label='', fieldtype='Column Break', insert_after='customer_po_no', print_hide=1, read_only=1), dict(fieldname='customer_po_date', label='Customer PO Date', fieldtype='Date', insert_after='customer_po_clm_brk', fetch_from = 'sales_order.po_date', - print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1) + print_hide=1, allow_on_submit=1, fetch_if_empty= 1, read_only=1, no_copy=1) ] custom_fields = { diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py index e56c98b271..b299a6fa48 100644 --- a/erpnext/regional/italy/utils.py +++ b/erpnext/regional/italy/utils.py @@ -82,6 +82,14 @@ def prepare_invoice(invoice, progressive_number): if item.tax_rate == 0.0 and item.tax_amount == 0.0: item.tax_exemption_reason = tax_data["0.0"]["tax_exemption_reason"] + customer_po_data = {} + for d in invoice.e_invoice_items: + if (d.customer_po_no and d.customer_po_date + and d.customer_po_no not in customer_po_data): + customer_po_data[d.customer_po_no] = d.customer_po_date + + invoice.customer_po_data = customer_po_data + return invoice def get_conditions(filters): @@ -267,13 +275,18 @@ def prepare_and_attach_invoice(doc, replace=False): def generate_single_invoice(docname): doc = frappe.get_doc("Sales Invoice", docname) + e_invoice = prepare_and_attach_invoice(doc, True) + return e_invoice.file_name + +@frappe.whitelist() +def download_e_invoice_file(file_name): content = None - with open(frappe.get_site_path('private', 'files', e_invoice.file_name), "r") as f: + with open(frappe.get_site_path('private', 'files', file_name), "r") as f: content = f.read() - frappe.local.response.filename = e_invoice.file_name + frappe.local.response.filename = file_name frappe.local.response.filecontent = content frappe.local.response.type = "download" From abc2a64d5e5d8869126f53dc509070281b8ead92 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 27 Mar 2019 20:25:18 +0530 Subject: [PATCH 19/23] fix: Commonify get gl_entry code by moving it to accounts_controller --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 5 ----- erpnext/accounts/doctype/payment_entry/payment_entry.py | 5 ----- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 5 ----- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 5 ----- erpnext/controllers/accounts_controller.py | 7 +++++++ 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 7c48b5c4f8..92342f4d7c 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -52,11 +52,6 @@ class JournalEntry(AccountsController): self.update_loan() self.update_inter_company_jv() - def before_print(self): - self.gl_entries = frappe.get_list("GL Entry",filters={"voucher_type": "Journal Entry", - "voucher_no": self.name} , - fields=["account", "party_type", "party", "debit", "credit", "remarks"] - ) def get_title(self): return self.pay_to_recd_from or self.accounts[0].account diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index f356ef8c8f..91004104af 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -70,11 +70,6 @@ class PaymentEntry(AccountsController): self.update_advance_paid() self.update_expense_claim() - def before_print(self): - self.gl_entries = frappe.get_list("GL Entry",filters={"voucher_type": "Payment Entry", - "voucher_no": self.name} , - fields=["account", "party_type", "party", "debit", "credit", "remarks"] - ) def on_cancel(self): self.setup_party_account_field() diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 53eb73191d..450f2d0eb7 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -55,11 +55,6 @@ class PurchaseInvoice(BuyingController): if not self.on_hold: self.release_date = '' - def before_print(self): - self.gl_entries = frappe.get_list("GL Entry",filters={"voucher_type": "Purchase Invoice", - "voucher_no": self.name} , - fields=["account", "party_type", "party", "debit", "credit"] - ) def invoice_is_blocked(self): return self.on_hold and (not self.release_date or self.release_date > getdate(nowdate())) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 61e1224596..489343c00c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -205,11 +205,6 @@ class SalesInvoice(SellingController): def before_cancel(self): self.update_time_sheet(None) - def before_print(self): - self.gl_entries = frappe.get_list("GL Entry",filters={"voucher_type": "Sales Invoice", - "voucher_no": self.name} , - fields=["account", "party_type", "party", "debit", "credit"] - ) def on_cancel(self): self.check_close_sales_order("sales_order") diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 34bbe7b999..b05dc1950b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -116,6 +116,13 @@ class AccountsController(TransactionBase): self.validate_non_invoice_documents_schedule() def before_print(self): + if self.doctype in ['Journal Entry', 'Payment Entry', 'Sales Invoice', 'Purchase Invoice']: + self.gl_entries = frappe.get_list("GL Entry", filters={ + "voucher_type": self.doctype, + "voucher_no": self.name} , + fields=["account", "party_type", "party", "debit", "credit", "remarks"] + ) + if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice', 'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']: if self.get("group_same_items"): From a7992ecb6246e770205554bc9af4692c5a62a7c4 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 27 Mar 2019 20:32:42 +0530 Subject: [PATCH 20/23] style: Fix formatting --- erpnext/controllers/accounts_controller.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index b05dc1950b..86b1ab6ece 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -119,9 +119,8 @@ class AccountsController(TransactionBase): if self.doctype in ['Journal Entry', 'Payment Entry', 'Sales Invoice', 'Purchase Invoice']: self.gl_entries = frappe.get_list("GL Entry", filters={ "voucher_type": self.doctype, - "voucher_no": self.name} , - fields=["account", "party_type", "party", "debit", "credit", "remarks"] - ) + "voucher_no": self.name + }, fields=["account", "party_type", "party", "debit", "credit", "remarks"]) if self.doctype in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice', 'Supplier Quotation', 'Purchase Receipt', 'Delivery Note', 'Quotation']: From 010acf75fa2f2f3f4a7a328067937ae882ab8a4d Mon Sep 17 00:00:00 2001 From: Gaurav Date: Thu, 28 Mar 2019 10:42:23 +0530 Subject: [PATCH 21/23] fix(regional,italy): autoset tax id, cf from customer before validating missing values Fixes issue #17033 --- erpnext/regional/italy/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py index e56c98b271..719f6c59c7 100644 --- a/erpnext/regional/italy/utils.py +++ b/erpnext/regional/italy/utils.py @@ -203,15 +203,19 @@ def sales_invoice_validate(doc): frappe.throw(_("Please set either the Tax ID or Fiscal Code on Company '%s'" % doc.company), title=_("E-Invoicing Information Missing")) #Validate customer details - customer_type, is_public_administration = frappe.db.get_value("Customer", doc.customer, ["customer_type", "is_public_administration"]) - if customer_type == _("Individual"): + customer = frappe.get_doc("Customer", doc.customer) + + if customer.customer_type == _("Individual"): + doc.customer_fiscal_code = customer.fiscal_code if not doc.customer_fiscal_code: frappe.throw(_("Please set Fiscal Code for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing")) else: - if is_public_administration: + if customer.is_public_administration: + doc.customer_fiscal_code = customer.fiscal_code if not doc.customer_fiscal_code: frappe.throw(_("Please set Fiscal Code for the public administration '%s'" % doc.customer), title=_("E-Invoicing Information Missing")) else: + doc.tax_id = customer.tax_id if not doc.tax_id: frappe.throw(_("Please set Tax ID for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing")) From bd80fd13cb1adc665fc90eb54b2bd90cce7e54f4 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Thu, 28 Mar 2019 12:18:03 +0530 Subject: [PATCH 22/23] fix(regional,italy): autoset company cf, tax_id before validating --- erpnext/regional/italy/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py index 719f6c59c7..89a603fdf7 100644 --- a/erpnext/regional/italy/utils.py +++ b/erpnext/regional/italy/utils.py @@ -199,6 +199,8 @@ def sales_invoice_validate(doc): else: doc.company_fiscal_regime = company_fiscal_regime + doc.company_tax_id = frappe.get_cached_value("Company", doc.company, 'tax_id') + doc.company_fiscal_code = frappe.get_cached_value("Company", doc.company, 'fiscal_code') if not doc.company_tax_id and not doc.company_fiscal_code: frappe.throw(_("Please set either the Tax ID or Fiscal Code on Company '%s'" % doc.company), title=_("E-Invoicing Information Missing")) From f2036dd1d1142260e906d9029db4242323cea031 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 28 Mar 2019 14:21:58 +0600 Subject: [PATCH 23/23] bumped to version 11.1.17 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 8fbdb54234..e510e38c09 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -5,7 +5,7 @@ import frappe from erpnext.hooks import regional_overrides from frappe.utils import getdate -__version__ = '11.1.16' +__version__ = '11.1.17' def get_default_company(user=None): '''Get default company for user'''