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_wechat #1443

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
77 changes: 77 additions & 0 deletions pos_wechat/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev

========================
WeChat Payments in POS
========================

The module implements following payment workflows

Quick Pay (micropay)
--------------------

* Cashier creates order and scan user's QR in user's WeChat mobile app

* scanning can be done via Mobile Phone camera (``pos_mobile`` module is recommended)
* scanning can be done via usb scanner
* scanning can be done via usb scanner attached to PosBox

* User's receives order information and authorise fund transferring
* Cashier gets payment confirmation in POS

Native Payment (QR Code Payment)
--------------------------------

* Cashier clicks a button to get one-time url and shows it to Buyer as a QR Code

* QR can be shown in POS
* QR can be shown in Mobile POS (``pos_mobile`` module is recommended)
* QR can be shown in Customer screen

* Buyer scans to finish the transaction.
* Cashier gets payment confirmation in POS

Debugging
=========

Camera
------

If you don't have camera, you can executing following code in browser console to simulate scanning::

odoo.__DEBUG__.services['web.core'].bus.trigger('qr_scanned', '134579302432164181');

Customer Screen
---------------

To emulate Customer screen do as following:

* run another odoo on a different port, say ``9069``, workers 1, extra *server wide modules*, i.e. use ``--workers=1 --load=web,hw_proxy,hw_posbox_homepage,hw_screen``
* open page at your browser: http://localhost:9069/point_of_sale/display -- you must see message ``POSBox Client display``
* at POS' Settings activate ``[x] PosBox``, activate ``[x] Customer Display`` and set **IP Address** to ``localhost:9069``
* Now just open POS

Roadmap
=======

