Skip to content

Commit

Permalink
[IMP] add obliged subject checkbox on partner
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h committed Dec 18, 2019
1 parent 95167a4 commit 04353bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion l10n_it_fatturapa/__manifest__.py
@@ -1,6 +1,6 @@
# Copyright 2014 Davide Corio <davide.corio@abstract.it>
# Copyright 2015-2016 Lorenzo Battistini - Agile Business Group
# Copyright 2018 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
# Copyright 2018-2019 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
# Copyright 2019 Gianluigi Tiesi - Netfarm S.r.l.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

Expand Down
15 changes: 15 additions & 0 deletions l10n_it_fatturapa/models/partner.py
@@ -1,4 +1,5 @@
# Copyright 2014 Davide Corio <davide.corio@abstract.it>
# Copyright 2019 Sergio Zanchetta <https://github.com/primes2h>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models, api, _
Expand Down Expand Up @@ -45,6 +46,8 @@ class ResPartner(models.Model):
)
electronic_invoice_subjected = fields.Boolean(
"Enable electronic invoicing")
electronic_invoice_obliged_subject = fields.Boolean(
"Obliged Subject")
electronic_invoice_data_complete = fields.Boolean(
compute="_compute_electronic_invoice_data_complete")

Expand Down Expand Up @@ -149,3 +152,15 @@ def onchange_country_id_e_inv(self):
self.codice_destinatario = STANDARD_ADDRESSEE_CODE
else:
self.codice_destinatario = 'XXXXXXX'

@api.onchange('electronic_invoice_subjected')
def onchange_electronic_invoice_subjected(self):
if not self.electronic_invoice_subjected:
self.electronic_invoice_obliged_subject = False

@api.onchange('electronic_invoice_obliged_subject')
def onchange_e_inv_obliged_subject(self):
if not self.electronic_invoice_obliged_subject:
self.onchange_country_id_e_inv()
self.pec_destinatario = ''
self.eori_code = ''
11 changes: 6 additions & 5 deletions l10n_it_fatturapa/views/partner_view.xml
Expand Up @@ -11,17 +11,18 @@
<group name="fatturapa_group">
<label for="electronic_invoice_no_contact_update" attrs="{'invisible': [('supplier', '=', False)]}"/>
<field name="electronic_invoice_no_contact_update" attrs="{'invisible': [('supplier', '=', False)]}"/>
<label for="electronic_invoice_subjected"/>
<field name="electronic_invoice_subjected"/>

<group attrs="{'invisible': [('electronic_invoice_subjected', '=', False)]}">
<group>
<field name="electronic_invoice_subjected"/>
<field name="electronic_invoice_obliged_subject" attrs="{'invisible': [('electronic_invoice_subjected', '=', False)]}"/>
</group>
<group attrs="{'invisible': ['|',('electronic_invoice_subjected', '=', False), ('electronic_invoice_obliged_subject', '=', False)]}">
<field name="ipa_code" placeholder="IPA123" attrs="{'invisible': [('is_pa','=', False)]}"/>
<field name="codice_destinatario" attrs="{'invisible': [('is_pa', '=', True)]}"/>
<field name="pec_destinatario"
attrs="{'invisible': ['|',('is_pa', '=', True), ('codice_destinatario', '!=', '0000000')]}"/>
<field name="eori_code"/>
</group>
</group>
</group>
</page>
</notebook>
</field>
Expand Down

0 comments on commit 04353bc

Please sign in to comment.