[FIX] l10n_ar, l10n_cl, l10n_pe, l10n_ec: only change invoice demo data when the company has the right country

Before when you installed one localization e.g. PE, but then you would
install another one with a demo company, then that demo company's demo invoices
might have adapted to the structure of PE, while it might be for another
country.

In the meantime we check that the necessary latam_document_numbers are set.

closes odoo/odoo#82998

X-original-commit: bef38eaee0e389554d35fede53a1224b72271d7f
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
Josse Colpaert
2022-01-18 16:17:43 +00:00
parent a2dcdf35cb
commit 6789b8f977
4 changed files with 27 additions and 22 deletions
+3 -2
View File
@@ -37,6 +37,7 @@ class AccountChartTemplate(models.Model):
def _get_demo_data_move(self):
cid = self.env.company.id
model, data = super()._get_demo_data_move()
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = '1-1'
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = '1-2'
if self.env.company.country_code == "AR":
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = '1-1'
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = '1-2'
return model, data
+10 -9
View File
@@ -29,14 +29,15 @@ class AccountChartTemplate(models.Model):
def _get_demo_data_move(self):
ref = self.env.ref
cid = self.env.company.id
foreign = ref('l10n_cl.dc_fe_dte').id
model, data = super()._get_demo_data_move()
self.env['account.journal'].search([
('type', '=', 'purchase'),
('company_id', '=', self.env.company.id),
]).l10n_latam_use_documents = False
data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_type_id'] = foreign
if self.env.company.country_code == "CL":
foreign = ref('l10n_cl.dc_fe_dte').id
self.env['account.journal'].search([
('type', '=', 'purchase'),
('company_id', '=', self.env.company.id),
]).l10n_latam_use_documents = False
data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = foreign
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_type_id'] = foreign
return model, data
+2
View File
@@ -20,4 +20,6 @@ class AccountChartTemplate(models.Model):
data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = document_type
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = document_type
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_type_id'] = document_type
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = '001-001-00001'
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = '001-001-00002'
return model, data
+12 -11
View File
@@ -10,15 +10,16 @@ class AccountChartTemplate(models.Model):
def _get_demo_data_move(self):
cid = self.env.company.id
model, data = super()._get_demo_data_move()
document_type = self.env.ref('l10n_pe.document_type01')
data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_1']['l10n_latam_document_number'] = 'FFI-000001'
data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_2']['l10n_latam_document_number'] = 'FFI-000002'
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_3']['l10n_latam_document_number'] = 'FFI-000003'
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_number'] = 'FFI-000004'
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = '1'
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = 'INV-000089'
if self.env.company.country_code == "PE":
document_type = self.env.ref('l10n_pe.document_type01')
data[f'{cid}_demo_invoice_1']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_1']['l10n_latam_document_number'] = 'FFI-000001'
data[f'{cid}_demo_invoice_2']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_2']['l10n_latam_document_number'] = 'FFI-000002'
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_3']['l10n_latam_document_number'] = 'FFI-000003'
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_type_id'] = document_type.id
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_number'] = 'FFI-000004'
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = '1'
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = 'INV-000089'
return model, data