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() self.calculate_totals()
def map_fields(self): def map_fields(self):
for field in self.meta.fields: for field in self.meta.get_valid_columns():
if not self.get(field.fieldname): if not self.get(field) and frappe.db.field_exists(self.opportunity_from, field):
try: try:
value = frappe.db.get_value(self.opportunity_from, self.party_name, field.fieldname) value = frappe.db.get_value(self.opportunity_from, self.party_name, field)
frappe.db.set(self, field.fieldname, value) frappe.db.set(self, field, value)
except Exception: except Exception:
continue continue