Use party identifier to store SIREN and SIRET

issue5834
review397071002
This commit is contained in:
Cédric Krier
2022-02-13 00:43:49 +01:00
parent c9449ec5ad
commit 018484d0d7
10 changed files with 106 additions and 25 deletions
+2
View File
@@ -1,3 +1,5 @@
* Add fr_siren and fr_siret identifiers
* Add optional address to identifiers
* Add autonomous city as subdivision type for Spain
* Add support for Python 3.10
* Remove support for Python 3.6
+7
View File
@@ -58,6 +58,13 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
depends=['country', 'subdivision_types'])
full_address = fields.Function(fields.Text('Full Address'),
'get_full_address')
identifiers = fields.One2Many(
'party.identifier', 'address', "Identifiers",
domain=[
('party', '=', Eval('party')),
('type', 'in', ['fr_siret']),
],
depends=['party'])
@classmethod
def __setup__(cls):
+7
View File
@@ -22,6 +22,13 @@ this repository contains the full copyright notices and license terms. -->
<field name="type">form</field>
<field name="name">address_form</field>
</record>
<record model="ir.ui.view" id="address_view_form_simple">
<field name="model">party.address</field>
<field name="type">form</field>
<field name="name">address_form_simple</field>
</record>
<record model="ir.action.act_window" id="act_address_form">
<field name="name">Addresses</field>
<field name="res_model">party.address</field>
+23 -2
View File
@@ -457,8 +457,8 @@ IDENTIFIER_TYPES = [
('fi_ytunnus', "Finnish Business Identifier"),
('fr_nif', "French Tax Identification Number"),
('fr_nir', "French Personal Identification Number"),
# TODO: remove from party_siren
# ('fr_siren', "French Company Identification Number"),
('fr_siren', "French Company Identification Number"),
('fr_siret', "French Company Establishment Identification Number"),
('fr_tva', "French VAT Number"),
('gb_nhs',
"United Kingdom National Health Service Patient Identifier"),
@@ -618,8 +618,21 @@ class Identifier(sequence_ordered(), DeactivableMixin, ModelSQL, ModelView):
party = fields.Many2One('party.party', 'Party', ondelete='CASCADE',
required=True, select=True,
help="The party identified by this record.")
address = fields.Many2One(
'party.address', "Address", ondelete='CASCADE', select=True,
states={
'required': Eval('type_address', False),
'invisible': ~Eval('type_address', True),
},
domain=[
('party', '=', Eval('party', -1)),
],
depends=['party', 'type_address'],
help="The address identified by this record.")
type = fields.Selection('get_types', 'Type')
type_string = type.translated('type')
type_address = fields.Function(
fields.Boolean("Type of Address"), 'on_change_with_type_address')
code = fields.Char('Code', required=True)
@classmethod
@@ -667,6 +680,14 @@ class Identifier(sequence_ordered(), DeactivableMixin, ModelSQL, ModelView):
configuration = Configuration(1)
return [(None, '')] + configuration.get_identifier_types()
@classmethod
def _type_addresses(cls):
return {'fr_siret'}
@fields.depends('type')
def on_change_with_type_address(self, name=None):
return self.type in self._type_addresses()
@fields.depends('type', 'code')
def on_change_with_code(self):
if self.type and '_' in self.type:
+22 -16
View File
@@ -14,20 +14,26 @@ this repository contains the full copyright notices and license terms. -->
<label name="sequence"/>
<field name="sequence"/>
</group>
<newline/>
<label name="name"/>
<field name="name"/>
<newline/>
<label name="street"/>
<field name="street" colspan="3"/>
<newline/>
<label name="postal_code"/>
<field name="postal_code"/>
<label name="city"/>
<field name="city"/>
<newline/>
<label name="country"/>
<field name="country" widget="selection"/>
<label name="subdivision"/>
<field name="subdivision" widget="selection"/>
<notebook colspan="6">
<page string="General" id="general">
<label name="name"/>
<field name="name"/>
<newline/>
<label name="street"/>
<field name="street" colspan="3"/>
<newline/>
<label name="postal_code"/>
<field name="postal_code"/>
<label name="city"/>
<field name="city"/>
<newline/>
<label name="country"/>
<field name="country" widget="selection"/>
<label name="subdivision"/>
<field name="subdivision" widget="selection"/>
</page>
<page name="identifiers">
<field name="identifiers" colspan="4" pre_validate="1" view_ids="party.identifier_list_sequence"/>
</page>
</notebook>
</form>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="party"/>
<field name="party" colspan="5"/>
<label name="party_name"/>
<field name="party_name"/>
<group colspan="2" col="-1" id="checkboxes">
<label name="active"/>
<field name="active"
xexpand="0" width="25"/>
<!-- Add here some checkboxes ! -->
<label name="sequence"/>
<field name="sequence"/>
</group>
<newline/>
<label name="name"/>
<field name="name"/>
<newline/>
<label name="street"/>
<field name="street" colspan="3"/>
<newline/>
<label name="postal_code"/>
<field name="postal_code"/>
<label name="city"/>
<field name="city"/>
<newline/>
<label name="country"/>
<field name="country" widget="selection"/>
<label name="subdivision"/>
<field name="subdivision" widget="selection"/>
</form>
+3
View File
@@ -14,4 +14,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="type"/>
<label name="code"/>
<field name="code"/>
<label name="address"/>
<field name="address"/>
</form>
+4 -3
View File
@@ -2,7 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="party"/>
<field name="type"/>
<field name="code" expand="1"/>
<field name="party" expand="1"/>
<field name="address" expand="1"/>
<field name="type" expand="1"/>
<field name="code" expand="2"/>
</tree>
+4 -3
View File
@@ -2,7 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree sequence="sequence">
<field name="party"/>
<field name="type"/>
<field name="code" expand="1"/>
<field name="party" expand="1"/>
<field name="address" expand="1"/>
<field name="type" expand="1"/>
<field name="code" expand="2"/>
</tree>
+1 -1
View File
@@ -18,7 +18,7 @@ this repository contains the full copyright notices and license terms. -->
<notebook colspan="6">
<page string="General" id="general">
<field name="addresses" mode="form,tree" colspan="4"
view_ids="party.address_view_form,party.address_view_tree_sequence"/>
view_ids="party.address_view_form_simple,party.address_view_tree_sequence"/>
<group col="2" colspan="4" id="lang">
<label name="lang"/>
<field name="lang" widget="selection" xexpand="0"/>