From e214f6647a078aeba97ec51e6b46ce02e1ded8e3 Mon Sep 17 00:00:00 2001 From: Earth Patel Date: Tue, 27 Feb 2024 11:21:28 +0530 Subject: [PATCH] [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 Signed-off-by: Earth Patel (eapa) --- addons/l10n_in/models/res_partner.py | 8 ++++++++ addons/l10n_in/views/res_partner_views.xml | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/addons/l10n_in/models/res_partner.py b/addons/l10n_in/models/res_partner.py index 3aa3d8fb3d7..ba021b7bffb 100644 --- a/addons/l10n_in/models/res_partner.py +++ b/addons/l10n_in/models/res_partner.py @@ -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): diff --git a/addons/l10n_in/views/res_partner_views.xml b/addons/l10n_in/views/res_partner_views.xml index b4bb33f7691..28ffc985e98 100644 --- a/addons/l10n_in/views/res_partner_views.xml +++ b/addons/l10n_in/views/res_partner_views.xml @@ -16,6 +16,13 @@ + + + +