diff --git a/addons/l10n_in/data/res_country_state_data.xml b/addons/l10n_in/data/res_country_state_data.xml index 55412d1f8c7..5b996c36923 100644 --- a/addons/l10n_in/data/res_country_state_data.xml +++ b/addons/l10n_in/data/res_country_state_data.xml @@ -8,6 +8,13 @@ 97 + + Other Country + IN_OC + + 96 + + 35 diff --git a/addons/l10n_in/models/account_invoice.py b/addons/l10n_in/models/account_invoice.py index 5670a903b40..4d312808418 100644 --- a/addons/l10n_in/models/account_invoice.py +++ b/addons/l10n_in/models/account_invoice.py @@ -19,7 +19,7 @@ class AccountMove(models.Model): ('deemed_export', 'Deemed Export'), ('uin_holders', 'UIN Holders'), ], string="GST Treatment", compute="_compute_l10n_in_gst_treatment", store=True, readonly=False, copy=True) - l10n_in_state_id = fields.Many2one('res.country.state', string="Location of supply") + l10n_in_state_id = fields.Many2one('res.country.state', string="Place of supply", compute="_compute_l10n_in_state_id", store=True, readonly=False) l10n_in_gstin = fields.Char(string="GSTIN") # For Export invoice this data is need in GSTR report l10n_in_shipping_bill_number = fields.Char('Shipping bill number', readonly=True, states={'draft': [('readonly', False)]}) @@ -37,17 +37,19 @@ class AccountMove(models.Model): for record in self: record.l10n_in_gst_treatment = record.partner_id.l10n_in_gst_treatment - @api.model - def _l10n_in_get_indian_state(self, partner): - """In tax return filing, If customer is not Indian in that case place of supply is must set to Other Territory. - So we set Other Territory in l10n_in_state_id when customer(partner) is not Indian - Also we raise if state is not set in Indian customer. - State is big role under GST because tax type is depend on.for more information check this https://www.cbic.gov.in/resources//htdocs-cbec/gst/Integrated%20goods%20&%20Services.pdf""" - if partner.country_id and partner.country_id.code == 'IN' and not partner.state_id: - raise ValidationError(_("State is missing from address in '%s'. First set state after post this invoice again.", partner.name)) - elif partner.country_id and partner.country_id.code != 'IN': - return self.env.ref('l10n_in.state_in_ot') - return partner.state_id + @api.depends('partner_id') + def _compute_l10n_in_state_id(self): + for move in self: + if move.country_code == 'IN': + country_code = move.partner_id.country_id.code + if country_code == 'IN': + move.l10n_in_state_id = move.partner_id.state_id + elif country_code: + move.l10n_in_state_id = self.env.ref('l10n_in.state_in_oc', raise_if_not_found=False) + else: + move.l10n_in_state_id = move.company_id.state_id + else: + move.l10n_in_state_id = False def _post(self, soft=True): """Use journal type to define document type because not miss state in any entry including POS entry""" @@ -66,9 +68,6 @@ class AccountMove(models.Model): "views": [[self.env.ref("base.view_company_form").id, "form"]], } raise RedirectWarning(msg, action, _('Go to Company configuration')) - elif move.journal_id.type == 'purchase': - move.l10n_in_state_id = move.company_id.state_id - move.l10n_in_gstin = move.partner_id.vat if not move.l10n_in_gstin and move.l10n_in_gst_treatment in ['regular', 'composition', 'special_economic_zone', 'deemed_export']: raise ValidationError(_( @@ -77,11 +76,6 @@ class AccountMove(models.Model): partner_id=move.partner_id.id, name=gst_treatment_name_mapping.get(move.l10n_in_gst_treatment) )) - if move.journal_id.type == 'sale': - move.l10n_in_state_id = self._l10n_in_get_indian_state(move.partner_id) - #still state is not set then assumed that transaction is local like PoS so set state of company - if not move.l10n_in_state_id: - move.l10n_in_state_id = move.company_id.state_id return posted def _l10n_in_get_warehouse_address(self): diff --git a/addons/l10n_in/views/account_invoice_views.xml b/addons/l10n_in/views/account_invoice_views.xml index 91e3c921f12..d9aff6e1de8 100644 --- a/addons/l10n_in/views/account_invoice_views.xml +++ b/addons/l10n_in/views/account_invoice_views.xml @@ -7,6 +7,8 @@ + diff --git a/addons/l10n_in/views/report_invoice.xml b/addons/l10n_in/views/report_invoice.xml index b05e4a2a883..8fac8b247c8 100644 --- a/addons/l10n_in/views/report_invoice.xml +++ b/addons/l10n_in/views/report_invoice.xml @@ -6,12 +6,7 @@ - - Destination of supply: - - - Place of supply: - + Place of supply: