fix: map missing fields in opportunity (#27904)

This commit is contained in:
Jannat Patel 2021-10-20 10:53:39 +05:30 committed by GitHub
parent 73ae504721
commit d81f811349
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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'):