From f9efc2b75f826368973b799c43391104ca5fa83e Mon Sep 17 00:00:00 2001 From: Jigar Vaghela Date: Wed, 29 Dec 2021 06:01:04 +0000 Subject: [PATCH] [IMP] l10n_in: simplify place of supply We just set a place of supply(state_id) from partner_id in the Invoice/Bill if partner country is india because there are many complex cases so we can't get it automatically in all cases like (a) where the supply involves movement of goods, whether by the supplier or the recipient or by any other person, the place of supply of such goods shall be the location of the goods at the time at which the movement of goods terminates for delivery to the recipient; (b) where the goods are delivered by the supplier to a recipient or any other person on the direction of a third person, whether acting as an agent or otherwise, before or during movement of goods, either by way of transfer of documents of title to the goods or otherwise, it shall be deemed that the said third person has received the goods and the place of supply of such goods shall be the principal place of business of such person; (c) where the supply does not involve movement of goods, whether by the supplier or the recipient, the place of supply shall be the location of such goods at the time of the delivery to the recipient; (d) where the goods are assembled or installed at site, the place of supply shall be the place of such installation or assembly; (e) where the goods are supplied on board a conveyance, including a vessel, an aircraft, a train or a motor vehicle, the place of supply shall be the location at which such goods are taken on board. we add new state "Other Country" to set place of supply(state_id) incase of partner country is not India for more details check CHAPTER V here https://www.cbic.gov.in/resources//htdocs-cbec/gst/igst-act.pdf;jsessionid=63D695F612B9972934E8131415FEBA28 closes odoo/odoo#82011 closes odoo/odoo#109286 X-original-commit: https://github.com/odoo-dev/odoo/commit/b76ee098e2a4c4d26d6d1c689bb0750e770201dc Signed-off-by: Quentin De Paoli Signed-off-by: Josse Colpaert --- .../l10n_in/data/res_country_state_data.xml | 7 ++++ addons/l10n_in/models/account_invoice.py | 34 ++++++++----------- .../l10n_in/views/account_invoice_views.xml | 2 ++ addons/l10n_in/views/report_invoice.xml | 7 +--- 4 files changed, 24 insertions(+), 26 deletions(-) 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: