mirror of
https://github.com/bringout/oca-ocb-l10n_asia-pacific.git
synced 2026-04-27 08:02:01 +02:00
Initial commit: L10N_Asia Pacific packages
This commit is contained in:
commit
54c86b612c
828 changed files with 58224 additions and 0 deletions
58
odoo-bringout-oca-ocb-l10n_in/l10n_in/models/res_partner.py
Normal file
58
odoo-bringout-oca-ocb-l10n_in/l10n_in/models/res_partner.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# -*- 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue