[IMP] l10n_in: autofill PAN from GST number
Previously, users were required to enter their PAN number even after manually inputting their GSTIN, even though the PAN is inherently part of the GSTIN (spanning from the 3rd to the 12th character). Furthermore, there was no mechanism to alert users if the manually entered PAN did not match the PAN segment within the GSTIN. This commit automates the filling of the PAN based on the entered GSTIN. Now upon entering a GSTIN, the corresponding PAN is auto-filled. task-3767627 closes odoo/odoo#157689 X-original-commit: ffd2274498f1fbf0205e60f1b125134e4fede16e Signed-off-by: Quentin De Paoli <qdp@odoo.com> Signed-off-by: Earth Patel (eapa) <eapa@odoo.com>
This commit is contained in:
@@ -27,6 +27,12 @@ class ResPartner(models.Model):
|
||||
"Thus, PAN acts as an identifier for the person with the tax department."
|
||||
)
|
||||
|
||||
display_pan_warning = fields.Boolean(string="Display pan warning", compute="_compute_display_pan_warning")
|
||||
|
||||
@api.depends('l10n_in_pan')
|
||||
def _compute_display_pan_warning(self):
|
||||
self.display_pan_warning = self.vat and self.l10n_in_pan and self.l10n_in_pan != self.vat[2:12]
|
||||
|
||||
@api.onchange('company_type')
|
||||
def onchange_company_type(self):
|
||||
res = super().onchange_company_type()
|
||||
@@ -49,6 +55,8 @@ class ResPartner(models.Model):
|
||||
state_id = self.env['res.country.state'].search([('l10n_in_tin', '=', self.vat[:2])], limit=1)
|
||||
if state_id:
|
||||
self.state_id = state_id
|
||||
if self.vat[2].isalpha():
|
||||
self.l10n_in_pan = self.vat[2:12]
|
||||
|
||||
@api.model
|
||||
def _commercial_fields(self):
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
<xpath expr="//field[@name='vat']" position="after">
|
||||
<field name="l10n_in_pan" placeholder="e.g. ABCTY1234D" invisible="'IN' not in fiscal_country_codes" />
|
||||
</xpath>
|
||||
<xpath expr="//sheet" position="before">
|
||||
<field name="display_pan_warning" invisible="1"/>
|
||||
<div class="alert alert-warning" role="alert"
|
||||
invisible="not display_pan_warning">
|
||||
PAN number is not same as the 3rd to 12th characters of the GST number.
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user