From 8c9c9cfc5fd0938a97b117a8aebfb031cebd6b95 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 27 Dec 2016 12:31:35 +0530 Subject: [PATCH] When a new company is made, cash account should be automatically set for Mode of Payment --- erpnext/accounts/page/pos/pos.js | 2 +- erpnext/setup/doctype/company/company.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index a4078bdca6..c0f82bc526 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -593,7 +593,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.remove_item = [] $.each(this.frm.doc["items"] || [], function(i, d) { - if(d.serial_no){ + if(d.serial_no && field == 'qty'){ me.validate_serial_no_qty(d, item_code, field, value) } diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 7f506d5440..94a01010fb 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -78,6 +78,8 @@ class Company(Document): if not frappe.local.flags.ignore_chart_of_accounts: self.set_default_accounts() + if self.default_cash_account: + self.mode_of_payment() if self.default_currency: frappe.db.set_value("Currency", self.default_currency, "enabled", 1) @@ -162,6 +164,16 @@ class Company(Document): if account: self.db_set(fieldname, account) + def mode_of_payment(self): + cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name') + if cash: + mode_of_payment = frappe.get_doc('Mode of Payment', cash) + mode_of_payment.append('accounts', { + 'company': self.name, + 'default_account': self.default_cash_account + }) + mode_of_payment.save(ignore_permissions=True) + def create_default_cost_center(self): cc_list = [ {