GST Treatment: * Is show that how This invoice or partner is treated in GST * Set default value in customer * This is help in GST retrun filing. * Value of treamtmnet as below - Registered Business - Regular - Registered Business - Composition - Unregistered Business - Consumer - Overseas - Special Economic Zone - Deemed Export * GSTIN is required in - Registered Business - Regular - Registered Business - Composition - Special Economic Zone - Deemed Export GSTIN: * GST identification number or GST number * There can be multiple GSTIN for a single person, being an assessee under the Income Tax Act for every State or Union Territory in which such person operates from * Add Validate of this number using regular expression remove field l10n_in_export_type and l10n_in_import_export becouse it's covered by GST Treatment remove field l10n_in_partner_vat becouse not use anyware.
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
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.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"
|
|
|
|
@api.depends('move_id.line_ids', 'move_id.line_ids.tax_line_id', 'move_id.line_ids.debit', 'move_id.line_ids.credit')
|
|
def _compute_tax_base_amount(self):
|
|
aml = self.filtered(lambda l: l.company_id.country_id.code == 'IN' and l.tax_line_id and l.product_id)
|
|
for move_line in aml:
|
|
base_lines = move_line.move_id.line_ids.filtered(lambda line: move_line.tax_line_id in line.tax_ids and move_line.product_id == line.product_id)
|
|
move_line.tax_base_amount = abs(sum(base_lines.mapped('balance')))
|
|
remaining_aml = self - aml
|
|
if remaining_aml:
|
|
return super(AccountMoveLine, remaining_aml)._compute_tax_base_amount()
|
|
|
|
|
|
class AccountTax(models.Model):
|
|
_inherit = 'account.tax'
|
|
|
|
l10n_in_reverse_charge = fields.Boolean("Reverse charge", help="Tick this if this tax is reverse charge. Only for Indian accounting")
|
|
|
|
def get_grouping_key(self, invoice_tax_val):
|
|
""" Returns a string that will be used to group account.invoice.tax sharing the same properties"""
|
|
key = super(AccountTax, self).get_grouping_key(invoice_tax_val)
|
|
if self.company_id.country_id.code == 'IN':
|
|
key += "-%s-%s"% (invoice_tax_val.get('l10n_in_product_id', False),
|
|
invoice_tax_val.get('l10n_in_uom_id', False))
|
|
return key
|