diff --git a/.drone.yml b/.drone.yml index a52ef0e..b873d8e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,7 +7,8 @@ pipeline: image: ${IMAGE} environment: - CFLAGS=-O0 - - TOX_TESTENV_PASSENV=CFLAGS + - DB_CACHE=/cache + - TOX_TESTENV_PASSENV=CFLAGS DB_CACHE - POSTGRESQL_URI=postgresql://postgres@postgresql:5432/ commands: - pip install tox diff --git a/__init__.py b/__init__.py index 8052da2..04573fa 100644 --- a/__init__.py +++ b/__init__.py @@ -1,10 +1,11 @@ # The COPYRIGHT file at the top level of this repository contains the full # copyright notices and license terms. from trytond.pool import Pool -from .party import Party +from .party import Party, PartyParty def register(): Pool.register( Party, + PartyParty, module='account_invoice_party_invoice_to', type_='model') diff --git a/party.py b/party.py index 913ca5c..5fd0caa 100644 --- a/party.py +++ b/party.py @@ -1,16 +1,31 @@ # The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.model import fields -from trytond.pool import PoolMeta +from trytond.model import ModelSQL, fields +from trytond.pool import PoolMeta, Pool +from trytond.modules.company.model import CompanyValueMixin -__all__ = ['Party'] +__all__ = ['Party', 'PartyParty'] class Party: __name__ = 'party.party' __metaclass__ = PoolMeta - customer_to_invoice = fields.Property( + customer_to_invoice = fields.MultiValue( fields.Many2One('party.party', 'Customer to invoice')) - supplier_to_invoice = fields.Property( + supplier_to_invoice = fields.MultiValue( fields.Many2One('party.party', 'Supplier to invoice')) + + @classmethod + def multivalue_model(cls, field): + pool = Pool() + if field in {'customer_to_invoice', 'supplier_to_invoice'}: + return pool.get('party.party.party') + return super(Party, cls).multivalue_model(field) + + +class PartyParty(ModelSQL, CompanyValueMixin): + "Party Party" + __name__ = 'party.party.party' + customer_to_invoice = fields.Many2One('party.party', 'Customer to invoice') + supplier_to_invoice = fields.Many2One('party.party', 'Supplier to invoice') diff --git a/tox.ini b/tox.ini index d205768..3d844ea 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ deps = {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5 pypy-postgresql: psycopg2cffi >= 2.5 mysql: MySQL-python + sqlite: sqlitebck setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://} diff --git a/tryton.cfg b/tryton.cfg index 7cb7338..f8ebdff 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=4.2.0 +version=4.8.0 depends: account_invoice ir