Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
216e4358 by Cédric Krier at 2023-06-27T15:00:59+02:00
Limit type to tax identifier for party tax identifier of invoice

Closes #12356
- - - - -
eb60c91d by Cédric Krier at 2023-06-27T15:06:34+02:00
Simplify tax identifier types of invoice

We do not need to be able to customize it for only the invoice so it can be
customized on party.
- - - - -


1 changed file:

- modules/account_invoice/invoice.py


Changes:

=====================================
modules/account_invoice/invoice.py
=====================================
@@ -115,10 +115,7 @@
         depends={'company'})
     party_tax_identifier = fields.Many2One(
         'party.identifier', "Party Tax Identifier", ondelete='RESTRICT',
-        states=_states,
-        domain=[
-            ('party', '=', Eval('party', -1)),
-            ])
+        states=_states)
     party_lang = fields.Function(fields.Char('Party Language'),
         'on_change_with_party_lang')
     invoice_address = fields.Many2One('party.address', 'Invoice Address',
@@ -301,6 +298,8 @@
 
     @classmethod
     def __setup__(cls):
+        pool = Pool()
+        Party = pool.get('party.party')
         cls.number.search_unaccented = False
         cls.reference.search_unaccented = False
         super(Invoice, cls).__setup__()
@@ -345,5 +344,6 @@
                 ('type', 'in', cls._journal_types('out')),
                 ('type', 'in', cls._journal_types('in'))),
             ]
+        tax_identifier_types = Party.tax_identifier_types()
         cls.tax_identifier.domain = [
             ('party', '=', Eval('company_party', -1)),
@@ -348,6 +348,10 @@
         cls.tax_identifier.domain = [
             ('party', '=', Eval('company_party', -1)),
-            ('type', 'in', cls.tax_identifier_types()),
+            ('type', 'in', tax_identifier_types),
+            ]
+        cls.party_tax_identifier.domain = [
+            ('party', '=', Eval('party', -1)),
+            ('type', 'in', tax_identifier_types),
             ]
         cls._transitions |= set((
                 ('draft', 'validated'),
@@ -1233,9 +1237,5 @@
             field += '_invoice'
         return field + '_sequence'
 
-    @classmethod
-    def tax_identifier_types(cls):
-        return Pool().get('party.party').tax_identifier_types()
-
     def get_tax_identifier(self):
         "Return the default computed tax identifier"
@@ -1240,9 +1240,6 @@
     def get_tax_identifier(self):
         "Return the default computed tax identifier"
-        types = self.tax_identifier_types()
-        for identifier in self.company.party.identifiers:
-            if identifier.type in types:
-                return identifier.id
+        return self.company.party.tax_identifier
 
     @property
     def is_modifiable(self):



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/a379ef0e1567383579001994c4c11f9cd711ad62...eb60c91d20d89f07b040558ff27f42fc1319c23d

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/compare/a379ef0e1567383579001994c4c11f9cd711ad62...eb60c91d20d89f07b040558ff27f42fc1319c23d
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to