From d81f81134955783d632b7d4005999da2092e82e7 Mon Sep 17 00:00:00 2001 From: Jannat Patel <31363128+pateljannat@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:53:39 +0530 Subject: [PATCH] fix: map missing fields in opportunity (#27904) --- erpnext/crm/doctype/opportunity/opportunity.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index be843a3386..55e0efaab1 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -33,6 +33,7 @@ class Opportunity(TransactionBase): self.validate_item_details() self.validate_uom_is_integer("uom", "qty") self.validate_cust_name() + self.map_fields() if not self.title: self.title = self.customer_name @@ -43,6 +44,15 @@ class Opportunity(TransactionBase): else: self.calculate_totals() + def map_fields(self): + for field in self.meta.fields: + if not self.get(field.fieldname): + try: + value = frappe.db.get_value(self.opportunity_from, self.party_name, field.fieldname) + frappe.db.set(self, field.fieldname, value) + except Exception: + continue + def calculate_totals(self): total = base_total = 0 for item in self.get('items'):