From 534167bf96af6dab0a5ed5e1f887eff1bb680f6e Mon Sep 17 00:00:00 2001 From: Jigar Vaghela Date: Mon, 10 Jan 2022 11:55:54 +0000 Subject: [PATCH] [IMP] l10n_in: update demo data, add tax report line and method to get warehouse address add get warehouse address method needed in Indian EDI to pass value of dispatched address improve demo data and bypass one GST number from validation because that GST number use to test EDI Add Non GST Supplies and State CESS tax report line Non-GST Supplies and State CESS is required to get related value from the invoice for send EDI Part-of: odoo/odoo#79995 --- .../l10n_in/data/account_tax_group_data.xml | 4 ++ .../data/account_tax_template_data.xml | 44 ++++++++++++++ addons/l10n_in/demo/account_invoice_demo.xml | 58 ++++++++++++++++++- addons/l10n_in/demo/demo_company.xml | 11 ++-- addons/l10n_in/demo/res_partner_demo.xml | 18 +++++- addons/l10n_in/models/account_invoice.py | 10 +++- addons/l10n_in/models/res_partner.py | 11 ++++ .../l10n_in_purchase_stock/models/__init__.py | 1 + .../models/account_move.py | 18 ++++++ addons/l10n_in_sale_stock/models/__init__.py | 1 + .../l10n_in_sale_stock/models/account_move.py | 16 +++++ 11 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 addons/l10n_in_purchase_stock/models/account_move.py create mode 100644 addons/l10n_in_sale_stock/models/account_move.py diff --git a/addons/l10n_in/data/account_tax_group_data.xml b/addons/l10n_in/data/account_tax_group_data.xml index 73111e9f77f..43c56ffe981 100644 --- a/addons/l10n_in/data/account_tax_group_data.xml +++ b/addons/l10n_in/data/account_tax_group_data.xml @@ -29,5 +29,9 @@ Nil Rated + + Non GST Supplies + + diff --git a/addons/l10n_in/data/account_tax_template_data.xml b/addons/l10n_in/data/account_tax_template_data.xml index 01d2e315fd6..a74756367b8 100644 --- a/addons/l10n_in/data/account_tax_template_data.xml +++ b/addons/l10n_in/data/account_tax_template_data.xml @@ -75,6 +75,17 @@ Zero Rated 7 + + Non GST Supplies + Non GST Supplies + 8 + + + + State CESS + State CESS + 9 + @@ -147,6 +158,39 @@ if tax > result:result=tax + + + Non GST Supplies + Non GST Supplies + sale + percent + 0 + + + + + + IGST 0% IGST 0% diff --git a/addons/l10n_in/demo/account_invoice_demo.xml b/addons/l10n_in/demo/account_invoice_demo.xml index eddd07d6459..1523ca1e6ed 100644 --- a/addons/l10n_in/demo/account_invoice_demo.xml +++ b/addons/l10n_in/demo/account_invoice_demo.xml @@ -11,9 +11,61 @@ regular + eval="obj().search([ + ('type', '=', 'sale'), + ('company_id', '=', ref('l10n_in.demo_company_in'))], limit=1).id"/> + + + + + out_invoice + + + + + + regular + IN Company - - A - Kannamangala + 36AABCT1332L011 + Block no. 401 + Street 2 + Hyderabad - - 56066 + + 500001 +91 81234 56789 info@company.inexample.com www.inexample.com diff --git a/addons/l10n_in/demo/res_partner_demo.xml b/addons/l10n_in/demo/res_partner_demo.xml index 3562e34824d..40d85295b2e 100644 --- a/addons/l10n_in/demo/res_partner_demo.xml +++ b/addons/l10n_in/demo/res_partner_demo.xml @@ -25,7 +25,21 @@ 382007 - 12GEOPS0823BBZH + 24AACCT6304M1ZB + + + + Registered Customer Intra State + + 1 + regular + floor-1, Maddikunta-Ankanpally Village + Post box No 2, NH-65 + Sangareddy + 500002 + + + 36AAACM4154G1ZO @@ -65,7 +79,7 @@ 382007 - 12GEOPS0823BBZ1 + 24GEOPS0823BBZ1 diff --git a/addons/l10n_in/models/account_invoice.py b/addons/l10n_in/models/account_invoice.py index 1260d5b740d..90e03b53d63 100644 --- a/addons/l10n_in/models/account_invoice.py +++ b/addons/l10n_in/models/account_invoice.py @@ -17,13 +17,13 @@ class AccountMove(models.Model): ('overseas', 'Overseas'), ('special_economic_zone', 'Special Economic Zone'), ('deemed_export', 'Deemed Export') - ], string="GST Treatment", compute="_compute_l10n_in_gst_treatment", store=True, readonly=False) + ], 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_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)]}) l10n_in_shipping_bill_date = fields.Date('Shipping bill date', readonly=True, states={'draft': [('readonly', False)]}) - l10n_in_shipping_port_code_id = fields.Many2one('l10n_in.port.code', 'Port code', states={'draft': [('readonly', False)]}) + l10n_in_shipping_port_code_id = fields.Many2one('l10n_in.port.code', 'Port code', readonly=True, states={'draft': [('readonly', False)]}) l10n_in_reseller_partner_id = fields.Many2one('res.partner', 'Reseller', domain=[('vat', '!=', False)], help="Only Registered Reseller", readonly=True, states={'draft': [('readonly', False)]}) @api.depends('amount_total') @@ -94,3 +94,9 @@ class AccountMove(models.Model): if not move.l10n_in_state_id: move.l10n_in_state_id = company_unit_partner.state_id return posted + + def _l10n_in_get_warehouse_address(self): + """Return address where goods are delivered/received for Invoice/Bill""" + # TO OVERRIDE + self.ensure_one() + return False diff --git a/addons/l10n_in/models/res_partner.py b/addons/l10n_in/models/res_partner.py index f14e39536a3..4860e528f89 100644 --- a/addons/l10n_in/models/res_partner.py +++ b/addons/l10n_in/models/res_partner.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, _ +TEST_GST_NUMBER = "36AABCT1332L011" class ResPartner(models.Model): _inherit = 'res.partner' @@ -44,3 +45,13 @@ class ResPartner(models.Model): def _commercial_fields(self): res = super()._commercial_fields() return res + ['l10n_in_gst_treatment'] + + def check_vat_in(self, vat): + """ + This TEST_GST_NUMBER is used as test credentials for EDI + but this is not a valid number as per the regular expression + so TEST_GST_NUMBER is considered always valid + """ + if vat == TEST_GST_NUMBER: + return True + return super().check_vat_in(vat) diff --git a/addons/l10n_in_purchase_stock/models/__init__.py b/addons/l10n_in_purchase_stock/models/__init__.py index b1a8586e9e1..c076a07a574 100644 --- a/addons/l10n_in_purchase_stock/models/__init__.py +++ b/addons/l10n_in_purchase_stock/models/__init__.py @@ -3,3 +3,4 @@ from . import purchase_order from . import stock_warehouse +from . import account_move diff --git a/addons/l10n_in_purchase_stock/models/account_move.py b/addons/l10n_in_purchase_stock/models/account_move.py new file mode 100644 index 00000000000..ea377c95af5 --- /dev/null +++ b/addons/l10n_in_purchase_stock/models/account_move.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _l10n_in_get_warehouse_address(self): + res = super()._l10n_in_get_warehouse_address() + if self.invoice_line_ids.purchase_line_id: + company_shipping_id = self.mapped( + "invoice_line_ids.purchase_line_id.move_ids.warehouse_id.partner_id" + ) + if len(company_shipping_id) == 1: + return company_shipping_id + return res diff --git a/addons/l10n_in_sale_stock/models/__init__.py b/addons/l10n_in_sale_stock/models/__init__.py index fcfd6a142db..6100d5bedb0 100644 --- a/addons/l10n_in_sale_stock/models/__init__.py +++ b/addons/l10n_in_sale_stock/models/__init__.py @@ -3,3 +3,4 @@ from . import sale_order from . import stock_warehouse +from . import account_move diff --git a/addons/l10n_in_sale_stock/models/account_move.py b/addons/l10n_in_sale_stock/models/account_move.py new file mode 100644 index 00000000000..af510725e71 --- /dev/null +++ b/addons/l10n_in_sale_stock/models/account_move.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _l10n_in_get_warehouse_address(self): + res = super()._l10n_in_get_warehouse_address() + if self.invoice_line_ids.sale_line_ids: + company_shipping_id = self.mapped("invoice_line_ids.sale_line_ids.order_id.warehouse_id.partner_id") + if len(company_shipping_id) == 1: + return company_shipping_id + return res