From a634aafe4df675ed2f819cfa4208a38c8ff0b476 Mon Sep 17 00:00:00 2001 From: bat-odoo Date: Fri, 2 Dec 2022 09:58:18 +0000 Subject: [PATCH] [REM] l10n_in*: removed multi GSTIN In this commit, we have removed the multi-GSTIN feature from the journal. Multi-unit is created if there is a different branch with the same GSTIN(vat) so now we decided to create a multi-company instead of this. because functionally we discuss with Indian CA and we find out that it's good practice if we create a different company. The main problem is one company and the same Bank account but we also find a functional solution using a transfer balance to another company. so we remove this so our other integrations do not have complexity like E-invoice, E-waybill, GST E-filing TaskID - 2723109 closes odoo/odoo#107234 Related: odoo/upgrade#4107 Signed-off-by: Josse Colpaert --- addons/l10n_in/__manifest__.py | 1 - addons/l10n_in/models/account.py | 22 ------------------- addons/l10n_in/models/account_invoice.py | 18 ++++++--------- addons/l10n_in/models/chart_template.py | 2 -- .../l10n_in/views/account_journal_views.xml | 3 --- addons/l10n_in/views/report_template.xml | 15 ------------- addons/l10n_in_purchase/models/__init__.py | 1 - .../l10n_in_purchase/models/account_move.py | 3 --- .../l10n_in_purchase/models/purchase_order.py | 10 --------- .../views/purchase_order_views.xml | 3 --- addons/l10n_in_purchase_stock/__manifest__.py | 12 ++++------ .../l10n_in_purchase_stock/models/__init__.py | 2 -- .../models/purchase_order.py | 15 ------------- .../models/stock_warehouse.py | 10 --------- .../views/stock_warehouse_views.xml | 13 ----------- addons/l10n_in_sale/models/sale_order.py | 15 ------------- addons/l10n_in_sale/views/sale_views.xml | 3 --- .../wizard/sale_make_invoice_advance.py | 2 -- addons/l10n_in_sale_stock/__manifest__.py | 13 +++++------ addons/l10n_in_sale_stock/models/__init__.py | 2 -- .../l10n_in_sale_stock/models/sale_order.py | 16 -------------- .../models/stock_warehouse.py | 10 --------- .../views/stock_warehouse_views.xml | 13 ----------- 23 files changed, 16 insertions(+), 188 deletions(-) delete mode 100644 addons/l10n_in/views/report_template.xml delete mode 100644 addons/l10n_in_purchase_stock/models/purchase_order.py delete mode 100644 addons/l10n_in_purchase_stock/models/stock_warehouse.py delete mode 100644 addons/l10n_in_purchase_stock/views/stock_warehouse_views.xml delete mode 100644 addons/l10n_in_sale_stock/models/sale_order.py delete mode 100644 addons/l10n_in_sale_stock/models/stock_warehouse.py delete mode 100644 addons/l10n_in_sale_stock/views/stock_warehouse_views.xml diff --git a/addons/l10n_in/__manifest__.py b/addons/l10n_in/__manifest__.py index 06caad91412..308d5d48d05 100644 --- a/addons/l10n_in/__manifest__.py +++ b/addons/l10n_in/__manifest__.py @@ -43,7 +43,6 @@ Sheet, now only Vertical format has been permitted Which is Supported By Odoo. 'views/res_partner_views.xml', 'views/account_tax_views.xml', 'views/uom_uom_views.xml', - 'views/report_template.xml', 'data/account_chart_template_data.xml' ], 'demo': [ diff --git a/addons/l10n_in/models/account.py b/addons/l10n_in/models/account.py index f9891b456fe..43904b8bcd2 100644 --- a/addons/l10n_in/models/account.py +++ b/addons/l10n_in/models/account.py @@ -6,28 +6,6 @@ from odoo.exceptions import ValidationError from odoo import tools -class AccountJournal(models.Model): - _inherit = "account.journal" - - # Use for filter import and export type. - l10n_in_gstin_partner_id = fields.Many2one('res.partner', string="GSTIN Unit", ondelete="restrict", help="GSTIN related to this journal. If empty then consider as company GSTIN.") - - def name_get(self): - """ - Add GSTIN number in name as suffix so user can easily find the right journal. - Used super to ensure nothing is missed. - """ - result = super().name_get() - result_dict = dict(result) - indian_journals = self.filtered(lambda j: j.company_id.account_fiscal_country_id.code == 'IN' and - j.l10n_in_gstin_partner_id and j.l10n_in_gstin_partner_id.vat) - for journal in indian_journals: - name = result_dict[journal.id] - name += "- %s" % (journal.l10n_in_gstin_partner_id.vat) - result_dict[journal.id] = name - return list(result_dict.items()) - - class AccountMoveLine(models.Model): _inherit = "account.move.line" diff --git a/addons/l10n_in/models/account_invoice.py b/addons/l10n_in/models/account_invoice.py index 979f3ea05cd..e63927b99a5 100644 --- a/addons/l10n_in/models/account_invoice.py +++ b/addons/l10n_in/models/account_invoice.py @@ -55,16 +55,14 @@ class AccountMove(models.Model): gst_treatment_name_mapping = {k: v for k, v in self._fields['l10n_in_gst_treatment']._description_selection(self.env)} for move in posted.filtered(lambda m: m.country_code == 'IN'): - """Check state is set in company/sub-unit""" - company_unit_partner = move.journal_id.l10n_in_gstin_partner_id or move.journal_id.company_id - if not company_unit_partner.state_id: + if not move.company_id.state_id: raise ValidationError(_( - "State is missing from your company/unit %(company_name)s (%(company_id)s).\nFirst set state in your company/unit.", - company_name=company_unit_partner.name, - company_id=company_unit_partner.id + "State is missing from your company %(company_name)s (%(company_id)s).\nFirst set state in your company.", + company_name=move.company_id.name, + company_id=move.company_id.id )) elif move.journal_id.type == 'purchase': - move.l10n_in_state_id = company_unit_partner.state_id + 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']: @@ -76,11 +74,9 @@ class AccountMove(models.Model): )) 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 = 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 unit - if not move.l10n_in_state_id: - move.l10n_in_state_id = company_unit_partner.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/models/chart_template.py b/addons/l10n_in/models/chart_template.py index 0f7b9e7ab4f..f218bf66142 100644 --- a/addons/l10n_in/models/chart_template.py +++ b/addons/l10n_in/models/chart_template.py @@ -11,8 +11,6 @@ class AccountChartTemplate(models.Model): res = super(AccountChartTemplate, self)._prepare_all_journals(acc_template_ref, company, journals_dict=journals_dict) if self == self.env.ref('l10n_in.indian_chart_template_standard'): for journal in res: - if journal.get('type') in ('sale','purchase'): - journal['l10n_in_gstin_partner_id'] = company.partner_id.id if journal['code'] == 'INV': journal['name'] = _('Tax Invoices') return res diff --git a/addons/l10n_in/views/account_journal_views.xml b/addons/l10n_in/views/account_journal_views.xml index 3f857c1c2aa..b920f48e21f 100644 --- a/addons/l10n_in/views/account_journal_views.xml +++ b/addons/l10n_in/views/account_journal_views.xml @@ -11,9 +11,6 @@ {'invisible': ['|', '&', ('country_code', '!=', 'IN'), ('type', '!=', 'cash'), '&', ('country_code', '=', 'IN'), ('type', 'not in', ['bank', 'cash', 'sale', 'purchase'])]} - - - diff --git a/addons/l10n_in/views/report_template.xml b/addons/l10n_in/views/report_template.xml deleted file mode 100644 index 0725936671c..00000000000 --- a/addons/l10n_in/views/report_template.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/addons/l10n_in_purchase/models/__init__.py b/addons/l10n_in_purchase/models/__init__.py index 476326ad60b..76ec8c77e97 100644 --- a/addons/l10n_in_purchase/models/__init__.py +++ b/addons/l10n_in_purchase/models/__init__.py @@ -2,4 +2,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import purchase_order -from . import account_move diff --git a/addons/l10n_in_purchase/models/account_move.py b/addons/l10n_in_purchase/models/account_move.py index c3d6571d944..ed90ad0a892 100644 --- a/addons/l10n_in_purchase/models/account_move.py +++ b/addons/l10n_in_purchase/models/account_move.py @@ -11,8 +11,5 @@ class AccountMove(models.Model): def _onchange_purchase_auto_complete(self): purchase_order_id = self.purchase_vendor_bill_id.purchase_order_id or self.purchase_id if purchase_order_id and purchase_order_id.country_code == 'IN': - journal_id = self.purchase_vendor_bill_id.purchase_order_id.l10n_in_journal_id or self.purchase_id.l10n_in_journal_id - if journal_id: - self.journal_id = journal_id self.l10n_in_gst_treatment = purchase_order_id.l10n_in_gst_treatment return super()._onchange_purchase_auto_complete() diff --git a/addons/l10n_in_purchase/models/purchase_order.py b/addons/l10n_in_purchase/models/purchase_order.py index 96d784d8461..5e131817732 100644 --- a/addons/l10n_in_purchase/models/purchase_order.py +++ b/addons/l10n_in_purchase/models/purchase_order.py @@ -8,8 +8,6 @@ from odoo.addons.purchase.models.purchase import PurchaseOrder as Purchase class PurchaseOrder(models.Model): _inherit = "purchase.order" - l10n_in_journal_id = fields.Many2one('account.journal', string="Journal", \ - states=Purchase.READONLY_STATES, domain="[('type', '=', 'purchase')]") l10n_in_gst_treatment = fields.Selection([ ('regular', 'Registered Business - Regular'), ('composition', 'Registered Business - Composition'), @@ -21,14 +19,6 @@ class PurchaseOrder(models.Model): ('uin_holders', 'UIN Holders'), ], string="GST Treatment", states=Purchase.READONLY_STATES, compute="_compute_l10n_in_gst_treatment", store=True) - @api.onchange('company_id') - def l10n_in_onchange_company_id(self): - if self.country_code == 'IN': - domain = [('company_id', '=', self.company_id.id), ('type', '=', 'purchase')] - journal = self.env['account.journal'].search(domain, limit=1) - if journal: - self.l10n_in_journal_id = journal.id - @api.depends('partner_id') def _compute_l10n_in_gst_treatment(self): for order in self: diff --git a/addons/l10n_in_purchase/views/purchase_order_views.xml b/addons/l10n_in_purchase/views/purchase_order_views.xml index feb2fd82431..f2bbbbd960e 100644 --- a/addons/l10n_in_purchase/views/purchase_order_views.xml +++ b/addons/l10n_in_purchase/views/purchase_order_views.xml @@ -9,9 +9,6 @@ - - - diff --git a/addons/l10n_in_purchase_stock/__manifest__.py b/addons/l10n_in_purchase_stock/__manifest__.py index a9e2a8495d0..aeb3ca9228b 100644 --- a/addons/l10n_in_purchase_stock/__manifest__.py +++ b/addons/l10n_in_purchase_stock/__manifest__.py @@ -6,13 +6,12 @@ 'icon': '/l10n_in/static/description/icon.png', 'summary': """ - Define default purchase journal on the warehouse""", + Get warehouse address if the bill is created from Purchase Order""", 'description': """ - Define default purchase journal on the warehouse, - help you to choose correct purchase journal on the purchase order when - you change the picking operation. - useful when you setup the multiple GSTIN units. + Get the warehouse address if the bill is created from the Purchase Order + + So this module is to get the warehouse address if the bill is created from Purchase Order """, 'website': "https://www.odoo.com", @@ -21,9 +20,6 @@ 'depends': ['l10n_in_purchase', 'l10n_in_stock'], - 'data': [ - 'views/stock_warehouse_views.xml', - ], 'auto_install': True, 'license': 'LGPL-3', } diff --git a/addons/l10n_in_purchase_stock/models/__init__.py b/addons/l10n_in_purchase_stock/models/__init__.py index c076a07a574..c0124efe182 100644 --- a/addons/l10n_in_purchase_stock/models/__init__.py +++ b/addons/l10n_in_purchase_stock/models/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import purchase_order -from . import stock_warehouse from . import account_move diff --git a/addons/l10n_in_purchase_stock/models/purchase_order.py b/addons/l10n_in_purchase_stock/models/purchase_order.py deleted file mode 100644 index 3278769c2e5..00000000000 --- a/addons/l10n_in_purchase_stock/models/purchase_order.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models, fields, api - - -class PurchaseOrder(models.Model): - _inherit = "purchase.order" - - @api.onchange('company_id', 'picking_type_id') - def l10n_in_onchange_company_id(self): - if self.picking_type_id.warehouse_id and self.picking_type_id.warehouse_id.l10n_in_purchase_journal_id: - self.l10n_in_journal_id = self.picking_type_id.warehouse_id.l10n_in_purchase_journal_id.id - else: - super().l10n_in_onchange_company_id() diff --git a/addons/l10n_in_purchase_stock/models/stock_warehouse.py b/addons/l10n_in_purchase_stock/models/stock_warehouse.py deleted file mode 100644 index 5fa743e3f45..00000000000 --- a/addons/l10n_in_purchase_stock/models/stock_warehouse.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models, fields, api - - -class Stock(models.Model): - _inherit = 'stock.warehouse' - - l10n_in_purchase_journal_id = fields.Many2one('account.journal', string="Purchase Journal") diff --git a/addons/l10n_in_purchase_stock/views/stock_warehouse_views.xml b/addons/l10n_in_purchase_stock/views/stock_warehouse_views.xml deleted file mode 100644 index 69df7c9b1d9..00000000000 --- a/addons/l10n_in_purchase_stock/views/stock_warehouse_views.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - stock.warehouse.form.inherit.l10n.in.stock - stock.warehouse - - - - - - - - diff --git a/addons/l10n_in_sale/models/sale_order.py b/addons/l10n_in_sale/models/sale_order.py index 5edf559296d..02276e2b618 100644 --- a/addons/l10n_in_sale/models/sale_order.py +++ b/addons/l10n_in_sale/models/sale_order.py @@ -9,7 +9,6 @@ class SaleOrder(models.Model): l10n_in_reseller_partner_id = fields.Many2one('res.partner', string='Reseller', domain="[('vat', '!=', False), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}) - l10n_in_journal_id = fields.Many2one('account.journal', string="Journal", compute="_compute_l10n_in_journal_id", store=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}) l10n_in_gst_treatment = fields.Selection([ ('regular', 'Registered Business - Regular'), ('composition', 'Registered Business - Composition'), @@ -34,23 +33,9 @@ class SaleOrder(models.Model): l10n_in_gst_treatment = order.partner_id.vat and 'regular' or 'consumer' order.l10n_in_gst_treatment = l10n_in_gst_treatment - @api.depends('company_id') - def _compute_l10n_in_journal_id(self): - for order in self: - # set default value as False so CacheMiss error never occurs for this field. - order.l10n_in_journal_id = False - if order.country_code == 'IN': - domain = [('company_id', '=', order.company_id.id), ('type', '=', 'sale')] - journal = self.env['account.journal'].search(domain, limit=1) - if journal: - order.l10n_in_journal_id = journal.id - - def _prepare_invoice(self): invoice_vals = super(SaleOrder, self)._prepare_invoice() if self.country_code == 'IN': invoice_vals['l10n_in_reseller_partner_id'] = self.l10n_in_reseller_partner_id.id - if self.l10n_in_journal_id: - invoice_vals['journal_id'] = self.l10n_in_journal_id.id invoice_vals['l10n_in_gst_treatment'] = self.l10n_in_gst_treatment return invoice_vals diff --git a/addons/l10n_in_sale/views/sale_views.xml b/addons/l10n_in_sale/views/sale_views.xml index da8a83116f1..1ad477f0d74 100644 --- a/addons/l10n_in_sale/views/sale_views.xml +++ b/addons/l10n_in_sale/views/sale_views.xml @@ -12,9 +12,6 @@ - - - diff --git a/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py b/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py index f22ba445d1b..093c0f31a32 100644 --- a/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py +++ b/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py @@ -9,8 +9,6 @@ class SaleAdvancePaymentInv(models.TransientModel): def _prepare_invoice_values(self, order, so_line): res = super()._prepare_invoice_values(order, so_line) - if order.l10n_in_journal_id: - res['journal_id'] = order.l10n_in_journal_id.id if order.country_code == 'IN': res['l10n_in_gst_treatment'] = order.l10n_in_gst_treatment if order.l10n_in_reseller_partner_id: diff --git a/addons/l10n_in_sale_stock/__manifest__.py b/addons/l10n_in_sale_stock/__manifest__.py index 93a18727b4c..5633c26f83e 100644 --- a/addons/l10n_in_sale_stock/__manifest__.py +++ b/addons/l10n_in_sale_stock/__manifest__.py @@ -6,13 +6,13 @@ 'icon': '/l10n_in/static/description/icon.png', 'summary': """ - Define default sales journal on the warehouse""", + Get warehouse address if the invoice is created from Sale Order""", 'description': """ - Define default sales journal on the warehouse, - help you to choose correct sales journal on the sales order when - you change the warehouse. - useful when you setup the multiple GSTIN units. + Get the warehouse address if the invoice is created from the Sale Order + In Indian EDI we send shipping address details if available + + So this module is to get the warehouse address if the invoice is created from Sale Order """, 'website': "https://www.odoo.com", @@ -21,9 +21,6 @@ 'depends': ['l10n_in_sale', 'l10n_in_stock'], - 'data': [ - 'views/stock_warehouse_views.xml', - ], 'auto_install': True, 'license': 'LGPL-3', } diff --git a/addons/l10n_in_sale_stock/models/__init__.py b/addons/l10n_in_sale_stock/models/__init__.py index 6100d5bedb0..c0124efe182 100644 --- a/addons/l10n_in_sale_stock/models/__init__.py +++ b/addons/l10n_in_sale_stock/models/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import sale_order -from . import stock_warehouse from . import account_move diff --git a/addons/l10n_in_sale_stock/models/sale_order.py b/addons/l10n_in_sale_stock/models/sale_order.py deleted file mode 100644 index 34ba84e3bfe..00000000000 --- a/addons/l10n_in_sale_stock/models/sale_order.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models, fields, api - - -class SaleOrder(models.Model): - _inherit = "sale.order" - - @api.depends('company_id', 'warehouse_id') - def _compute_l10n_in_journal_id(self): - super()._compute_l10n_in_journal_id() - for order in self: - if order.country_code == 'IN': - if order.warehouse_id.l10n_in_sale_journal_id: - order.l10n_in_journal_id = order.warehouse_id.l10n_in_sale_journal_id.id diff --git a/addons/l10n_in_sale_stock/models/stock_warehouse.py b/addons/l10n_in_sale_stock/models/stock_warehouse.py deleted file mode 100644 index 190e0b2750d..00000000000 --- a/addons/l10n_in_sale_stock/models/stock_warehouse.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models, fields, api - - -class Stock(models.Model): - _inherit = 'stock.warehouse' - - l10n_in_sale_journal_id = fields.Many2one('account.journal', string="Sale Journal") diff --git a/addons/l10n_in_sale_stock/views/stock_warehouse_views.xml b/addons/l10n_in_sale_stock/views/stock_warehouse_views.xml deleted file mode 100644 index 0329dc01d2d..00000000000 --- a/addons/l10n_in_sale_stock/views/stock_warehouse_views.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - stock.warehouse.form.inherit.l10n.in.stock - stock.warehouse - - - - - - - -