From 879cb6ebee9f56573460595ebe513328c099df9a Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 31 Aug 2016 13:04:05 +0530 Subject: [PATCH] [POS] Fixed POS Sales Invoice when Payment Table is Empty --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b28911edef1..a5028c5ee56 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -89,6 +89,8 @@ class SalesInvoice(SellingController): set_account_for_mode_of_payment(self) def on_submit(self): + self.validate_pos_paid_amount() + if not self.recurring_id: frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) @@ -121,6 +123,10 @@ class SalesInvoice(SellingController): self.update_time_sheet(self.name) + def validate_pos_paid_amount(self): + if len(self.payments) == 0 and self.is_pos: + frappe.throw(_("At least one mode of payment is required for POS invoice.")) + def before_cancel(self): self.update_time_sheet(None) @@ -248,7 +254,7 @@ class SalesInvoice(SellingController): from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile pos = get_pos_profile(self.company) - if not self.get('payments'): + if not self.get('payments') and not for_validate: pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None update_multi_mode_option(self, pos_profile)