* TODO: In sake of UX, we need to add ``micropay_id`` reference to ``account.bank.statement.line``

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>`__
* `Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>`__

===================

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


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

Tested on `Odoo 12.0 <https://github.com/odoo/odoo/commit/b05e34a0d9b13a1c6971b99ed3e5fa20199f3545>`_
3 changes: 3 additions & 0 deletions pos_wechat/__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
27 changes: 27 additions & 0 deletions pos_wechat/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License MIT (https://opensource.org/licenses/MIT).
{
"name": """WeChat Payments in POS""",
"summary": """Support WeChat QR-based payments (scan and show)""",
"category": "Point of Sale",
"images": ["images/main.jpg"],
"version": "14.0.1.0.0",
"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": [
"wechat",
"pos_qr_scan",
"pos_qr_show",
"pos_qr_payments",
"pos_longpolling",
],
"external_dependencies": {"python": [], "bin": []},
"data": ["views/assets.xml", "wizard/pos_payment_views.xml"],
"demo": [],
"qweb": ["static/src/xml/pos.xml"],
"auto_install": False,
"installable": True,
}
4 changes: 4 additions & 0 deletions pos_wechat/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
60 changes: 60 additions & 0 deletions pos_wechat/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
========================
WeChat Payments in POS
========================


Follow instructions of `WeChat API <https://apps.odoo.com/apps/modules/13.0/wechat/>`__ module.

Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way

Configuration
=============

WeChat Journals
---------------

WeChat Journals are created automatically on first opening new POS session.

* In demo installation: they are availabe in POS immediatly
* In non-demo installation: add Journals to **Payment Methods** in *Point of
Sale*'s Settings, then close existing session if any and open again

Usage
=====

Show QR to customer
-------------------

* Start POS
* Create some Order
* Go to Payment screen
* Click on journal *Wechat Native Payment*
* RESULT: QR is shown on Screen and Customer Screen (when available)

Scanning customer's QR
----------------------

* Start POS
* Create some Order
* Click ``[Scan QR Code]`` or use QR Scanner device attached to PosBox or the device you use (computer, tablet, phone)
* Ask customer to prepare QR in WeChat app
* Scan the QR
* Wait until customer authorise the payment in his WeChat app
* RESULT: Payment is proceeded. Use your WeChat Seller control panel to see balance update.

Refunds
-------

* Make Refund Order via backend as usual:

* Go to ``[[ Point of Sale ]] >> Orders >> Orders``
* Open product to be refuned
* Click button ``[Return Products]``

* In Refund Order click ``[Payment]``
* In **Payment Mode** specify a WeChat journal
* Depending on type of WeChat journal specify either **WeChat Order to refund**
or **Micropay to refund**
82 changes: 82 additions & 0 deletions pos_wechat/i18n/pos_wechat.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_wechat
#
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_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_pos__display_name
msgid "Display Name"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_pos__id
msgid "ID"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_pos____last_update
msgid "Last Modified on"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_pos_make_payment__micropay_id
msgid "Micropay to refund"
msgstr ""

#. module: pos_wechat
#: model:ir.model,name:pos_wechat.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""

#. module: pos_wechat
#: model:ir.model,name:pos_wechat.model_pos_make_payment
msgid "Point of Sale Payment"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_micropay__pos_id
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_order__pos_id
#: model:ir.model.fields,field_description:pos_wechat.field_wechat_pos__pos_id
msgid "Pos"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,help:pos_wechat.field_pos_make_payment__journal_wechat
msgid "Register for WeChat payment"
msgstr ""

#. module: pos_wechat
#: model:ir.model,name:pos_wechat.model_wechat_order
msgid "Unified Order"
msgstr ""

#. module: pos_wechat
#: model:ir.model,name:pos_wechat.model_wechat_micropay
msgid "WeChat Micropay"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_pos_make_payment__wechat_order_id
msgid "WeChat Order to refund"
msgstr ""

#. module: pos_wechat
#: model:ir.model,name:pos_wechat.model_wechat_pos
msgid "WeChat POS"
msgstr ""

#. module: pos_wechat
#: model:ir.model.fields,field_description:pos_wechat.field_pos_make_payment__journal_wechat
msgid "WeChat Payment"
msgstr ""

Binary file added pos_wechat/images/main.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions pos_wechat/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import wechat_pos
from . import wechat_micropay
from . import wechat_order
from . import pos_config
114 changes: 114 additions & 0 deletions pos_wechat/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License MIT (https://opensource.org/licenses/MIT).
from odoo import models

MODULE = "pos_wechat"


class PosConfig(models.Model):
_inherit = "pos.config"

def open_session_cb(self):
res = super(PosConfig, self).open_session_cb()
self.init_pos_wechat_journals()
return res

def init_pos_wechat_journals(self):
"""Init demo Journals for current company"""
# Multi-company is not primary task for this module, but I copied this
# code from pos_debt_notebook, so why not
journal_obj = self.env["account.journal"]
user = self.env.user
wechat_journal_active = journal_obj.search(
[("company_id", "=", user.company_id.id), ("wechat", "!=", False)]
)
if wechat_journal_active:
return

demo_is_on = self.env["ir.module.module"].search([("name", "=", MODULE)]).demo

options = {"noupdate": True, "type": "cash", "write_statement": demo_is_on}
wechat_native_journal = self._create_wechat_journal(
dict(
sequence_name="Wechat Native Payment",
prefix="WNATIVE-- ",
journal_name="Wechat Native Payment",
code="WNATIVE",
wechat="native",
**options
)
)
micropay_journal = self._create_wechat_journal(
dict(
sequence_name="Wechat Micropay",
prefix="WMICRO- ",
journal_name="Wechat Micropay",
code="WMICRO",
wechat="micropay",
**options
)
)
if demo_is_on:
self.write(
{
"journal_ids": [
(4, wechat_native_journal.id),
(4, micropay_journal.id),
]
}
)

def _create_wechat_journal(self, vals):
user = self.env.user
new_sequence = self.env["ir.sequence"].create(
{
"name": vals["sequence_name"] + str(user.company_id.id),
"padding": 3,
"prefix": vals["prefix"] + str(user.company_id.id),
}
)
self.env["ir.model.data"].create(
{
"name": "journal_sequence" + str(new_sequence.id),
"model": "ir.sequence",
"module": MODULE,
"res_id": new_sequence.id,
"noupdate": True, # If it's False, target record (res_id) will be removed while module update
}
)
wechat_journal = self.env["account.journal"].create(
{
"name": vals["journal_name"],
"code": vals["code"],
"type": vals["type"],
"wechat": vals["wechat"],
"journal_user": True,
"sequence_id": new_sequence.id,
}
)
self.env["ir.model.data"].create(
{
"name": "wechat_journal_" + str(wechat_journal.id),
"model": "account.journal",
"module": MODULE,
"res_id": int(wechat_journal.id),
"noupdate": True, # If it's False, target record (res_id) will be removed while module update
}
)
if vals["write_statement"]:
self.write({"journal_ids": [(4, wechat_journal.id)]})
current_session = self.current_session_id
statement = [
(
0,
0,
{
"name": current_session.name,
"journal_id": wechat_journal.id,
"user_id": user.id,
"company_id": user.company_id.id,
},
)
]
current_session.write({"statement_ids": statement})
return wechat_journal
Loading