Don't throw expense account validation on fetching item details

This commit is contained in:
Nabin Hait 2016-10-05 17:15:43 +05:30
parent 7b9638c93a
commit cccc45edc5
3 changed files with 6 additions and 6 deletions

View File

@ -58,7 +58,7 @@ class PurchaseInvoice(BuyingController):
self.check_for_closed_status()
self.validate_with_previous_doc()
self.validate_uom_is_integer("uom", "qty")
self.set_expense_account()
self.set_expense_account(for_validate=True)
self.set_against_expense_account()
self.validate_write_off_account()
self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount", "items")
@ -155,7 +155,7 @@ class PurchaseInvoice(BuyingController):
super(PurchaseInvoice, self).validate_warehouse()
def set_expense_account(self):
def set_expense_account(self, for_validate=False):
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
if auto_accounting_for_stock:
@ -181,7 +181,7 @@ class PurchaseInvoice(BuyingController):
else:
item.expense_account = stock_not_billed_account
elif not item.expense_account:
elif not item.expense_account and for_validate:
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
def set_against_expense_account(self):

View File

@ -144,7 +144,7 @@ class AccountsController(TransactionBase):
self.conversion_rate = get_exchange_rate(self.currency,
self.company_currency)
def set_missing_item_details(self):
def set_missing_item_details(self, for_validate=False):
"""set missing item values"""
from erpnext.stock.get_item_details import get_item_details
@ -196,7 +196,7 @@ class AccountsController(TransactionBase):
(1.0 - (flt(item.discount_percentage) / 100.0)), item.precision("rate"))
if self.doctype == "Purchase Invoice":
self.set_expense_account()
self.set_expense_account(for_validate)
def set_taxes(self):
if not self.meta.get_field("taxes"):

View File

@ -62,7 +62,7 @@ class BuyingController(StockController):
if getattr(self, "supplier", None):
self.update_if_missing(get_party_details(self.supplier, party_type="Supplier", ignore_permissions=self.flags.ignore_permissions))
self.set_missing_item_details()
self.set_missing_item_details(for_validate)
def set_supplier_from_item_default(self):
if self.meta.get_field("supplier") and not self.supplier: