[ADD] l10n_in: merge l10n_in_upi l10n_in
merge l10n_in_upi into l10n_in closes odoo/odoo#111299 Related: odoo/upgrade#4272 Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
@@ -37,6 +37,7 @@ Sheet, now only Vertical format has been permitted Which is Supported By Odoo.
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/product_template_view.xml',
|
||||
'views/port_code_views.xml',
|
||||
'views/res_company_views.xml',
|
||||
'views/report_invoice.xml',
|
||||
'views/res_country_state_view.xml',
|
||||
'views/res_partner_views.xml',
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import base64
|
||||
import logging
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError, RedirectWarning, UserError
|
||||
from odoo.tools.image import image_data_uri
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -122,3 +123,16 @@ class AccountMove(models.Model):
|
||||
if logger_msg:
|
||||
_logger.info(logger_msg)
|
||||
return res
|
||||
|
||||
def _generate_qr_code(self, silent_errors=False):
|
||||
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(silent_errors)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from odoo import api, models
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
l10n_in_upi_id = fields.Char(string="UPI Id")
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
companies = super().create(vals_list)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import models
|
||||
@@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': 'Indian - UPI',
|
||||
'countries': ['in'],
|
||||
'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,
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import account_invoice
|
||||
from . import res_company
|
||||
@@ -1,23 +0,0 @@
|
||||
# -*- 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, silent_errors=False):
|
||||
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(silent_errors)
|
||||
@@ -1,10 +0,0 @@
|
||||
# -*- 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")
|
||||
Reference in New Issue
Block a user