diff --git a/addons/l10n_in_upi/__init__.py b/addons/l10n_in_upi/__init__.py new file mode 100644 index 00000000000..be9f4fab00a --- /dev/null +++ b/addons/l10n_in_upi/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import models diff --git a/addons/l10n_in_upi/__manifest__.py b/addons/l10n_in_upi/__manifest__.py new file mode 100644 index 00000000000..7c6d6ec73ae --- /dev/null +++ b/addons/l10n_in_upi/__manifest__.py @@ -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, +} diff --git a/addons/l10n_in_upi/models/__init__.py b/addons/l10n_in_upi/models/__init__.py new file mode 100644 index 00000000000..1bd4ba68797 --- /dev/null +++ b/addons/l10n_in_upi/models/__init__.py @@ -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 diff --git a/addons/l10n_in_upi/models/account_invoice.py b/addons/l10n_in_upi/models/account_invoice.py new file mode 100644 index 00000000000..d7ffab93a17 --- /dev/null +++ b/addons/l10n_in_upi/models/account_invoice.py @@ -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() diff --git a/addons/l10n_in_upi/models/res_company.py b/addons/l10n_in_upi/models/res_company.py new file mode 100644 index 00000000000..9adfe1f1ed8 --- /dev/null +++ b/addons/l10n_in_upi/models/res_company.py @@ -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") diff --git a/addons/l10n_in_upi/views/res_company_views.xml b/addons/l10n_in_upi/views/res_company_views.xml new file mode 100644 index 00000000000..3a317fb47b1 --- /dev/null +++ b/addons/l10n_in_upi/views/res_company_views.xml @@ -0,0 +1,13 @@ + + + + res.company.form.inherit.l10n_in_upi + res.company + + + + + + + +