Avoid deprecated logic for fetching vendor contact email/phone

This commit is contained in:
Lance Edgar 2023-10-06 15:03:17 -05:00
parent 2ae2cdc4bd
commit d84b98041f

View file

@ -92,7 +92,8 @@ class VendorView(MasterView):
g.set_link('abbreviation') g.set_link('abbreviation')
def configure_form(self, f): def configure_form(self, f):
super(VendorView, self).configure_form(f) super().configure_form(f)
app = self.get_rattail_app()
vendor = f.model_instance vendor = f.model_instance
f.set_type('lead_time_days', 'quantity') f.set_type('lead_time_days', 'quantity')
@ -111,7 +112,7 @@ class VendorView(MasterView):
# orders_email # orders_email
f.set_renderer('orders_email', self.render_orders_email) f.set_renderer('orders_email', self.render_orders_email)
if not self.creating and vendor.emails: if not self.creating and vendor.emails:
f.set_default('orders_email', vendor.get_email_address(type_='Orders') or '') f.set_default('orders_email', app.get_contact_email_address(vendor, type_='Orders') or '')
# contact # contact
if self.creating: if self.creating:
@ -128,7 +129,7 @@ class VendorView(MasterView):
if 'orders_email' in data: if 'orders_email' in data:
address = data['orders_email'] address = data['orders_email']
email = vendor.get_email(type_='Orders') email = app.get_contact_email(vendor, type_='Orders')
if address: if address:
if email: if email:
if email.address != address: if email.address != address:
@ -145,7 +146,8 @@ class VendorView(MasterView):
return vendor.emails[0].address return vendor.emails[0].address
def render_orders_email(self, vendor, field): def render_orders_email(self, vendor, field):
return vendor.get_email_address(type_='Orders') app = self.get_rattail_app()
return app.get_contact_email_address(vendor, type_='Orders')
def render_default_phone(self, vendor, field): def render_default_phone(self, vendor, field):
if vendor.phones: if vendor.phones: