From a60c3081cf54b61757c1196c957bdbf3f5738a99 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 11 May 2021 16:38:33 +0530 Subject: [PATCH] fix: Breaking cost center validation --- erpnext/controllers/accounts_controller.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index c409850734..996c4ed11b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -368,6 +368,11 @@ class AccountsController(TransactionBase): if self.doctype in ["Purchase Invoice", "Sales Invoice"] and item.meta.get_field('is_fixed_asset'): item.set('is_fixed_asset', ret.get('is_fixed_asset', 0)) + # Double check for cost center + # Items add via promotional scheme may not have cost center set + if hasattr(item, 'cost_center') and not item.get('cost_center'): + item.set('cost_center', self.get('cost_center') or erpnext.get_default_cost_center(self.company)) + if ret.get("pricing_rules"): self.apply_pricing_rule_on_items(item, ret) self.set_pricing_rule_details(item, ret)