[FIX] l10n_it_edi: Share Capital and Sole Shareholder not mandatory

If the business is incorporated, both these fields must be present.
We don't have a field to know whether the business is incorporated,
but in any case the fields must be both present or not present.

opw-3127832

closes odoo/odoo#112366

X-original-commit: b3de98d4dd248f56461f735a6cae143296a96a0a
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Paolo Gatti (pgi) <pgi@odoo.com>
This commit is contained in:
Paolo Gatti (pgi)
2023-02-10 11:23:05 +01:00
parent 423747ef4a
commit 563a2b320c
+17 -9
View File
@@ -73,20 +73,28 @@ class ResCompany(models.Model):
@api.constrains('l10n_it_has_eco_index',
'l10n_it_eco_index_office',
'l10n_it_eco_index_number',
'l10n_it_eco_index_share_capital',
'l10n_it_eco_index_sole_shareholder',
'l10n_it_eco_index_liquidation_state')
def _check_eco_admin_index(self):
for record in self:
if not record.l10n_it_has_eco_index:
continue
if not record.l10n_it_eco_index_office\
or not record.l10n_it_eco_index_number\
or not record.l10n_it_eco_index_share_capital\
or not record.l10n_it_eco_index_sole_shareholder\
or not record.l10n_it_eco_index_liquidation_state:
if (record.l10n_it_has_eco_index
and (not record.l10n_it_eco_index_office
or not record.l10n_it_eco_index_number
or not record.l10n_it_eco_index_liquidation_state)):
raise ValidationError(_("All fields about the Economic and Administrative Index must be completed."))
@api.constrains('l10n_it_has_eco_index',
'l10n_it_eco_index_share_capital',
'l10n_it_eco_index_sole_shareholder')
def _check_eco_incorporated(self):
""" If the business is incorporated, both these fields must be present.
We don't know whether the business is incorporated, but in any case the fields
must be both present or not present. """
for record in self:
if (record.l10n_it_has_eco_index
and bool(record.l10n_it_eco_index_share_capital) ^ bool(record.l10n_it_eco_index_sole_shareholder)):
raise ValidationError(_("If one of Share Capital or Sole Shareholder is present, "
"then they must be both filled out."))
@api.constrains('l10n_it_has_tax_representative',
'l10n_it_tax_representative_partner_id')
def _check_tax_representative(self):