Use company country code for phone country code
issue7831 review56471002
This commit is contained in:
@@ -23,6 +23,7 @@ def register():
|
||||
party.PartyConfigurationLang,
|
||||
party.Party,
|
||||
party.PartyLang,
|
||||
party.ContactMechanism,
|
||||
Rule,
|
||||
module='company', type_='model')
|
||||
Pool.register(
|
||||
|
||||
@@ -8,7 +8,7 @@ from trytond.transaction import Transaction
|
||||
from .model import CompanyMultiValueMixin, CompanyValueMixin
|
||||
|
||||
__all__ = ['Configuration', 'PartyConfigurationLang', 'Party', 'PartyLang',
|
||||
'PartyReplace', 'PartyErase']
|
||||
'PartyReplace', 'PartyErase', 'ContactMechanism']
|
||||
|
||||
|
||||
class Configuration(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||
@@ -93,3 +93,20 @@ class PartyErase(metaclass=PoolMeta):
|
||||
|
||||
def check_erase_company(self, party, company):
|
||||
pass
|
||||
|
||||
|
||||
class ContactMechanism(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||
__name__ = 'party.contact_mechanism'
|
||||
|
||||
def _phone_country_codes(self):
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
context = Transaction().context
|
||||
|
||||
yield from super()._phone_country_codes()
|
||||
|
||||
if 'company' in context:
|
||||
company = Company(context['company'])
|
||||
for address in company.party.addresses:
|
||||
if address.country:
|
||||
yield address.country.code
|
||||
|
||||
Reference in New Issue
Block a user