summaryrefslogtreecommitdiff
path: root/addons/l10n_pe
diff options
context:
space:
mode:
authorfw-bot <otis@odoo.com>2019-10-16 09:18:15 +0000
committerJosse Colpaert <jco@odoo.com>2019-10-16 11:37:28 +0000
commiteaa094285e489dadc5607cfb9ec44fc721322a29 (patch)
tree4bc5c9e6c16f3dc86d3ab7948c7532c53ecaff55 /addons/l10n_pe
parentcddf577abb991568197f31bf3ba3cad13aabd0ea (diff)
[FIX] l1n_pe: forward-port of fixes to l10n_pe
base_vat: Correct management of the check of peruvian VAT without prefix. l10n_pe: Correct income account the last one is not correct. l10n_pe: Forced Round globally for peruvian companies once l10n_pe is installed, and with the onchange. l10n_pe: For peruvian companies it does not make sense a sequence per year and the year in the prefix is incorrect, we must force XXX- as a sequence prefix. closes odoo/odoo#38854 Forward-port-of: #38764 Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'addons/l10n_pe')
-rw-r--r--addons/l10n_pe/data/l10n_pe_chart_post_data.xml2
-rw-r--r--addons/l10n_pe/data/res_country_data.xml14
-rw-r--r--addons/l10n_pe/models/__init__.py3
-rw-r--r--addons/l10n_pe/models/account_chart_template.py14
-rw-r--r--addons/l10n_pe/models/account_journal.py31
-rw-r--r--addons/l10n_pe/models/account_tax.py2
-rw-r--r--addons/l10n_pe/models/res_company.py13
7 files changed, 71 insertions, 8 deletions
diff --git a/addons/l10n_pe/data/l10n_pe_chart_post_data.xml b/addons/l10n_pe/data/l10n_pe_chart_post_data.xml
index b28f5129674..5103fa97f27 100644
--- a/addons/l10n_pe/data/l10n_pe_chart_post_data.xml
+++ b/addons/l10n_pe/data/l10n_pe_chart_post_data.xml
@@ -6,7 +6,7 @@
<field name="property_account_payable_id" ref="chart4212"/>
<field name="property_account_expense_categ_id" ref="chart6329"/>
<field name="property_account_expense_id" ref="chart6011"/>
- <field name="property_account_income_categ_id" ref="chart70111"/>
+ <field name="property_account_income_categ_id" ref="chart70121"/>
<field name="property_stock_account_input_categ_id" ref="chart6111"/>
<field name="property_stock_account_output_categ_id" ref="chart69111"/>
<field name="property_stock_valuation_account_id" ref="chart20111"/>
diff --git a/addons/l10n_pe/data/res_country_data.xml b/addons/l10n_pe/data/res_country_data.xml
index 72aede8be3c..4b6a12df565 100644
--- a/addons/l10n_pe/data/res_country_data.xml
+++ b/addons/l10n_pe/data/res_country_data.xml
@@ -9,22 +9,22 @@
<div class="o_address_format">
<field name="parent_id" invisible="1"/>
<field name="type" invisible="1"/>
- <field name="street" invisible="1"/>
- <field name="street_name" placeholder="Street Name..." attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
- <field name="street2" placeholder="Street2"/>
+ <field name="street_name" placeholder="Street Name..." attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" class="oe_read_only"/>
+ <field name="street" placeholder="Street" class="oe_edit_only"/>
+ <field name="street2" placeholder="Street2" invisible="1"/>
<div class="o_row">
<label for="street_number" class="oe_edit_only"/>
- <span> </span>
<field name="street_number" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
+ <span> </span>
<label for="street_number2" class="oe_edit_only"/>
<field name="street_number2" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</div>
<field name="l10n_pe_district" placeholder="District..."/>
<field name="city" placeholder="Province..." invisible="1"/>
- <field name="city_id" placeholder="Province..." />
+ <field name="city_id" placeholder="Province..."/>
<field name="state_id" class="o_address_state" placeholder="State..." options='{"no_open": True}'/>
- <field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
+ <field name="zip" placeholder="ZIP" class="o_address_zip"/>
</div>
</form>
</field>
@@ -32,5 +32,7 @@
<record id="base.pe" model="res.country">
<field name="enforce_cities" eval="1" />
<field name="address_view_id" ref="pe_partner_address_form" />
+ <field name="address_format" eval="'%(street)s\n%(city)s\n%(state_name)s\n%(country_name)s'"/>
+ <field name="street_format" eval="'%(street_name)s %(street_number)s, %(street_number2)s'"/>
</record>
</odoo>
diff --git a/addons/l10n_pe/models/__init__.py b/addons/l10n_pe/models/__init__.py
index 7be3012e1aa..4ba6149ba4f 100644
--- a/addons/l10n_pe/models/__init__.py
+++ b/addons/l10n_pe/models/__init__.py
@@ -1,7 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_tax
from . import account_move
+from . import account_journal
+from . import account_chart_template
from . import l10n_latam_identification_type
from . import res_partner
from . import res_city_district
from . import res_city
+from . import res_company
diff --git a/addons/l10n_pe/models/account_chart_template.py b/addons/l10n_pe/models/account_chart_template.py
new file mode 100644
index 00000000000..e9314da7709
--- /dev/null
+++ b/addons/l10n_pe/models/account_chart_template.py
@@ -0,0 +1,14 @@
+from odoo import models
+
+
+class AccountChartTemplate(models.Model):
+
+ _inherit = 'account.chart.template'
+
+ def _load(self, sale_tax_rate, purchase_tax_rate, company):
+ """Load the rounding method properly to the company once the CoA is installed.
+ """
+ company.filtered(lambda c: c.country_id.id == self.env.ref('base.pe').id).write({
+ 'tax_calculation_rounding_method': 'round_globally',
+ })
+ return super()._load(sale_tax_rate, purchase_tax_rate, company)
diff --git a/addons/l10n_pe/models/account_journal.py b/addons/l10n_pe/models/account_journal.py
new file mode 100644
index 00000000000..ff55a01cd45
--- /dev/null
+++ b/addons/l10n_pe/models/account_journal.py
@@ -0,0 +1,31 @@
+from odoo import models, api
+
+
+class AccountJournal(models.Model):
+ _inherit = "account.journal"
+
+ @api.model
+ def _get_sequence_prefix(self, code, refund=False):
+ """For peruvian companies we can not use sequences with **/** due to the edi generation which need in the
+ sequence a plain text ended by a *-* and the length of this prefix"""
+ if self.env.company.country_id != self.env.ref('base.pe'):
+ return super()._get_sequence_prefix(code, refund=refund)
+ prefix = code.upper()
+ if len(prefix) > 3:
+ prefix = prefix[:3]
+ prefix = prefix.ljust(3, 'X')
+ if refund:
+ prefix = 'R' + prefix[:-1]
+ return prefix + '-'
+
+ @api.model
+ def _create_sequence(self, vals, refund=False):
+ """For Peruvian companies, a number reset by date do not make sense due to the fact that we can not use a free
+ prefix the format does not have enough space to put a year on it or any other char, then with this approach we
+ are avoiding the default behavior there."""
+ res = super()._create_sequence(vals, refund=refund)
+ # NOTE: the self element is coming filled just when write and not on create (which is Ok)
+ journal_type = self.type if not vals.get('type') else vals.get('type')
+ if self.env.company.country_id == self.env.ref('base.pe') or journal_type in ['sale', 'purchase']:
+ res.write({'use_date_range': False})
+ return res
diff --git a/addons/l10n_pe/models/account_tax.py b/addons/l10n_pe/models/account_tax.py
index eb8674c629c..903093fc9fc 100644
--- a/addons/l10n_pe/models/account_tax.py
+++ b/addons/l10n_pe/models/account_tax.py
@@ -57,4 +57,4 @@ class AccountTaxTemplate(models.Model):
'l10n_pe_edi_tax_code': self.l10n_pe_edi_tax_code,
'l10n_pe_edi_unece_category': self.l10n_pe_edi_unece_category,
})
- return val \ No newline at end of file
+ return val
diff --git a/addons/l10n_pe/models/res_company.py b/addons/l10n_pe/models/res_company.py
new file mode 100644
index 00000000000..bee9be55580
--- /dev/null
+++ b/addons/l10n_pe/models/res_company.py
@@ -0,0 +1,13 @@
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from odoo import models, api
+
+
+class ResCompany(models.Model):
+
+ _inherit = "res.company"
+
+ @api.onchange('country_id')
+ def onchange_country(self):
+ """In Peru, the rounding method it's calculated as global"""
+ for rec in self.filtered(lambda x: x.country_id == self.env.ref('base.pe')):
+ rec.tax_calculation_rounding_method = 'round_globally'