fix: only query fields that exist

This commit is contained in:
Ankush Menat 2022-04-24 19:19:22 +05:30
parent ce75fe0ec4
commit 0fdfc1e76e

View File

@ -54,11 +54,11 @@ class Opportunity(TransactionBase):
self.calculate_totals()
def map_fields(self):
for field in self.meta.fields:
if not self.get(field.fieldname):
for field in self.meta.get_valid_columns():
if not self.get(field) and frappe.db.field_exists(self.opportunity_from, field):
try:
value = frappe.db.get_value(self.opportunity_from, self.party_name, field.fieldname)
frappe.db.set(self, field.fieldname, value)
value = frappe.db.get_value(self.opportunity_from, self.party_name, field)
frappe.db.set(self, field, value)
except Exception:
continue