This commit is contained in:
@@ -8,7 +8,7 @@ from sql.conditionals import Coalesce
|
|||||||
|
|
||||||
from trytond import backend
|
from trytond import backend
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.model import ModelSQL, ValueMixin, fields
|
from trytond.model import ModelSQL, fields
|
||||||
from trytond.modules.company.model import (
|
from trytond.modules.company.model import (
|
||||||
CompanyMultiValueMixin, CompanyValueMixin)
|
CompanyMultiValueMixin, CompanyValueMixin)
|
||||||
from trytond.modules.currency.fields import Monetary
|
from trytond.modules.currency.fields import Monetary
|
||||||
@@ -40,10 +40,12 @@ supplier_ncf_type = fields.Selection(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Party(metaclass=PoolMeta):
|
class Party(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||||
__name__ = 'party.party'
|
__name__ = 'party.party'
|
||||||
customer_ncf_type = fields.MultiValue(customer_ncf_type)
|
customer_ncf_type = fields.MultiValue(customer_ncf_type)
|
||||||
supplier_ncf_type = fields.MultiValue(supplier_ncf_type)
|
supplier_ncf_type = fields.MultiValue(supplier_ncf_type)
|
||||||
|
ncf_types = fields.One2Many(
|
||||||
|
'party.party.ncf_type', 'party', "NCF Types")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def multivalue_model(cls, field):
|
def multivalue_model(cls, field):
|
||||||
@@ -69,12 +71,16 @@ class Party(metaclass=PoolMeta):
|
|||||||
'default_supplier_ncf_type', **pattern)
|
'default_supplier_ncf_type', **pattern)
|
||||||
|
|
||||||
|
|
||||||
class PartyNcfType(ModelSQL, ValueMixin):
|
class PartyNcfType(ModelSQL, CompanyValueMixin):
|
||||||
"Party Ncf Type"
|
"Party Ncf Type"
|
||||||
__name__ = 'party.party.ncf_type'
|
__name__ = 'party.party.ncf_type'
|
||||||
|
|
||||||
party = fields.Many2One(
|
party = fields.Many2One(
|
||||||
'party.party', "Party", ondelete='CASCADE')
|
'party.party', "Party", ondelete='CASCADE',
|
||||||
|
context={
|
||||||
|
'company': Eval('company', -1),
|
||||||
|
},
|
||||||
|
depends={'company'})
|
||||||
customer_ncf_type = customer_ncf_type
|
customer_ncf_type = customer_ncf_type
|
||||||
supplier_ncf_type = supplier_ncf_type
|
supplier_ncf_type = supplier_ncf_type
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from trytond.modules.ncf_manager.sequence import Sequence
|
|||||||
from trytond.modules.ncf_manager.importer import (
|
from trytond.modules.ncf_manager.importer import (
|
||||||
normalize_dgii_row, parse_dgii_authorizations)
|
normalize_dgii_row, parse_dgii_authorizations)
|
||||||
from trytond.modules.ncf_manager.invoice import Invoice
|
from trytond.modules.ncf_manager.invoice import Invoice
|
||||||
|
from trytond.modules.ncf_manager.party import Party, PartyNcfType
|
||||||
|
|
||||||
|
|
||||||
class NcfManagerUnitTestCase(unittest.TestCase):
|
class NcfManagerUnitTestCase(unittest.TestCase):
|
||||||
@@ -73,6 +74,13 @@ class NcfManagerUnitTestCase(unittest.TestCase):
|
|||||||
self.assertIn('template.type == product_type', source)
|
self.assertIn('template.type == product_type', source)
|
||||||
self.assertIn("line.type == 'line'", source)
|
self.assertIn("line.type == 'line'", source)
|
||||||
|
|
||||||
|
def test_party_ncf_type_is_stored_per_party_and_company(self):
|
||||||
|
self.assertIn('ncf_types', Party._fields)
|
||||||
|
self.assertEqual(
|
||||||
|
Party._fields['ncf_types'].model_name, 'party.party.ncf_type')
|
||||||
|
self.assertIn('party', PartyNcfType._fields)
|
||||||
|
self.assertIn('company', PartyNcfType._fields)
|
||||||
|
|
||||||
def test_csv_parser_preserves_unquoted_detail(self):
|
def test_csv_parser_preserves_unquoted_detail(self):
|
||||||
source_format, rows = parse_dgii_authorizations(
|
source_format, rows = parse_dgii_authorizations(
|
||||||
f'{self.HEADERS}\r\n{self.ROW}\r\n'.encode())
|
f'{self.HEADERS}\r\n{self.ROW}\r\n'.encode())
|
||||||
|
|||||||
Reference in New Issue
Block a user