[FIX] l10n_cl: manage document type for generic demo data

Part of task 2124952

Amend the demo data to populate required fields added in dependencies of
l10n_cl.

The field l10n_latam_document_number is not required if the journal is
not using Latam invoice documents.
This commit is contained in:
wan
2021-02-17 08:39:29 +00:00
parent de0c5f4b8c
commit da4f2b8966
4 changed files with 49 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import demo
+3
View File
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_demo
+42
View File
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
import logging
from odoo import api, models
_logger = logging.getLogger(__name__)
class AccountChartTemplate(models.Model):
_inherit = "account.chart.template"
@api.model
def _get_demo_data(self):
yield ('res.partner', {
'base.res_partner_12': {
'l10n_cl_sii_taxpayer_type': '4',
},
'base.res_partner_2': {
'l10n_cl_sii_taxpayer_type': '4',
},
})
yield ('l10n_latam.document.type', {
'l10n_cl.dc_fe_dte': {'active': True},
})
for model, data in super()._get_demo_data():
yield model, data
@api.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
return model, data
@@ -45,7 +45,9 @@
attrs="{'invisible': [('l10n_latam_use_documents', '=', False)], 'required': [('l10n_latam_use_documents', '=', True)], 'readonly': [('posted_before', '=', True)]}"
domain="[('id', 'in', l10n_latam_available_document_type_ids)]" options="{'no_open': True, 'no_create': True}"/>
<field name="l10n_latam_document_number"
attrs="{'invisible': ['|', ('l10n_latam_use_documents', '=', False), ('l10n_latam_manual_document_number', '=', False), '|', '|', ('l10n_latam_use_documents', '=', False), ('highest_name', '!=', False), ('state', '!=', 'draft')], 'required': ['|', ('l10n_latam_manual_document_number', '=', True), ('highest_name', '=', False)], 'readonly': [('posted_before', '=', True), ('state', '!=', 'draft')]}"/>
attrs="{'invisible': ['|', ('l10n_latam_use_documents', '=', False), ('l10n_latam_manual_document_number', '=', False), '|', '|', ('l10n_latam_use_documents', '=', False), ('highest_name', '!=', False), ('state', '!=', 'draft')],
'required': [('l10n_latam_use_documents', '=', True), '|', ('l10n_latam_manual_document_number', '=', True), ('highest_name', '=', False)],
'readonly': [('posted_before', '=', True), ('state', '!=', 'draft')]}"/>
</xpath>
<!-- on latam_documents we use document_number to set name -->