From 9a3462031dbba19eb752c4c18a4afbc6447aa945 Mon Sep 17 00:00:00 2001 From: tundebabzy Date: Fri, 16 Jun 2017 11:00:14 +0100 Subject: [PATCH] [UX] Error in purchase transaction - Ignore instead of Prompt #7766 (#9329) * sets tax category to "Total" if all items are non-stock items * makes notification message translatable and removes multi-line string * Update buying_controller.py --- erpnext/controllers/buying_controller.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 5bc8bb38f86..d770af3cdfe 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -73,10 +73,13 @@ class BuyingController(StockController): def validate_stock_or_nonstock_items(self): if self.meta.get_field("taxes") and not self.get_stock_items(): - tax_for_valuation = [d.account_head for d in self.get("taxes") + tax_for_valuation = [d for d in self.get("taxes") if d.category in ["Valuation", "Valuation and Total"]] + if tax_for_valuation: - frappe.throw(_("Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items")) + for d in tax_for_valuation: + d.category = 'Total' + msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items')) def set_landed_cost_voucher_amount(self): for d in self.get("items"):