Files
odoo_source/addons/l10n_in/models/res_partner.py
T
oco-odoo b7232b14b7 [IMP] account, l10n_*: Introduce unified reporting engine
This commit adapts account's model to the new report engine introduced for v16, and updates the data files accordingly.

account.report model is now declared in community, together with the other models used by the reporting. This is done so that the tax tags can properly be created by the tax report and used on tax templates. All the actual computation logic stays in enterprise.

See enterprise commit for full details.

Task 2524389

Part-of: odoo/odoo#94125
2022-08-25 19:56:55 +02:00

59 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
TEST_GST_NUMBER = "36AABCT1332L011"
class ResPartner(models.Model):
_inherit = 'res.partner'
l10n_in_gst_treatment = fields.Selection([
('regular', 'Registered Business - Regular'),
('composition', 'Registered Business - Composition'),
('unregistered', 'Unregistered Business'),
('consumer', 'Consumer'),
('overseas', 'Overseas'),
('special_economic_zone', 'Special Economic Zone'),
('deemed_export', 'Deemed Export'),
('uin_holders', 'UIN Holders'),
], string="GST Treatment")
@api.onchange('company_type')
def onchange_company_type(self):
res = super().onchange_company_type()
if self.country_id and self.country_id.code == 'IN':
self.l10n_in_gst_treatment = (self.company_type == 'company') and 'regular' or 'consumer'
return res
@api.onchange('country_id')
def _onchange_country_id(self):
res = super()._onchange_country_id()
if self.country_id and self.country_id.code != 'IN':
self.l10n_in_gst_treatment = 'overseas'
elif self.country_id and self.country_id.code == 'IN':
self.l10n_in_gst_treatment = (self.company_type == 'company') and 'regular' or 'consumer'
return res
@api.onchange('vat')
def onchange_vat(self):
if self.vat and self.check_vat_in(self.vat):
state_id = self.env['res.country.state'].search([('l10n_in_tin', '=', self.vat[:2])], limit=1)
if state_id:
self.state_id = state_id
@api.model
def _commercial_fields(self):
res = super()._commercial_fields()
return res + ['l10n_in_gst_treatment']
def check_vat_in(self, vat):
"""
This TEST_GST_NUMBER is used as test credentials for EDI
but this is not a valid number as per the regular expression
so TEST_GST_NUMBER is considered always valid
"""
if vat == TEST_GST_NUMBER:
return True
return super().check_vat_in(vat)