From 4a994d4eb8fb2153fcdcb0db7c8f2b7bce902ca5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 25 Apr 2019 17:47:26 +0530 Subject: [PATCH] fix: Don't allocate advance if pos --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js | 1 + erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 1 + erpnext/controllers/accounts_controller.py | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 7ab7f149021..d224961bd8e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -285,6 +285,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ is_paid: function() { hide_fields(this.frm.doc); if(cint(this.frm.doc.is_paid)) { + this.frm.set_value("allocate_advances_automatically", 0); if(!this.frm.doc.company) { this.frm.set_value("is_paid", 0) frappe.msgprint(__("Please specify Company to proceed")); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 44af743ebf8..f21fbd97946 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -369,6 +369,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte set_pos_data: function() { if(this.frm.doc.is_pos) { + this.frm.set_value("allocate_advances_automatically", 0); if(!this.frm.doc.company) { this.frm.set_value("is_pos", 0); frappe.msgprint(__("Please specify Company to proceed")); diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 63ea2591c5e..155a996a15a 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -89,7 +89,8 @@ class AccountsController(TransactionBase): self.validate_paid_amount() if self.doctype in ['Purchase Invoice', 'Sales Invoice']: - if cint(self.allocate_advances_automatically): + pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid" + if cint(self.allocate_advances_automatically) and not cint(self.get(pos_check_field)): self.set_advances() if self.is_return: