summaryrefslogtreecommitdiff
path: root/addons/l10n_latam_base/models/res_company.py
blob: 165d0afb5f6ef8125c808dcd3af743ca98609e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, fields, api


class ResCompany(models.Model):
    _inherit = 'res.company'

    @api.model
    def create(self, vals):
        """ If exists, use specific vat identification.type for the country of the company """
        country_id = vals.get('country_id')
        if country_id:
            country_vat_type = self.env['l10n_latam.identification.type'].search(
                [('is_vat', '=', True), ('country_id', '=', country_id)], limit=1)
            if country_vat_type:
                self = self.with_context(default_l10n_latam_identification_type_id=country_vat_type.id)
        return super().create(vals)