changeset bf0e85514a98 in modules/company:default details: https://hg.tryton.org/modules/company?cmd=changeset;node=bf0e85514a98 description: Use company country code for phone country code
issue7831 review56471002 diffstat: __init__.py | 1 + party.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletions(-) diffs (44 lines): diff -r bbed411aaa7b -r bf0e85514a98 __init__.py --- a/__init__.py Mon Oct 01 12:39:10 2018 +0200 +++ b/__init__.py Thu Dec 13 18:47:37 2018 +0100 @@ -23,6 +23,7 @@ party.PartyConfigurationLang, party.Party, party.PartyLang, + party.ContactMechanism, Rule, module='company', type_='model') Pool.register( diff -r bbed411aaa7b -r bf0e85514a98 party.py --- a/party.py Mon Oct 01 12:39:10 2018 +0200 +++ b/party.py Thu Dec 13 18:47:37 2018 +0100 @@ -8,7 +8,7 @@ from .model import CompanyMultiValueMixin, CompanyValueMixin __all__ = ['Configuration', 'PartyConfigurationLang', 'Party', 'PartyLang', - 'PartyReplace', 'PartyErase'] + 'PartyReplace', 'PartyErase', 'ContactMechanism'] class Configuration(CompanyMultiValueMixin, metaclass=PoolMeta): @@ -93,3 +93,20 @@ 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