diff --git a/pos_qr_payments/README.rst b/pos_qr_payments/README.rst new file mode 100644 index 0000000000..b04ec0137b --- /dev/null +++ b/pos_qr_payments/README.rst @@ -0,0 +1,33 @@ +.. image:: https://itpp.dev/images/infinity-readme.png + :alt: Tested and maintained by IT Projects Labs + :target: https://itpp.dev + +.. image:: https://img.shields.io/badge/license-MIT-blue.svg + :target: https://opensource.org/licenses/MIT + :alt: License: MIT + +========================== + QR-based payments in POS +========================== + +Technical module to support qr-based payments like Alipay, WeChat + +Questions? +========== + +To get an assistance on this module contact us by email :arrow_right: help@itpp.dev + +Contributors +============ +* `Ivan Yelizariev `__ + + +Further information +=================== + +Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/pos_qr_payments/ + + +Notifications on updates: `via Atom `_, `by Email `_ + +Tested on `Odoo 11.0 `_ diff --git a/pos_qr_payments/__init__.py b/pos_qr_payments/__init__.py new file mode 100644 index 0000000000..d7c7b9400f --- /dev/null +++ b/pos_qr_payments/__init__.py @@ -0,0 +1,3 @@ +# License MIT (https://opensource.org/licenses/MIT). +from . import models +from . import wizard diff --git a/pos_qr_payments/__manifest__.py b/pos_qr_payments/__manifest__.py new file mode 100644 index 0000000000..e10ce57abf --- /dev/null +++ b/pos_qr_payments/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2018 Ivan Yelizariev +# License MIT (https://opensource.org/licenses/MIT). +{ + "name": """QR-based payments in POS""", + "summary": """Technical module to support qr-based payments like Alipay, WeChat""", + "category": "Hidden", + "images": [], + "version": "14.0.1.0.1", + "application": False, + "author": "IT-Projects LLC, Ivan Yelizariev", + "support": "help@itpp.dev", + "website": "https://github.com/itpp-labs/pos-addons#readme", + "license": "Other OSI approved licence", # MIT + "depends": ["point_of_sale"], + "external_dependencies": {"python": [], "bin": []}, + "data": ["wizard/pos_payment_views.xml", "views/assets.xml"], + "demo": [], + "qweb": [], + "post_load": None, + "pre_init_hook": None, + "post_init_hook": None, + "uninstall_hook": None, + "auto_install": False, + "installable": True, +} diff --git a/pos_qr_payments/doc/changelog.rst b/pos_qr_payments/doc/changelog.rst new file mode 100644 index 0000000000..a1f08e15ad --- /dev/null +++ b/pos_qr_payments/doc/changelog.rst @@ -0,0 +1,9 @@ +`1.0.1` +------- + +- **FIX** - Error related to pos reference in different translations + +`1.0.0` +------- + +- **Init version** diff --git a/pos_qr_payments/doc/index.rst b/pos_qr_payments/doc/index.rst new file mode 100644 index 0000000000..92f2520b78 --- /dev/null +++ b/pos_qr_payments/doc/index.rst @@ -0,0 +1,5 @@ +========================== + QR-based payments in POS +========================== + +The module cannot be used alone. Try to install, for example, `pos_wechat `__. diff --git a/pos_qr_payments/i18n/pos_qr_payments.pot b/pos_qr_payments/i18n/pos_qr_payments.pot new file mode 100644 index 0000000000..de7ce6717b --- /dev/null +++ b/pos_qr_payments/i18n/pos_qr_payments.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_qr_payments +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_qr_payments +#: model:ir.model.fields,field_description:pos_qr_payments.field_pos_make_payment__order_ref +msgid "Order Ref" +msgstr "" + +#. module: pos_qr_payments +#: model:ir.model.fields,field_description:pos_qr_payments.field_pos_order__pos_reference_uid +msgid "Order UID" +msgstr "" + +#. module: pos_qr_payments +#: model:ir.model,name:pos_qr_payments.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: pos_qr_payments +#: model:ir.model,name:pos_qr_payments.model_pos_make_payment +msgid "Point of Sale Payment" +msgstr "" + +#. module: pos_qr_payments +#. openerp-web +#: code:addons/pos_qr_payments/static/src/js/pos_qr_payments.js:30 +#, python-format +msgid "Warning" +msgstr "" + diff --git a/pos_qr_payments/models/__init__.py b/pos_qr_payments/models/__init__.py new file mode 100644 index 0000000000..8e9c9c4c75 --- /dev/null +++ b/pos_qr_payments/models/__init__.py @@ -0,0 +1,2 @@ +# License MIT (https://opensource.org/licenses/MIT). +from . import pos_order diff --git a/pos_qr_payments/models/pos_order.py b/pos_qr_payments/models/pos_order.py new file mode 100644 index 0000000000..374328328a --- /dev/null +++ b/pos_qr_payments/models/pos_order.py @@ -0,0 +1,22 @@ +# Copyright 2018 Ivan Yelizariev +# Copyright 2018 Kolushov Alexandr +# License MIT (https://opensource.org/licenses/MIT). +import re + +from odoo import api, fields, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + pos_reference_uid = fields.Char( + string="Order UID", compute="_compute_pos_reference_uid" + ) + + @api.depends("pos_reference") + def _compute_pos_reference_uid(self): + for r in self: + reference = r.pos_reference and re.search( + r"\d{1,}-\d{1,}-\d{1,}", r.pos_reference + ) + r.pos_reference_uid = reference and reference.group(0) or "" diff --git a/pos_qr_payments/static/description/icon.png b/pos_qr_payments/static/description/icon.png new file mode 100644 index 0000000000..8a058284ed Binary files /dev/null and b/pos_qr_payments/static/description/icon.png differ diff --git a/pos_qr_payments/static/description/index.html b/pos_qr_payments/static/description/index.html new file mode 100644 index 0000000000..a2da51f247 --- /dev/null +++ b/pos_qr_payments/static/description/index.html @@ -0,0 +1,61 @@ +
+
+
+

