Files
odoo_source/addons/l10n_in/models/res_partner.py
T
Jigar Vaghela 534167bf96 [IMP] l10n_in: update demo data, add tax report line and method to get warehouse address
add get warehouse address method
needed in Indian EDI to pass value of dispatched address

improve demo data and bypass one GST number from validation because that GST number use to test EDI

Add Non GST Supplies and State CESS tax report line
Non-GST Supplies and State CESS is required to get related value from the invoice for send EDI

Part-of: odoo/odoo#79995
2022-04-06 16:45:30 +02:00

58 lines
2.1 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'),
], 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)