[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 <jco@odoo.com>
This commit is contained in:
@@ -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': [
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
<field name='loss_account_id' position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|', '&', ('country_code', '!=', 'IN'), ('type', '!=', 'cash'), '&', ('country_code', '=', 'IN'), ('type', 'not in', ['bank', 'cash', 'sale', 'purchase'])]}</attribute>
|
||||
</field>
|
||||
<field name="company_id" position="after">
|
||||
<field name="l10n_in_gstin_partner_id" context="{'show_vat':True}" options='{"no_create": True,"always_reload": True}' attrs="{'invisible': [('country_code', '!=', 'IN')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- get vat from journal_id for all layout -->
|
||||
<template id="l10n_in_external_layout" inherit_id="web.external_layout">
|
||||
<xpath expr="//t[@t-if='company.external_report_layout_id']" position="before">
|
||||
<t t-if="o and 'journal_id' in o and company.country_id.code == 'IN' and o.journal_id.l10n_in_gstin_partner_id.vat">
|
||||
<t t-set="forced_vat" t-value="o.journal_id.l10n_in_gstin_partner_id.vat"/>
|
||||
</t>
|
||||
<t t-elif="o and 'l10n_in_journal_id' in o and company.country_id.code == 'IN' and o.l10n_in_journal_id.l10n_in_gstin_partner_id.vat">
|
||||
<t t-set="forced_vat" t-value="o.l10n_in_journal_id.l10n_in_gstin_partner_id.vat"/>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -2,4 +2,3 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import purchase_order
|
||||
from . import account_move
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
<field name="country_code" invisible="1"/>
|
||||
<field name="l10n_in_gst_treatment" attrs="{'invisible': [('country_code', '!=', 'IN')], 'required': [('country_code', '=', 'IN')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='other_info']//field[@name='user_id']" position="after">
|
||||
<field name="l10n_in_journal_id" options="{'no_create': True}" domain="[('company_id', '=', company_id), ('type', '=', 'purchase')]" attrs="{'invisible': [('country_code', '!=', 'IN')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
@@ -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")
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_stock_warehouse_inherit_l10n_in_stock" model="ir.ui.view">
|
||||
<field name="name">stock.warehouse.form.inherit.l10n.in.stock</field>
|
||||
<field name="model">stock.warehouse</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="l10n_in_purchase_journal_id" domain="[('company_id', '=', company_id), ('type','=','purchase')]" options="{'no_create': True}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -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
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
<field name="l10n_in_gst_treatment"
|
||||
attrs="{'invisible':[('country_code','!=','IN')],'required':[('country_code','=','IN')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='sale_info']//field[@name='invoice_status']" position="after">
|
||||
<field name="l10n_in_journal_id" domain="[('company_id', '=', company_id), ('type','=','sale')]" options="{'no_create': True}" attrs="{'invisible': [('country_code','!=', 'IN')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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")
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_stock_warehouse_inherit_l10n_in_stock" model="ir.ui.view">
|
||||
<field name="name">stock.warehouse.form.inherit.l10n.in.stock</field>
|
||||
<field name="model">stock.warehouse</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="l10n_in_sale_journal_id" domain="[('company_id', '=', company_id), ('type','=','sale')]" options="{'no_create': True}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user