QR-based payments in POS

+

Technical module to support qr-based payments like Alipay, WeChat

+
+
+
+ +
+
+
+

Need our service?

+

Contact us by email or fill out request form

+ +
+
+
+
+ Tested on Odoo
12.0 community +
+ +
+
+
+
diff --git a/pos_qr_payments/static/src/js/pos_qr_payments.js b/pos_qr_payments/static/src/js/pos_qr_payments.js new file mode 100644 index 0000000000..992af573da --- /dev/null +++ b/pos_qr_payments/static/src/js/pos_qr_payments.js @@ -0,0 +1,80 @@ +/* Copyright 2018 Ivan Yelizariev + License MIT (https://opensource.org/licenses/MIT). */ +odoo.define("pos_qr_payments", function (require) { + "use strict"; + var gui = require("point_of_sale.gui"); + var models = require("point_of_sale.models"); + var core = require("web.core"); + + var _t = core._t; + + gui.Gui.prototype.screen_classes + .filter(function (el) { + return el.name === "payment"; + })[0] + .widget.include({ + init: function (parent, options) { + this._super(parent, options); + this.pos.bind( + "validate_order", + function () { + this.validate_order(); + }, + this + ); + }, + }); + + var PosModelSuper = models.PosModel; + models.PosModel = models.PosModel.extend({ + initialize: function () { + this.hidden_cashregisters = []; + return PosModelSuper.prototype.initialize.apply(this, arguments); + }, + show_warning: function (warning_message) { + console.info("error", warning_message); + this.chrome.gui.show_popup("error", { + title: _t("Warning"), + body: warning_message, + }); + }, + add_qr_payment: function ( + order_uid, + journal_id, + amount, + payment_vals, + validate + ) { + var order = this.get("orders").find(function (item) { + return item.uid === order_uid; + }); + if (order) { + var creg = _.filter( + this.hidden_cashregisters.concat(this.cashregisters), + function (r) { + return r.journal_id[0] === journal_id; + } + )[0]; + + // Add payment + payment_vals = _.extend({}, payment_vals, { + order: order, + journal_id: journal_id, + cashregister: creg, + pos: this, + }); + var newPaymentline = new models.Paymentline({}, payment_vals); + newPaymentline.set_amount(amount); + order.paymentlines.add(newPaymentline); + + if (validate && order.is_paid()) { + /* Order is paid and has to be closed */ + this.trigger("validate_order"); + } + return order; + } + console.log("error", "Order is not found"); + return false; + }, + }); +}); diff --git a/pos_qr_payments/views/assets.xml b/pos_qr_payments/views/assets.xml new file mode 100644 index 0000000000..12e1bd0f7c --- /dev/null +++ b/pos_qr_payments/views/assets.xml @@ -0,0 +1,14 @@ + + + + +