From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/l10n_ar/models/res_company.py | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 addons/l10n_ar/models/res_company.py (limited to 'addons/l10n_ar/models/res_company.py') diff --git a/addons/l10n_ar/models/res_company.py b/addons/l10n_ar/models/res_company.py new file mode 100644 index 00000000..62fe7563 --- /dev/null +++ b/addons/l10n_ar/models/res_company.py @@ -0,0 +1,44 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError + +class ResCompany(models.Model): + + _inherit = "res.company" + + l10n_ar_gross_income_number = fields.Char( + related='partner_id.l10n_ar_gross_income_number', string='Gross Income Number', readonly=False, + help="This field is required in order to print the invoice report properly") + l10n_ar_gross_income_type = fields.Selection( + related='partner_id.l10n_ar_gross_income_type', string='Gross Income', readonly=False, + help="This field is required in order to print the invoice report properly") + l10n_ar_afip_responsibility_type_id = fields.Many2one( + domain="[('code', 'in', [1, 4, 6])]", related='partner_id.l10n_ar_afip_responsibility_type_id', readonly=False) + l10n_ar_company_requires_vat = fields.Boolean(compute='_compute_l10n_ar_company_requires_vat', string='Company Requires Vat?') + l10n_ar_afip_start_date = fields.Date('Activities Start') + + @api.onchange('country_id') + def onchange_country(self): + """ Argentinian companies use round_globally as tax_calculation_rounding_method """ + for rec in self.filtered(lambda x: x.country_id.code == "AR"): + rec.tax_calculation_rounding_method = 'round_globally' + + @api.depends('l10n_ar_afip_responsibility_type_id') + def _compute_l10n_ar_company_requires_vat(self): + recs_requires_vat = self.filtered(lambda x: x.l10n_ar_afip_responsibility_type_id.code == '1') + recs_requires_vat.l10n_ar_company_requires_vat = True + remaining = self - recs_requires_vat + remaining.l10n_ar_company_requires_vat = False + + def _localization_use_documents(self): + """ Argentinian localization use documents """ + self.ensure_one() + return True if self.country_id.code == "AR" else super()._localization_use_documents() + + @api.constrains('l10n_ar_afip_responsibility_type_id') + def _check_accounting_info(self): + """ Do not let to change the AFIP Responsibility of the company if there is already installed a chart of + account and if there has accounting entries """ + if self.env['account.chart.template'].existing_accounting(self): + raise ValidationError(_( + 'Could not change the AFIP Responsibility of this company because there are already accounting entries.')) -- cgit v1.2.3