From b47302dd528c36d7e9660ef97a168aba48f5ea1a Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 20 Apr 2018 14:20:49 +0530 Subject: [PATCH] unlink reference on cancellation of any invoice --- .../purchase_invoice/purchase_invoice.js | 32 ------------------- .../doctype/sales_invoice/sales_invoice.js | 1 - .../doctype/sales_invoice/sales_invoice.py | 5 ++- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index af6839031a3..a2ea0965aa7 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -110,38 +110,6 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ supplier: function() { var me = this; - let internal; - frappe.db.get_value('Supplier', {name: this.frm.doc.supplier}, 'is_internal_supplier', (r) => { - if (r) { - internal = r.is_internal_supplier; - } - if (internal == 1) { - frappe.call({ - method:"erpnext.accounts.doctype.sales_invoice.sales_invoice.get_allowed_companies", - args: {supplier: this.frm.doc.supplier}, - callback: function(r){ - if (r.message){ - if (me.frm.doc.company) { - me.frm.set_value("company", r.message[0]); - } - me.frm.set_query('company', function() { - return { - "filters": {"name": ["in", r.message]} - } - } - ); - } - } - }); - } - else { - me.frm.set_query('company', function(){ - return { - "filters": {"name": ["like", "%" + "" + "%"]} - } - }); - } - }); if(this.frm.updating_party_details) return; erpnext.utils.get_party_details(this.frm, "erpnext.accounts.party.get_party_details", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 91696c203dc..8e48cc3a89d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -663,4 +663,3 @@ var calculate_total_billing_amount = function(frm) { refresh_field('total_billing_amount') } - diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index acd455eb333..7a8ee2434f5 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1030,7 +1030,7 @@ def get_inter_company_details(doc, doctype): company = frappe.db.get_value("Customer", {"name": doc.get("customer")}, "represents_company") else: party = frappe.db.get_value("Customer", {"is_internal_customer":1, "represents_company": doc.get("company")}, "name") - company = frappe.db.get_value("Customer", {"name": doc.get("supplier")}, "represents_company") + company = frappe.db.get_value("Supplier", {"name": doc.get("supplier")}, "represents_company") return { "party": party, @@ -1067,6 +1067,7 @@ def validate_inter_company_invoice(doc): company = details.get("company") default_currency = frappe.db.get_value("Company", company, "default_currency") + if default_currency != doc.get("currency"): frappe.throw(_("Company currencies of both the companies should match for Inter Company Transactions.")) @@ -1106,8 +1107,6 @@ def make_inter_company_invoice(doctype, source_name, target_doc=None): target_doc.expense_account = "" target_doc.cost_center = "" - base_doc = "Sales Invoice" - target_doctype = "Purchase Invoice" doclist = get_mapped_doc(doctype, source_name, { doctype: { "doctype": target_doctype,