Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] pos_qr_payments #1425

Open
wants to merge 3 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions pos_qr_payments/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://it-projects.info/team/yelizariev>`__


Further information
===================

Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/pos_qr_payments/


Notifications on updates: `via Atom <https://github.com/it-projects-llc/pos-addons/commits/13.0/pos_qr_payments.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/pos-addons/commits/13.0/pos_qr_payments.atom>`_

Tested on `Odoo 11.0 <https://github.com/odoo/odoo/commit/4d0a1330e05bd688265bea14df4ad12838f9f2d7>`_
3 changes: 3 additions & 0 deletions pos_qr_payments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import models
from . import wizard
25 changes: 25 additions & 0 deletions pos_qr_payments/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/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,
}
9 changes: 9 additions & 0 deletions pos_qr_payments/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
`1.0.1`
-------

- **FIX** - Error related to pos reference in different translations

`1.0.0`
-------

- **Init version**
5 changes: 5 additions & 0 deletions pos_qr_payments/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
==========================
QR-based payments in POS
==========================

The module cannot be used alone. Try to install, for example, `pos_wechat <https://apps.odoo.com/apps/modules/13.0/pos_wechat/>`__.
42 changes: 42 additions & 0 deletions pos_qr_payments/i18n/pos_qr_payments.pot
Original file line number Diff line number Diff line change
@@ -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 ""

2 changes: 2 additions & 0 deletions pos_qr_payments/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import pos_order
22 changes: 22 additions & 0 deletions pos_qr_payments/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# 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 ""
Binary file added pos_qr_payments/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions pos_qr_payments/static/description/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan" style="color:#875A7B;">QR-based payments in POS</h2>
<h3 class="oe_slogan">Technical module to support qr-based payments like Alipay, WeChat</h3>
</div>
</div>
</section>

<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span8">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:pos@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:pos@it-projects.info">pos@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
<div class="oe_span4">
<div class="stamp" style="width:200px;">
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);">
Tested on Odoo<br/>12.0 community
</div>
<!--<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(8deg);
-o-transform: rotate(8deg);
-moz-transform: rotate(8deg);
-ms-transform: rotate(8deg);">
Tested on Odoo<br/>12.0 enterprise
</div>-->
</div>
</div>
</div>
</section>
80 changes: 80 additions & 0 deletions pos_qr_payments/static/src/js/pos_qr_payments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/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;
},
});
});
14 changes: 14 additions & 0 deletions pos_qr_payments/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<!-- POS -->
<template id="pos_assets" name="POS assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/pos_qr_payments/static/src/js/pos_qr_payments.js"
/>
</xpath>
</template>
</odoo>
2 changes: 2 additions & 0 deletions pos_qr_payments/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import pos_payment
20 changes: 20 additions & 0 deletions pos_qr_payments/wizard/pos_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License MIT (https://opensource.org/licenses/MIT).
from odoo import api, fields, models


class PosMakePayment(models.TransientModel):
_inherit = "pos.make.payment"

order_ref = fields.Char(compute="_compute_order_ref")

# TODO: It could be removed, as we set defaul values and don't need to use domain

# It doesn't depend on journal_id, it's a workaround, because otherwise it
# doesn't receive a value in form
@api.depends("journal_id")
def _compute_order_ref(self):
order = self.env["pos.order"].browse(self.env.context.get("active_id", False))
if order:
for r in self:
r.order_ref = order.pos_reference_uid
15 changes: 15 additions & 0 deletions pos_qr_payments/wizard/pos_payment_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<record id="view_pos_payment" model="ir.ui.view">
<field name="name">pos.make.payment.form</field>
<field name="model">pos.make.payment</field>
<field name="inherit_id" ref="point_of_sale.view_pos_payment" />
<field name="arch" type="xml">
<xpath expr="//field[@name='amount']" position="after">
<field name="order_ref" invisible="1" />
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/pos_qr_payments/odoo/addons/pos_qr_payments
6 changes: 6 additions & 0 deletions setup/pos_qr_payments/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)