[ADD] l10n_in_upi: added qr code for upi payment in invoice report

Currently, there is no facility for UPI payment for the invoice.

So in this commit, there will be a QR code for UPI payment in the invoice report.

closes odoo/odoo#109237

X-original-commit: e8e75678ee64fd9e4150ab7c9a9836d69b06c4db
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Jigar Vaghela (jva) <jva@odoo.com>
This commit is contained in:
Nishant Jain (niai)
2023-01-06 05:48:11 +01:00
parent 8bac2f8136
commit 0f55e6a773
6 changed files with 71 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+18
View File
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Indian - UPI',
'version': '1.0',
'description': """
Invoice with UPI QR code
=========================
This module adds QR code in invoice report for UPI payment allowing to make payment via any UPI app.
To print UPI Qr code add UPI id in company and tick "QR Codes" in configuration
""",
'category': 'Accounting/Localizations',
'depends': ['l10n_in'],
'data': ['views/res_company_views.xml'],
'license': 'LGPL-3',
'auto_install': True,
}
+4
View File
@@ -0,0 +1,4 @@
# -*- coding:utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_invoice
from . import res_company
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base64
from odoo import models
from odoo.tools.image import image_data_uri
class AccountMove(models.Model):
_inherit = "account.move"
def generate_qr_code(self):
self.ensure_one()
if self.company_id.country_code == 'IN':
payment_url = 'upi://pay?pa=%s&pn=%s&am=%s&tr=%s&tn=%s' % (
self.company_id.l10n_in_upi_id,
self.company_id.name,
self.amount_residual,
self.payment_reference or self.name,
("Payment for %s" % self.name))
barcode = self.env['ir.actions.report'].barcode(barcode_type="QR", value=payment_url, width=120, height=120)
return image_data_uri(base64.b64encode(barcode))
return super().generate_qr_code()
+10
View File
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class Company(models.Model):
_inherit = 'res.company'
l10n_in_upi_id = fields.Char(string="UPI Id")
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_company_form" model="ir.ui.view">
<field name="name">res.company.form.inherit.l10n_in_upi</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='currency_id']" position="after">
<field name="l10n_in_upi_id" attrs="{'invisible': [('country_code', '!=', 'IN')]}"/>
</xpath>
</field>
</record>
</odoo>