From 720ce5808ddc8d06bc759a9f5b27d7ce4c259fc0 Mon Sep 17 00:00:00 2001 From: Mitchell Admin Date: Wed, 11 Aug 2021 09:39:57 +0000 Subject: [PATCH 1/3] :tada::one::three: pos_qr_payments previous commits history: https://github.com/itpp-labs/pos-addons/commits/13.0/pos_qr_payments > Made via .github/workflows/DINAR-PORT.yml --- pos_qr_payments/README.rst | 33 ++++++++ pos_qr_payments/__init__.py | 3 + pos_qr_payments/__manifest__.py | 25 ++++++ pos_qr_payments/doc/changelog.rst | 9 ++ pos_qr_payments/doc/index.rst | 5 ++ pos_qr_payments/i18n/pos_qr_payments.pot | 42 +++++++++ pos_qr_payments/models/__init__.py | 2 + pos_qr_payments/models/pos_order.py | 22 +++++ pos_qr_payments/static/description/icon.png | Bin 0 -> 1915 bytes pos_qr_payments/static/description/index.html | 61 +++++++++++++ .../static/src/js/pos_qr_payments.js | 80 ++++++++++++++++++ pos_qr_payments/views/assets.xml | 14 +++ pos_qr_payments/wizard/__init__.py | 2 + pos_qr_payments/wizard/pos_payment.py | 20 +++++ pos_qr_payments/wizard/pos_payment_views.xml | 15 ++++ 15 files changed, 333 insertions(+) create mode 100644 pos_qr_payments/README.rst create mode 100644 pos_qr_payments/__init__.py create mode 100644 pos_qr_payments/__manifest__.py create mode 100644 pos_qr_payments/doc/changelog.rst create mode 100644 pos_qr_payments/doc/index.rst create mode 100644 pos_qr_payments/i18n/pos_qr_payments.pot create mode 100644 pos_qr_payments/models/__init__.py create mode 100644 pos_qr_payments/models/pos_order.py create mode 100644 pos_qr_payments/static/description/icon.png create mode 100644 pos_qr_payments/static/description/index.html create mode 100644 pos_qr_payments/static/src/js/pos_qr_payments.js create mode 100644 pos_qr_payments/views/assets.xml create mode 100644 pos_qr_payments/wizard/__init__.py create mode 100644 pos_qr_payments/wizard/pos_payment.py create mode 100644 pos_qr_payments/wizard/pos_payment_views.xml 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..105bedd861 --- /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": "13.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": False, +} 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 0000000000000000000000000000000000000000..8a058284ed5f19cdba59c17a7dffb27828924681 GIT binary patch literal 1915 zcmV->2ZZ>EP)KbovemO~h<(8G$fl)$!c`_S{a>y;}U(%wD4T$;P*p1W&5{Qf@Aa~MAA`btMd zp6Dq83X8&`uqZ4Fi^8G^C@cz#!lJM!EDDPvps*+`3X8&`uqZ5wfWo4%C@cz#!qU7L zlHp5ar5pE_I4bi>N^{I?XnJ&p?Vj}f`D~2B63ULkvJ(}J;6)Bgv(4C?7F*}|z)wsU zHNzLOHN)I$-^Y>SOJlL)M0q2H6%{u4PDMkU^UyEo9fhTv8Dn41ttiSj$M1Hu>@}_X zERga&WLzJ-hy4L&(B0SN_4}OmolQ0MIUBP0Jx!Upm9LZ}iL*DX7b!r2T6KGRFJ8Y& z+Ci=DUdM%#XSZ&&^84G829|zZNQGT{gowMhd&$|^AlUu&&j`N}!BLAoiz5YT*>f=5 z5()_Vz#c!lcDe1|O@JdUFhf&jp0>qn}9dP#0ZWkMRF2CqOJ#e=62*2fP&+YyxCN*G5 zks@-V$9>4@0xyI=K?H<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KcnvU@!3!$JAww3b0$jd@wCA*FIyOU4*bI&Lpp4Joa_%GqQxS1a(JNA#2wg{3?x zmBUh&l$v2FPD-^7KEJ#qzr0xS+o}*2QiPlm(^}kFPf2MM)|!%16|A);r5;!>fs`5? zJj%VoD(g!imGZDas%V$ZnD>%iywg)s^5uU41^~Z)j6Q#e#pD10002ovPDHLkV1hpK BqagqQ literal 0 HcmV?d00001 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 @@ + + + + +