mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-26 15:12:07 +02:00
Initial commit: L10N_Americas packages
This commit is contained in:
commit
12b27ce151
714 changed files with 79328 additions and 0 deletions
8
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/__init__.py
Normal file
8
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/__init__.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import account_tax
|
||||
from . import account_move
|
||||
from . import l10n_latam_identification_type
|
||||
from . import res_partner
|
||||
from . import res_city_district
|
||||
from . import res_city
|
||||
from . import res_company
|
||||
52
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/account_move.py
Normal file
52
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/account_move.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, models, fields
|
||||
from odoo.tools.sql import column_exists, create_column
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
def _get_l10n_latam_documents_domain(self):
|
||||
self.ensure_one()
|
||||
result = super()._get_l10n_latam_documents_domain()
|
||||
if self.company_id.country_id.code != "PE" or not self.journal_id.l10n_latam_use_documents:
|
||||
return result
|
||||
if self.journal_id.type == "sale":
|
||||
result.append(("code", "in", ("01", "03", "07", "08", "20", "40")))
|
||||
return result
|
||||
|
||||
@api.onchange('l10n_latam_document_type_id', 'l10n_latam_document_number', 'partner_id')
|
||||
def _inverse_l10n_latam_document_number(self):
|
||||
"""Inherit to complete the l10n_latam_document_number with the expected 8 characters after that a '-'
|
||||
Example: Change FFF-32 by FFF-00000032, to avoid incorrect values on the reports"""
|
||||
super()._inverse_l10n_latam_document_number()
|
||||
to_review = self.filtered(
|
||||
lambda x: x.journal_id.type == "purchase"
|
||||
and x.l10n_latam_document_type_id.code in ("01", "03", "07", "08")
|
||||
and x.l10n_latam_document_number
|
||||
and "-" in x.l10n_latam_document_number
|
||||
and x.l10n_latam_document_type_id.country_id.code == "PE"
|
||||
)
|
||||
for rec in to_review:
|
||||
number = rec.l10n_latam_document_number.split("-")
|
||||
rec.l10n_latam_document_number = "%s-%s" % (number[0], number[1].zfill(8))
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
l10n_pe_group_id = fields.Many2one("account.group", related="account_id.group_id", store=True)
|
||||
|
||||
def _auto_init(self):
|
||||
"""
|
||||
Create column to stop ORM from computing it himself (too slow)
|
||||
"""
|
||||
if not column_exists(self.env.cr, self._table, 'l10n_pe_group_id'):
|
||||
create_column(self.env.cr, self._table, 'l10n_pe_group_id', 'int4')
|
||||
self.env.cr.execute("""
|
||||
UPDATE account_move_line line
|
||||
SET l10n_pe_group_id = account.group_id
|
||||
FROM account_account account
|
||||
WHERE account.id = line.account_id
|
||||
""")
|
||||
return super()._auto_init()
|
||||
75
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/account_tax.py
Normal file
75
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/account_tax.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountTax(models.Model):
|
||||
_inherit = "account.tax"
|
||||
|
||||
l10n_pe_edi_tax_code = fields.Selection([
|
||||
('1000', 'IGV - General Sales Tax'),
|
||||
('1016', 'IVAP - Tax on Sale Paddy Rice'),
|
||||
('2000', 'ISC - Selective Excise Tax'),
|
||||
('7152', 'ICBPER - Plastic bag tax'),
|
||||
('9995', 'EXP - Exportation'),
|
||||
('9996', 'GRA - Free'),
|
||||
('9997', 'EXO - Exonerated'),
|
||||
('9998', 'INA - Unaffected'),
|
||||
('9999', 'OTROS - Other taxes')
|
||||
], 'EDI peruvian code')
|
||||
|
||||
l10n_pe_edi_unece_category = fields.Selection([
|
||||
('E', 'Exempt from tax'),
|
||||
('G', 'Free export item, tax not charged'),
|
||||
('O', 'Services outside scope of tax'),
|
||||
('S', 'Standard rate'),
|
||||
('Z', 'Zero rated goods')], 'EDI UNECE code',
|
||||
help="Follow the UN/ECE 5305 standard from the United Nations Economic Commission for Europe for more "
|
||||
"information http://www.unece.org/trade/untdid/d08a/tred/tred5305.htm"
|
||||
)
|
||||
l10n_pe_edi_isc_type = fields.Selection([
|
||||
('01', 'System to value'),
|
||||
('02', 'Application of the Fixed Amount'),
|
||||
('03', 'Retail Price System'),
|
||||
], 'ISC Type',
|
||||
help='Used in Selective Consumption Tax to indicate the type of calculation for the ISC.')
|
||||
|
||||
|
||||
class AccountTaxTemplate(models.Model):
|
||||
_inherit = "account.tax.template"
|
||||
|
||||
l10n_pe_edi_tax_code = fields.Selection([
|
||||
('1000', 'IGV - General Sales Tax'),
|
||||
('1016', 'IVAP - Tax on Sale Paddy Rice'),
|
||||
('2000', 'ISC - Selective Excise Tax'),
|
||||
('7152', 'ICBPER - Plastic bag tax'),
|
||||
('9995', 'EXP - Exportation'),
|
||||
('9996', 'GRA - Free'),
|
||||
('9997', 'EXO - Exonerated'),
|
||||
('9998', 'INA - Unaffected'),
|
||||
('9999', 'OTROS - Other taxes')
|
||||
], 'EDI peruvian code')
|
||||
|
||||
l10n_pe_edi_unece_category = fields.Selection([
|
||||
('E', 'Exempt from tax'),
|
||||
('G', 'Free export item, tax not charged'),
|
||||
('O', 'Services outside scope of tax'),
|
||||
('S', 'Standard rate'),
|
||||
('Z', 'Zero rated goods')], 'EDI UNECE code',
|
||||
help="Follow the UN/ECE 5305 standard from the United Nations Economic Commission for Europe for more "
|
||||
"information http://www.unece.org/trade/untdid/d08a/tred/tred5305.htm"
|
||||
)
|
||||
l10n_pe_edi_isc_type = fields.Selection([
|
||||
('01', 'System to value'),
|
||||
('02', 'Application of the Fixed Amount'),
|
||||
('03', 'Retail Price System'),
|
||||
], 'ISC Type',
|
||||
help='Used in Selective Consumption Tax to indicate the type of calculation for the ISC.')
|
||||
|
||||
def _get_tax_vals(self, company, tax_template_to_tax):
|
||||
val = super()._get_tax_vals(company, tax_template_to_tax)
|
||||
val.update({
|
||||
'l10n_pe_edi_tax_code': self.l10n_pe_edi_tax_code,
|
||||
'l10n_pe_edi_unece_category': self.l10n_pe_edi_unece_category,
|
||||
'l10n_pe_edi_isc_type': self.l10n_pe_edi_isc_type,
|
||||
})
|
||||
return val
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class L10nLatamIdentificationType(models.Model):
|
||||
|
||||
_inherit = "l10n_latam.identification.type"
|
||||
|
||||
l10n_pe_vat_code = fields.Char()
|
||||
9
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_city.py
Normal file
9
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_city.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class City(models.Model):
|
||||
_inherit = "res.city"
|
||||
|
||||
l10n_pe_code = fields.Char('Code', help='This code will help with the '
|
||||
'identification of each city in Peru.')
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class L10nPeResCityDistrict(models.Model):
|
||||
_name = 'l10n_pe.res.city.district'
|
||||
_description = 'District'
|
||||
_order = 'name'
|
||||
|
||||
name = fields.Char(translate=True)
|
||||
city_id = fields.Many2one('res.city', 'City')
|
||||
code = fields.Char(
|
||||
help='This code will help with the identification of each district '
|
||||
'in Peru.')
|
||||
12
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_company.py
Normal file
12
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_company.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
def _localization_use_documents(self):
|
||||
# OVERRIDE
|
||||
self.ensure_one()
|
||||
return self.account_fiscal_country_id.code == "PE" or super()._localization_use_documents()
|
||||
26
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_partner.py
Normal file
26
odoo-bringout-oca-ocb-l10n_pe/l10n_pe/models/res_partner.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
l10n_pe_district = fields.Many2one(
|
||||
'l10n_pe.res.city.district', string='District',
|
||||
help='Districts are part of a province or city.')
|
||||
l10n_pe_district_name = fields.Char(string='District name', related='l10n_pe_district.name')
|
||||
|
||||
@api.onchange('l10n_pe_district')
|
||||
def _onchange_l10n_pe_district(self):
|
||||
if self.l10n_pe_district:
|
||||
self.city_id = self.l10n_pe_district.city_id
|
||||
|
||||
@api.onchange('city_id')
|
||||
def _onchange_l10n_pe_city_id(self):
|
||||
if self.city_id and self.l10n_pe_district.city_id and self.l10n_pe_district.city_id != self.city_id:
|
||||
self.l10n_pe_district = False
|
||||
|
||||
@api.model
|
||||
def _formatting_address_fields(self):
|
||||
"""Returns the list of address fields usable to format addresses."""
|
||||
return super()._formatting_address_fields() + ['l10n_pe_district_name']
|
||||
Loading…
Add table
Add a link
Reference in a new issue