summaryrefslogtreecommitdiff
path: root/addons/l10n_ar/models/res_company.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_ar/models/res_company.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/l10n_ar/models/res_company.py')
-rw-r--r--addons/l10n_ar/models/res_company.py44
1 files changed, 44 insertions, 0 deletions
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.'))