[ADD] l10n_cl: forward to 14.0
closes odoo/odoo#58889 X-original-commit: faea1fec6b0a8571e5f61c1a891cfa708b0a9075 Related: odoo/enterprise#13721 Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
@@ -19,7 +19,6 @@ Plan contable chileno e impuestos de acuerdo a disposiciones vigentes
|
||||
'uom',
|
||||
],
|
||||
'data': [
|
||||
'views/account_journal_view.xml',
|
||||
'views/account_move_view.xml',
|
||||
'views/account_tax_view.xml',
|
||||
'views/ir_sequence_view.xml',
|
||||
|
||||
@@ -445,11 +445,6 @@ msgstr "Comercial"
|
||||
msgid "Sequence"
|
||||
msgstr "Secuencia"
|
||||
|
||||
#. module: l10n_cl
|
||||
#: model:ir.model.fields,field_description:l10n_cl.field_account_journal__l10n_cl_sequence_ids
|
||||
msgid "Sequences (cl)"
|
||||
msgstr "Secuencias (CL)"
|
||||
|
||||
#. module: l10n_cl
|
||||
#: model:ir.model.fields,field_description:l10n_cl.field_res_currency__l10n_cl_short_name
|
||||
msgid "Short Name"
|
||||
|
||||
@@ -429,11 +429,6 @@ msgstr ""
|
||||
msgid "Sequence"
|
||||
msgstr ""
|
||||
|
||||
#. module: l10n_cl
|
||||
#: model:ir.model.fields,field_description:l10n_cl.field_account_journal__l10n_cl_sequence_ids
|
||||
msgid "Sequences (cl)"
|
||||
msgstr ""
|
||||
|
||||
#. module: l10n_cl
|
||||
#: model:ir.model.fields,field_description:l10n_cl.field_res_currency__l10n_cl_short_name
|
||||
msgid "Short Name"
|
||||
|
||||
@@ -8,32 +8,4 @@ class AccountJournal(models.Model):
|
||||
|
||||
l10n_cl_sequence_ids = fields.Many2many(
|
||||
'ir.sequence', 'l10n_cl_journal_sequence_rel', 'journal_id', 'sequence_id', string='Sequences (cl)',
|
||||
domain="[('l10n_latam_document_type_id', '!=', False)]")
|
||||
|
||||
def button_create_new_sequences(self):
|
||||
self.ensure_one()
|
||||
internal_types = ['invoice', 'debit_note', 'credit_note']
|
||||
domain = [('country_id.code', '=', 'CL'), ('internal_type', 'in', internal_types)]
|
||||
if self.company_id.partner_id.l10n_cl_sii_taxpayer_type in ['1', False]:
|
||||
domain += [('code', 'not in', ['70', '71'])]
|
||||
elif self.company_id.partner_id.l10n_cl_sii_taxpayer_type == '2':
|
||||
domain += [('code', 'not in', ['33', '34'])]
|
||||
documents = self.env['l10n_latam.document.type'].search(domain)
|
||||
sequences = self.env['ir.sequence']
|
||||
for document in documents:
|
||||
sequences |= self.env['ir.sequence'].create(document._get_document_sequence_vals(self))
|
||||
self.write({'l10n_cl_sequence_ids': [(4, s.id) for s in sequences]})
|
||||
|
||||
def create_document_sequences_cl(self):
|
||||
self.ensure_one()
|
||||
if (self.company_id.country_id != self.env.ref('base.cl')) or self.env['ir.sequence'].search(
|
||||
[('l10n_latam_document_type_id', '!=', False)]) or self.type != 'sale' or not self.l10n_latam_use_documents:
|
||||
return
|
||||
self.button_create_new_sequences()
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
""" Create Document sequences after create the journal """
|
||||
res = super().create(values)
|
||||
res.create_document_sequences_cl()
|
||||
return res
|
||||
domain="[('l10n_latam_document_type_id', '!=', False)]")
|
||||
@@ -4,6 +4,8 @@ from odoo.exceptions import ValidationError
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.osv import expression
|
||||
|
||||
SII_VAT = '60805000-0'
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
@@ -19,16 +21,19 @@ class AccountMove(models.Model):
|
||||
if (self.journal_id.l10n_latam_use_documents and
|
||||
self.journal_id.company_id.country_id == self.env.ref('base.cl')):
|
||||
if self.journal_id.type == 'sale':
|
||||
document_type_ids = self.journal_id.l10n_cl_sequence_ids.mapped('l10n_latam_document_type_id').ids
|
||||
domain = [('country_id', '=', self.env.ref('base.cl').id), ('internal_type', '!=', 'invoice_in')]
|
||||
if self.company_id.partner_id.l10n_cl_sii_taxpayer_type == '1':
|
||||
domain += [('code', '!=', '71')] # Companies with VAT Affected doesn't have "Boleta de honorarios Electrónica"
|
||||
document_type_ids = self.env['l10n_latam.document.type'].search(domain).ids
|
||||
else:
|
||||
partner_domain = [
|
||||
('country_id.code', '=', 'CL'),
|
||||
('internal_type', 'in', ['invoice', 'debit_note', 'credit_note', 'invoice_in'])]
|
||||
if not self.partner_id:
|
||||
pass
|
||||
elif self.partner_id.l10n_cl_sii_taxpayer_type == '1' and self.partner_id_vat != '60805000-0':
|
||||
elif self.partner_id.l10n_cl_sii_taxpayer_type == '1' and self.partner_id_vat != SII_VAT:
|
||||
partner_domain += [('code', 'not in', ['39', '70', '71', '914', '911'])]
|
||||
elif self.partner_id.l10n_cl_sii_taxpayer_type == '1' and self.partner_id_vat == '60805000-0':
|
||||
elif self.partner_id.l10n_cl_sii_taxpayer_type == '1' and self.partner_id_vat == SII_VAT:
|
||||
partner_domain += [('code', 'not in', ['39', '70', '71'])]
|
||||
elif self.partner_id.l10n_cl_sii_taxpayer_type == '2':
|
||||
partner_domain += [('code', 'in', ['70', '71', '56', '61'])]
|
||||
@@ -61,7 +66,7 @@ class AccountMove(models.Model):
|
||||
'Document types for foreign customers must be export type (codes 110, 111 or 112) or you \
|
||||
should define the customer as an end consumer and use receipts (codes 39 or 41)'))
|
||||
if rec.journal_id.type == 'purchase' and rec.journal_id.l10n_latam_use_documents:
|
||||
if vat != '60805000-0' and latam_document_type_code == '914':
|
||||
if vat != SII_VAT and latam_document_type_code == '914':
|
||||
raise ValidationError(_('The DIN document is intended to be used only with RUT 60805000-0'
|
||||
' (Tesorería General de La República)'))
|
||||
if not tax_payer_type or not vat:
|
||||
@@ -96,11 +101,11 @@ class AccountMove(models.Model):
|
||||
super()._post(soft)
|
||||
|
||||
def _l10n_cl_get_formatted_sequence(self, number=0):
|
||||
return "%s %06d" % (self.l10n_latam_document_type_id.doc_code_prefix, number)
|
||||
return '%s %06d' % (self.l10n_latam_document_type_id.doc_code_prefix, number)
|
||||
|
||||
def _get_starting_sequence(self):
|
||||
""" If use documents then will create a new starting sequence using the document type code prefix and the
|
||||
journal document number with a 8 padding number """
|
||||
journal document number with a 6 padding number """
|
||||
if self.journal_id.l10n_latam_use_documents and self.env.company.country_id == self.env.ref('base.cl'):
|
||||
if self.l10n_latam_document_type_id:
|
||||
return self._l10n_cl_get_formatted_sequence()
|
||||
@@ -109,11 +114,10 @@ class AccountMove(models.Model):
|
||||
def _get_last_sequence_domain(self, relaxed=False):
|
||||
where_string, param = super(AccountMove, self)._get_last_sequence_domain(relaxed)
|
||||
if self.company_id.country_id == self.env.ref('base.cl') and self.l10n_latam_use_documents:
|
||||
journals = self.journal_id.l10n_cl_sequence_ids.filtered(lambda s: s.l10n_latam_document_type_id == self.l10n_latam_document_type_id).l10n_cl_journal_ids.ids
|
||||
if len(journals) > 1:
|
||||
where_string.replace("journal_id = %(journal_ids)s", "journal_id in %(journal_ids)s")
|
||||
param['journal_ids'] = journals
|
||||
where_string += " AND l10n_latam_document_type_id = %(l10n_latam_document_type_id)s "
|
||||
where_string = where_string.replace('journal_id = %(journal_id)s AND', '')
|
||||
where_string += ' AND l10n_latam_document_type_id = %(l10n_latam_document_type_id)s AND ' \
|
||||
'company_id = %(company_id)s'
|
||||
param['company_id'] = self.company_id.id or False
|
||||
param['l10n_latam_document_type_id'] = self.l10n_latam_document_type_id.id or 0
|
||||
return where_string, param
|
||||
|
||||
|
||||
@@ -15,15 +15,16 @@ class L10nLatamDocumentType(models.Model):
|
||||
('credit_note', 'Credit Notes'),
|
||||
('receipt_invoice', 'Receipt Invoice')])
|
||||
|
||||
def _get_document_sequence_vals(self, journal):
|
||||
values = {}
|
||||
def _format_document_number(self, document_number):
|
||||
""" Make validation of Import Dispatch Number
|
||||
* making validations on the document_number. If it is wrong it should raise an exception
|
||||
* format the document_number against a pattern and return it
|
||||
"""
|
||||
self.ensure_one()
|
||||
if self.country_id != self.env.ref('base.cl'):
|
||||
return values
|
||||
values.update({
|
||||
'name': '%s - %s' % (journal.name, self.name),
|
||||
'padding': 6,
|
||||
'implementation': 'no_gap',
|
||||
'l10n_latam_document_type_id': self.id,
|
||||
'prefix': None
|
||||
})
|
||||
return values
|
||||
return super()._format_document_number(document_number)
|
||||
|
||||
if not document_number:
|
||||
return False
|
||||
|
||||
return document_number.zfill(6)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_account_journal_form_inherit_l10n_cl" model="ir.ui.view">
|
||||
<field name="model">account.journal</field>
|
||||
<field name="name">account.journal.form.inherit.cl</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='code']/.." position="inside">
|
||||
<button name="button_create_new_sequences" type="object" string="Create New Sequences"
|
||||
attrs="{'invisible': ['|', '|', '|', ('l10n_cl_sequence_ids', '!=', []), ('l10n_latam_use_documents', '=', False), ('type', '=', 'purchase'), ('country_code', '!=', 'CL')]}"
|
||||
class="btn btn-primary"/>
|
||||
<field name="l10n_cl_sequence_ids" nolabel="1" colspan="2"
|
||||
attrs="{'invisible': ['|', '|', ('l10n_latam_use_documents', '=', False), ('country_code', '!=', 'CL'), ('type', '=', 'purchase')]}">
|
||||
<tree default_order="id">
|
||||
<field name="name" readonly="True" string="Sequence"/>
|
||||
<field name="number_next_actual" string="Next Number"/>
|
||||
<field name="id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="l10n_cl_latam_document_type_view" model="ir.ui.view">
|
||||
<field name="name">l10n.cl.latam.document.type.view</field>
|
||||
<field name="model">l10n_latam.document.type</field>
|
||||
<field name="inherit_id" ref="l10n_latam_invoice_document.view_document_type_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="sequence" position="attributes">
|
||||
<attribute name="widget">handle</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,27 +1,150 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- this header can be used on any Chilean report -->
|
||||
<template id="custom_header">
|
||||
|
||||
<t t-set="report_date" t-value="o.invoice_date"/>
|
||||
<t t-set="report_number" t-value="int(o.l10n_latam_document_number)"/>
|
||||
<t t-set="pre_printed_report" t-value="report_type == 'pdf'"/>
|
||||
<t t-set="report_name" t-value="o.l10n_latam_document_type_id.name"/>
|
||||
<t t-set="header_address" t-value="o.company_id.partner_id"/>
|
||||
<t t-set="is_tax" t-value="o.l10n_latam_document_type_id.code not in ['39', '41', '110', '111', '112', '34']"/>
|
||||
<t t-set="custom_footer">
|
||||
<t t-call="l10n_cl.custom_footer"/>
|
||||
</t>
|
||||
|
||||
<div>
|
||||
<div class="row">
|
||||
<div name="left-upper-side" class="col-8">
|
||||
<img t-if="o.company_id.logo" t-att-src="image_data_uri(o.company_id.logo)"
|
||||
style="max-height: 45px;" alt="Logo"/>
|
||||
<br/>
|
||||
<strong>
|
||||
<span t-field="o.company_id.partner_id.name"/>
|
||||
</strong>
|
||||
<br/>
|
||||
<span name="company_activity" class="font-italic" t-field="o.company_id.report_header"/>
|
||||
<div/>
|
||||
<t t-esc="' - '.join([item for item in [
|
||||
', '.join([item for item in [header_address.street, header_address.street2] if item]),
|
||||
header_address.city,
|
||||
header_address.state_id and header_address.state_id.name,
|
||||
header_address.zip,
|
||||
header_address.country_id and header_address.country_id.name] if item])"/>
|
||||
<span t-if="header_address.phone">
|
||||
<br/>
|
||||
</span>
|
||||
<span t-if="header_address.phone" style="white-space: nowrap;"
|
||||
t-esc="'Tel: ' + header_address.phone"/>
|
||||
<span t-if="header_address.website">
|
||||
<span t-att-style="'color: %s;' % o.company_id.primary_color"
|
||||
t-esc="'- Web: %s' %' - '.join([item for item in [header_address.website.replace('https://', '').replace('http://', ''), header_address.email] if item])"/>
|
||||
</span>
|
||||
</div>
|
||||
<div name="right-upper-side" class="col-4">
|
||||
<div class="row">
|
||||
<div name="right-upper-side" class="col-12">
|
||||
<div class="row border border-dark">
|
||||
<div class="col-12 text-center">
|
||||
<h6 t-att-style="'color: %s;' % o.company_id.primary_color">
|
||||
<strong t-att-style="'color: %s;' % o.company_id.primary_color">
|
||||
<br/>
|
||||
<span style="line-height: 180%;">RUT:</span>
|
||||
<span t-field="o.company_id.partner_id.vat"/>
|
||||
<br/>
|
||||
<span class="text-uppercase" t-esc="report_name"/>
|
||||
<br/>
|
||||
<span>Nº:</span>
|
||||
<span style="line-height: 200%;" t-esc="report_number"/>
|
||||
</strong>
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
<!-- (6) Titulo de Documento -->
|
||||
<div class="row text-center">
|
||||
<div class="col-12 text-center" t-att-style="'color: %s;' % o.company_id.primary_color"
|
||||
name="regional-office"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<template id="informations">
|
||||
<div id="informations" class="row mt8 mb8">
|
||||
<div class="col-6">
|
||||
<strong>
|
||||
<span t-att-style="'color: %s;' % o.company_id.secondary_color">Date:</span>
|
||||
</strong>
|
||||
<span t-esc="report_date" t-options='{"widget": "date"}'/>
|
||||
<br/>
|
||||
|
||||
<strong>Customer:</strong>
|
||||
<span t-field="o.partner_id.name"/>
|
||||
<br/>
|
||||
|
||||
<t t-if="o.partner_id.vat and o.partner_id.l10n_latam_identification_type_id">
|
||||
<strong>
|
||||
<t t-esc="o.partner_id.l10n_latam_identification_type_id.name or o.company_id.country_id.vat_label" id="inv_tax_id_label"/>:
|
||||
</strong>
|
||||
<span t-esc="o.partner_id.vat"/>
|
||||
<br/>
|
||||
</t>
|
||||
<strong>GIRO:</strong>
|
||||
<span t-esc="o.partner_id.industry_id.name or ''"/>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<strong>Due Date:</strong>
|
||||
<span t-esc="o.invoice_date_due" t-options='{"widget": "date"}'/>
|
||||
<br/>
|
||||
<strong>Address:</strong>
|
||||
<span t-field="o.partner_id"
|
||||
t-options="{'widget': 'contact', 'fields': ['address'], 'no_marker': true, 'no_tag_br': True}"/>
|
||||
|
||||
<strong>Payment Terms:</strong>
|
||||
<span t-esc="o.invoice_payment_term_id.name or ''"/>
|
||||
|
||||
|
||||
<t t-if="o.invoice_incoterm_id">
|
||||
<br/>
|
||||
<strong>Incoterm:</strong>
|
||||
<span t-field="o.invoice_incoterm_id.name"/>
|
||||
</t>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="references" class="row">
|
||||
<div name="references" class="col-12 text-center"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="custom_footer">
|
||||
<div name="footer_left_column" class="col-8 text-center"/>
|
||||
</template>
|
||||
|
||||
<template id="report_invoice_document" inherit_id="account.report_invoice_document" primary="True">
|
||||
|
||||
<xpath expr="//h2" position="attributes">
|
||||
<attribute name="t-if">not o.l10n_latam_document_type_id.report_name</attribute>
|
||||
</xpath>
|
||||
<t t-set="o" position="after">
|
||||
<t t-set="custom_header" t-value="'l10n_cl.custom_header'"/>
|
||||
</t>
|
||||
|
||||
<xpath expr="//h2" position="after">
|
||||
<h2 t-if="o.l10n_latam_document_type_id.report_name">
|
||||
<span t-field="o.l10n_latam_document_type_id.report_name"/>
|
||||
<span t-field="o.l10n_latam_document_number"/>
|
||||
</h2>
|
||||
</xpath>
|
||||
<!-- remove default partner address -->
|
||||
<t t-set="address" position="replace"/>
|
||||
|
||||
<xpath expr="//h2" position="replace"/>
|
||||
|
||||
<xpath expr="//span[@t-field='line.price_unit']" position="attributes">
|
||||
<attribute name="t-field">line.l10n_latam_price_unit</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@id='line_tax_ids']" position="attributes">
|
||||
<attribute name="t-esc">', '.join(map(lambda x: (x.description or x.name), line.l10n_latam_tax_ids))</attribute>
|
||||
</xpath>
|
||||
|
||||
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" position="attributes">
|
||||
<attribute name="t-value">current_subtotal + line.l10n_latam_price_subtotal</attribute>
|
||||
</t>
|
||||
@@ -30,10 +153,52 @@
|
||||
<attribute name="t-field">line.l10n_latam_price_subtotal</attribute>
|
||||
</span>
|
||||
|
||||
|
||||
<span t-field="o.amount_untaxed" position="attributes">
|
||||
<attribute name="t-field">o.l10n_latam_amount_untaxed</attribute>
|
||||
</span>
|
||||
|
||||
|
||||
<!-- we remove the taxes column in boletas -->
|
||||
<xpath expr="//th[@name='th_taxes']/span" position="replace">
|
||||
<t t-if="is_tax">
|
||||
<span>Taxes</span>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//span[@id='line_tax_ids']" position="replace">
|
||||
<t t-if="is_tax">
|
||||
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))" id="line_tax_ids"/>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
<!-- remove payment term, this is added on information section -->
|
||||
<p name="payment_term" position="replace"/>
|
||||
|
||||
|
||||
<xpath expr="//span[@t-field='o.payment_reference']/../.." position="replace"/>
|
||||
|
||||
<div id="informations" position="replace">
|
||||
<t t-call="l10n_cl.informations"/>
|
||||
</div>
|
||||
|
||||
<!-- we remove the ml auto and also give more space to avoid multiple lines on tax detail -->
|
||||
<xpath expr="//div[@id='total']/div" position="attributes">
|
||||
<attribute name="t-attf-class">#{'col-6' if report_type != 'html' else 'col-sm-7 col-md-6'}</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[@id='total']/div" position="before">
|
||||
<div t-attf-class="#{'col-6' if report_type != 'html' else 'col-sm-7 col-md-6'}"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[@id='total']" position="after">
|
||||
<div class="row">
|
||||
<div name="stamp" class="col-4 text-center"/>
|
||||
<div name="transferable-table" class="col-4"/>
|
||||
<div name="transferable-legend" class="col-4 pull-right"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user