lims_industry: default country in Plants and Addresses

This commit is contained in:
Adri?n Bernardi 2019-09-20 19:12:45 -03:00
parent 079a26e1be
commit b743187b0b
2 changed files with 22 additions and 2 deletions

View File

@ -3,8 +3,9 @@
# the full copyright notices and license terms.
from trytond.model import ModelSQL, ModelView, fields
from trytond.pyson import Eval
from trytond.pool import Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['Plant', 'EquipmentType', 'Brand', 'ComponentType',
'EquipmentTemplate', 'EquipmentTemplateComponentType', 'Equipment',
@ -45,6 +46,15 @@ class Plant(ModelSQL, ModelView):
cls._order.insert(0, ('party', 'ASC'))
cls._order.insert(1, ('name', 'ASC'))
@staticmethod
def default_country():
Company = Pool().get('company.company')
company_id = Transaction().context.get('company')
if company_id:
address = Company(company_id).party.address_get()
if address and address.country:
return address.country.id
class EquipmentType(ModelSQL, ModelView):
'Equipment Type'

View File

@ -3,8 +3,9 @@
# the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['Party', 'Address']
@ -43,3 +44,12 @@ class Address(metaclass=PoolMeta):
technical_contact = fields.Boolean('Technical contact')
administrative_contact = fields.Boolean('Administrative contact')
contract_contact = fields.Boolean('Contract contact')
@staticmethod
def default_country():
Company = Pool().get('company.company')
company_id = Transaction().context.get('company')
if company_id:
address = Company(company_id).party.address_get()
if address and address.country:
return address.country.id