[IMP] l10n_in{_edi}: improvements in UX

In this commit, the following points are covered

- updated error messages
- remove renaming the `Customer Invoices` journal name
- updated Fiscal Opening Date and Year End for Indian localization
- updated Indian E-Invoicing report and settings setup

Part-of: odoo/odoo#109396
This commit is contained in:
bat-odoo
2023-01-12 11:09:23 +01:00
parent 3a6cdf5110
commit 7269e6a0c4
8 changed files with 112 additions and 52 deletions
+11 -6
View File
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
from odoo.exceptions import ValidationError, RedirectWarning
class AccountMove(models.Model):
@@ -56,11 +56,16 @@ class AccountMove(models.Model):
self._fields['l10n_in_gst_treatment']._description_selection(self.env)}
for move in posted.filtered(lambda m: m.country_code == 'IN'):
if not move.company_id.state_id:
raise ValidationError(_(
"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
))
msg = _("Your company %s needs to have a correct address in order to validate this invoice.\n"
"Set the address of your company (Don't forget the State field)") % (move.company_id.name)
action = {
"view_mode": "form",
"res_model": "res.company",
"type": "ir.actions.act_window",
"res_id" : move.company_id.id,
"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
+5 -9
View File
@@ -7,18 +7,14 @@ from odoo import api, fields, models, _
class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
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['code'] == 'INV':
journal['name'] = _('Tax Invoices')
return res
def _load(self, company):
""" Set Opening Date and Fiscal Year End in Indian localization"""
res = super(AccountChartTemplate, self)._load(company)
if self == self.env.ref("l10n_in.indian_chart_template_standard"):
company.write({'fiscalyear_last_month': '3'})
company.write({
'account_opening_date': fields.Date.context_today(self).replace(month=4, day=1),
'fiscalyear_last_month': '3',
})
return res
@@ -8,3 +8,4 @@ class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
group_l10n_in_reseller = fields.Boolean(implied_group='l10n_in.group_l10n_in_reseller', string="Manage Reseller(E-Commerce)")
module_l10n_in_edi = fields.Boolean('Indian Electronic Invoicing')
@@ -9,6 +9,9 @@
<setting help="Use this if setup with Reseller(E-Commerce)." name="ecommerce_reseller_setting" title="Manage Reseller(E-Commerce)" attrs="{'invisible': [('country_code', '!=', 'IN')]}">
<field name="group_l10n_in_reseller"/>
</setting>
<setting help="Connect to NIC (National Informatics Center) to submit invoices on posting." name="electronic_invoices_in" attrs="{'invisible': [('country_code', '!=', 'IN')]}" documentation="/applications/finance/accounting/fiscal_localizations/localizations/india.html">
<field name="module_l10n_in_edi" class="oe_inline" widget="upgrade_boolean"/>
</setting>
</block>
</field>
</record>
@@ -594,10 +594,10 @@ class AccountEdiFormat(models.Model):
@api.model
def _l10n_in_edi_no_config_response(self):
return {'error': [{
'code': '000',
'code': '0',
'message': _(
"A username and password still needs to be set or it's wrong for the E-invoice(IN). "
"It needs to be added and verify in the Settings."
"Unable to send e-Invoice."
"Create an API user in NIC portal, and set it using the top menu: Configuration > Settings."
)}
]}
@@ -19,4 +19,4 @@ class ResConfigSettings(models.TransientModel):
def l10n_in_edi_test(self):
self.env["account.edi.format"]._l10n_in_edi_authenticate(self.company_id)
if not self.company_id.sudo()._l10n_in_edi_token_is_valid():
raise UserError(_("Username/password are incorrect."))
raise UserError(_("Incorrect username or password, or the GST number on company does not match."))
+67 -20
View File
@@ -1,31 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="l10n_in_einvoice_report_invoice_document_inherit" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='informations']" position="before">
<t t-set="l10n_in_einvoice_json" t-value="o._get_l10n_in_edi_response_json()"/>
<div id="l10n_in_einvoice_informations_inr" class="row mt-4 mb-4">
<div class="col-auto col-3 mw-100 mb-2" t-if="l10n_in_einvoice_json" name="irn">
<strong>IRN:</strong>
<p class="m-0" t-out="l10n_in_einvoice_json['Irn']"/>
<template id="external_layout_standard_inherit_l10n_in_edi" inherit_id="web.external_layout_standard">
<div name="company_address" position="inside">
<span style="font-size: 10px;" t-if="l10n_in_einvoice_json">IRN:<span t-esc="l10n_in_einvoice_json['Irn']"/></span>
</div>
<div name="company_address" position="after">
<div class="col-6 mt-1" t-if="l10n_in_einvoice_json">
<div class="text-center">
<img t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %
('QR', l10n_in_einvoice_json['SignedQRCode'], 150, 150)"/>
</div>
</div>
<div id="l10n_in_einvoice_informations_other" class="row mt-4 mb-4">
<div class="col-auto col-3 mw-100 mb-2" t-if="l10n_in_einvoice_json" name="ack_no">
<strong>Ack. No:</strong>
<p class="m-0" t-out="l10n_in_einvoice_json['AckNo']"/>
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="l10n_in_einvoice_json" name="ack_date">
<strong>Ack. Date:</strong>
<p class="m-0" t-out="l10n_in_einvoice_json['AckDt']"/>
</div>
</template>
<template id="external_layout_boxed_inherit_l10n_in_edi" inherit_id="web.external_layout_boxed">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" position="after">
<div class="mt-5" t-if="l10n_in_einvoice_json">
<span style="font-size: 10px;">IRN:<span t-esc="l10n_in_einvoice_json['Irn']"/></span>
</div>
</img>
<div class="col-6 text-end mb4" position="before">
<div class="col-3" t-if="l10n_in_einvoice_json">
<div class="text-center">
<img t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %
('QR', l10n_in_einvoice_json['SignedQRCode'], 150, 150)"/>
</div>
</div>
</div>
<div class="col-6 text-end mb4" position="attributes">
<attribute name="class">col-3 text-end mb4</attribute>
</div>
</template>
<template id="external_layout_bold_inherit_l10n_in_edi" inherit_id="web.external_layout_bold">
<img t-if="company.logo" position="after">
<strong style="font-size: 10px;" t-if="l10n_in_einvoice_json">IRN:<span t-esc="l10n_in_einvoice_json['Irn']"/></strong>
</img>
<xpath expr="//div[hasclass('row')]/div[hasclass('col-6')]" position="after">
<div class="col-2 text-end" t-if="l10n_in_einvoice_json">
<img class="m-2" t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %
('QR', l10n_in_einvoice_json['SignedQRCode'], 150, 150)"/>
</div>
</xpath>
<xpath expr="//div[@id='qrcode']" position="after">
<p t-if="l10n_in_einvoice_json">
<strong class="text-center">Scan me with E-invoice app.</strong><br/><br/>
<xpath expr="//div[hasclass('row')]/div[hasclass('col-6')]" position="attributes">
<attribute name="class">col-5</attribute>
</xpath>
<xpath expr="//div[@name='company_address']" position="attributes">
<attribute name="class">col-4</attribute>
</xpath>
</template>
<template id="external_layout_striped_inherit_l10n_in_edi" inherit_id="web.external_layout_striped">
<xpath expr="//div[hasclass('company_address')]" position="after">
<div class="text-end" t-if="l10n_in_einvoice_json">
<img t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %
('QR', l10n_in_einvoice_json['SignedQRCode'], 200, 200)"/>
</p>
('QR', l10n_in_einvoice_json['SignedQRCode'], 150, 150)"/><br/>
<span style="font-size: 10px;">IRN:<span t-esc="l10n_in_einvoice_json['Irn']"/></span>
</div>
</xpath>
</template>
<template id="l10n_in_einvoice_report_invoice_document_inherit" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='informations']" position="inside">
<t t-set="l10n_in_einvoice_json" t-value="o._get_l10n_in_edi_response_json()"/>
<div class="col-auto col-3 mw-100 mb-2" t-if="l10n_in_einvoice_json" name="ack_no">
<strong>Ack. No:</strong>
<p class="m-0" t-out="l10n_in_einvoice_json['AckNo']"/>
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="l10n_in_einvoice_json" name="ack_date">
<strong>Ack. Date:</strong>
<p class="m-0" t-out="l10n_in_einvoice_json['AckDt']"/>
</div>
</xpath>
</template>
</odoo>
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_l10n_in_inherit_l10n_in_edi" model="ir.ui.view">
<field name="name">res.config.settings.form.l10n_in.inherit.l10n_in_edi</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="l10n_in.res_config_settings_view_form_inherit_l10n_in"/>
<field name="arch" type="xml">
<setting name="electronic_invoices_in" position="replace"/>
</field>
</record>
<record id="res_config_settings_view_form_inherit_l10n_in_edi" model="ir.ui.view">
<field name="name">res.config.settings.form.inherit.l10n_in_edi</field>
<field name="model">res.config.settings</field>
@@ -7,20 +16,19 @@
<field name="arch" type="xml">
<app name="account" position="inside">
<block title="Indian Electronic Invoicing" name="l10n_in_edi_iap" attrs="{'invisible': [('country_code', '!=', 'IN')]}">
<setting id="gsp_setting" string="Setup E-invoice" help="Setup E-invoice Service for this company" company_dependent="1">
<div class="content-group">
<div class="mt16 row">
<label for="l10n_in_edi_username" string="Username" class="col-3 col-lg-3 o_light_label"/>
<field name="l10n_in_edi_username" nolabel="1"/>
<label for="l10n_in_edi_password" string="Password" class="col-3 col-lg-3 o_light_label" />
<field name="l10n_in_edi_password" password="True" nolabel="1"/>
<label for="l10n_in_edi_production_env" string="Production Environment" class="col-3 col-lg-3 o_light_label"/>
<field name="l10n_in_edi_production_env" nolabel="1"/>
<div class="text-muted">
Only check if you are in production.
</div>
<setting id="gsp_setting" string="Setup E-invoice" help="Check the documentation to get credentials" documentation="/applications/finance/accounting/fiscal_localizations/localizations/india.html" company_dependent="1">
<div class="content-group mt16">
<label for="l10n_in_edi_username" string="Username" class="col-lg-3 o_light_label"/>
<field name="l10n_in_edi_username" nolabel="1"/>
</div>
<div class="content-group">
<label for="l10n_in_edi_password" string="Password" class="col-lg-3 o_light_label" />
<field name="l10n_in_edi_password" password="True" nolabel="1"/>
</div>
<div class="content-group">
<label for="l10n_in_edi_production_env" string="Production Environment" class="col-lg-3 o_light_label"/>
<field name="l10n_in_edi_production_env" nolabel="1"/>
</div>
</div>
<div class='mt8'>
<button name="l10n_in_edi_test" icon="fa-arrow-right" type="object" string="Verify Username and Password" class="btn-link"/>
</div>