[FIX] l10n_fr_fec: prevent error for non-french vat
As the FEC can be downloaded by non-french companies, the length of a given vat number might be different than the french's vat. Currently, if the vat length was lower than 13, it raised an error. For french companies -> include the SIREN in the name of the FEC file (legal requirement) For non french companies -> include the complete vat number in the FEC file closes odoo/odoo#83054 X-original-commit: c3c05bf073a521a662d83c3382e77cb25c59bc3c Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
@@ -238,6 +238,16 @@ msgstr ""
|
||||
msgid "Non-official FEC report (posted and unposted entries)"
|
||||
msgstr "Rapport FEC non-officiel (avec à la fois les entrées comptabilisées et non comptabilisées)"
|
||||
|
||||
#: code:addons/l10n_fr_fec/wizard/fec.py:98
|
||||
#, python-format
|
||||
msgid "Invalid VAT number for company %s"
|
||||
msgstr "Numéro de TVA invalide sur la société %s"
|
||||
|
||||
#. module: l10n_fr_fec
|
||||
#: view:account.fr.fec:0
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#. module: l10n_fr_fec
|
||||
#: model:ir.model.fields.selection,name:l10n_fr_fec.selection__account_fr_fec__export_type__official
|
||||
msgid "Official FEC report (posted entries only)"
|
||||
|
||||
@@ -228,6 +228,12 @@ msgstr ""
|
||||
msgid "Missing VAT number for company %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: l10n_fr_fec
|
||||
#: code:addons/l10n_fr_fec/wizard/account_fr_fec.py:98
|
||||
#, python-format
|
||||
msgid "Invalid VAT number for company %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: l10n_fr_fec
|
||||
#: model_terms:ir.ui.view,arch_db:l10n_fr_fec.account_fr_fec_view
|
||||
msgid "Montantdevise"
|
||||
|
||||
@@ -10,6 +10,7 @@ from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError, AccessDenied
|
||||
from odoo.tools import float_is_zero, pycompat
|
||||
from odoo.tools.misc import get_lang
|
||||
from stdnum.fr import siren
|
||||
|
||||
|
||||
class AccountFrFec(models.TransientModel):
|
||||
@@ -89,13 +90,24 @@ class AccountFrFec(models.TransientModel):
|
||||
sources:
|
||||
https://www.service-public.fr/professionnels-entreprises/vosdroits/F23570
|
||||
http://www.douane.gouv.fr/articles/a11024-tva-dans-les-dom
|
||||
|
||||
* Returns the siren if the company is french or an empty siren for dom-tom
|
||||
* For non-french companies -> returns the complete vat number
|
||||
"""
|
||||
dom_tom_group = self.env.ref('l10n_fr.dom-tom')
|
||||
is_dom_tom = company.account_fiscal_country_id.code in dom_tom_group.country_ids.mapped('code')
|
||||
if not company.vat or is_dom_tom:
|
||||
return {'siren': ''}
|
||||
if is_dom_tom:
|
||||
return ''
|
||||
elif company.country_id.code == 'FR':
|
||||
if not company.vat:
|
||||
raise UserError(_("Missing VAT number for company %s") % company.display_name)
|
||||
elif len(company.vat) < 13 or not siren.is_valid(company.vat[4:13]):
|
||||
raise UserError(_("Invalid VAT number for company %s") % company.display_name)
|
||||
else:
|
||||
return company.vat[4:13]
|
||||
else:
|
||||
return {'siren': company.vat[4:13]}
|
||||
return '' if not company.vat else company.vat
|
||||
|
||||
|
||||
def generate_fec(self):
|
||||
self.ensure_one()
|
||||
@@ -383,7 +395,7 @@ class AccountFrFec(models.TransientModel):
|
||||
self.write({
|
||||
'fec_data': base64.encodebytes(fecvalue),
|
||||
# Filename = <siren>FECYYYYMMDD where YYYMMDD is the closing date
|
||||
'filename': '%sFEC%s%s.csv' % (company_legal_data['siren'], end_date, suffix),
|
||||
'filename': '%sFEC%s%s.csv' % (company_legal_data, end_date, suffix),
|
||||
})
|
||||
|
||||
# Set fiscal year lock date to the end date (not in test)
|
||||
|
||||
Reference in New Issue
Block a user