Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
3ef8483
:fire: add test_create_without_pay_from_miniprogram_ui, test_create_a…
Aug 22, 2018
a443196
:fire_engine: Passing tests
Aug 22, 2018
0d15ef4
:lock: update access
Aug 22, 2018
e2ac62b
:rose: style for mini-program banners
Aug 22, 2018
ba44f0c
:tv:
Aug 22, 2018
45edcdb
:memo: update depends
Aug 22, 2018
99e4ccf
:fire_engine: passing test_mobile_number_verification
Aug 22, 2018
c3ef422
:memo: fix depends
Aug 22, 2018
ece9609
:fire: fix test_create_and_pay_from_miniprogram_ui
Aug 22, 2018
640c1d8
:fire_engine: passing tests
Aug 22, 2018
4b2e007
:bomb: message format for POS
Aug 22, 2018
3b35370
:fire: fix test_create_order_from_ui
Aug 23, 2018
1cd406d
:fire_engine: passing tests
Aug 23, 2018
83f075e
:bomb: display mini program order in POS
Aug 23, 2018
00dd4af
:bomb: add new selection to journal
Aug 23, 2018
2b48a91
:bomb: update and chage exist order
Aug 24, 2018
d5161ff
:green_heart:
Aug 27, 2018
dc3a7fe
:green_heart:
Aug 27, 2018
d9f6455
:bomb: decryption data from mini-program
Aug 27, 2018
6390d26
:bath: ref code
Aug 27, 2018
1527de8
:bomb: verification WeChat phone number
Aug 27, 2018
79e13d2
:bomb: new field
Aug 27, 2018
065d544
:tv:
Aug 27, 2018
757b1ec
:bath: remove temp code
Aug 27, 2018
3f66af0
:green_heart:
Aug 27, 2018
f09bbb4
:bomb: add function for sync beetwen mini-programs
Aug 27, 2018
4494395
:green_heart:
Aug 27, 2018
aad7e47
:tv: pos config view
Aug 28, 2018
81a91ae
:rose: help for field
Aug 28, 2018
b013526
:bomb: verify number for current user
Aug 28, 2018
da56c26
:bomb: use wechat user for decrypt data
Aug 28, 2018
ee25aba
:bomb: use session key for decrypt wechat data
Aug 28, 2018
7604e89
:bomb: new fields
Aug 29, 2018
2357aa7
:bomb: use parther session key
Aug 29, 2018
225892a
:bomb: decoding decrypt result
Aug 29, 2018
85c4b61
:fire_engine: fix region error
Aug 29, 2018
c43cab0
:fire_engine: use phoneNumber
Aug 29, 2018
ae88c88
:bath: remove old code and refactoring
Aug 30, 2018
1518ea0
Revert ":bath: remove old code and refactoring"
Aug 30, 2018
86b49a2
:bath: refactoring code and revert last commit
Aug 30, 2018
ee66cf8
:tv: fix view for qcloud module
Aug 30, 2018
1c9d8f8
:bomb: change type of field
Aug 30, 2018
67f4c81
:bomb: check template params on kwargs
Aug 30, 2018
ced914d
:fire: new test_template_sms_mobile_number_verification
Aug 30, 2018
fb8f1ab
:fire_engine: passing test_template_sms_mobile_number_verification
Aug 30, 2018
becae23
:fire: fix tests
Aug 30, 2018
c962673
:fire_engine: passing tests
Aug 30, 2018
e17625c
:fire_engine: template ID is int
Aug 30, 2018
f0be13b
:fire_engine: use object function
Aug 30, 2018
7e18a1f
:fire_engine: type of verification code
Aug 30, 2018
154b48b
:bomb: lines is array
Aug 31, 2018
7bf7981
:bomb: use firs element of array
Aug 31, 2018
6e6f6fb
:bomb: user floor id
Aug 31, 2018
1836fce
:fire_engine: save floor id on model
Aug 31, 2018
7857317
:bomb: add new field
Aug 31, 2018
2db96e6
:bomb: remove not found mini-program orders
Aug 31, 2018
df37d31
:bomb: remove removed orders from POS
Aug 31, 2018
67db8a5
:bath: cleanup and refactoring code
Aug 31, 2018
ea7cd38
:bomb: use all lines
Aug 31, 2018
438a084
:bomb: update floor screen after getting message
Aug 31, 2018
219af35
:tv: update view
Sep 3, 2018
30f2adc
:bomb: add new setting to pos config
Sep 3, 2018
3a39b20
:tv: pos config view
Sep 3, 2018
abcd52c
:bomb: auto print payed orders
Sep 3, 2018
dc41a75
:green_heart:
Sep 3, 2018
4599f86
:bomb: show user error if not user info
Sep 4, 2018
1646c15
:fire_engine: gui is not defined
Sep 4, 2018
598de81
:fire_engine: gui is not defined
Sep 4, 2018
860cd64
:bomb: rerender floor screen
Sep 4, 2018
55f14e4
:fire_engine: gui is not defined
Sep 4, 2018
be80285
:bomb: get partner
Sep 4, 2018
6dec59b
:rose: change _order
Sep 4, 2018
8d78444
:rose: change _order
Sep 4, 2018
08c27c9
:bath: cleanup
Sep 4, 2018
6735921
:bomb: return payment data to mini-program
Sep 4, 2018
c042c47
:bomb: get miniprogram access token
Sep 4, 2018
f95b5c3
:bomb: get qr code and access token
Sep 5, 2018
dedce52
:bomb: generate WeChat mini-program QR code for tables
Sep 5, 2018
b513228
:green_heart:
Sep 5, 2018
32de318
:memo: License
Sep 5, 2018
93a2458
:fire: fix pos wechat miniprogram tests
Sep 5, 2018
0dcd2fb
:bomb: fix path
Sep 5, 2018
6d3dab3
:bomb: save table qr code
Sep 5, 2018
e1a0cfb
:memo: update documentation
Sep 5, 2018
7ce1192
:memo: update README
Sep 11, 2018
816b40c
:bomb: fix write of partner
Sep 11, 2018
ca3f096
:bomb: fix write of partner
Sep 11, 2018
34a274b
:rose: show records
Sep 11, 2018
3ef2402
:rose: show records
Sep 11, 2018
803af32
:rose: rename field name
Sep 11, 2018
e0221bf
:rose: sorting records
Sep 11, 2018
89fcc35
:rose: sorting and display records
Sep 11, 2018
e716e80
:bomb: new field product note
Sep 11, 2018
c4adaa6
:view: product note
Sep 11, 2018
2b8954e
:bomb: show note in POS
Sep 11, 2018
180fcff
:bomb: mini-program journal
Sep 11, 2018
eb61c19
:bomb: not print products durring load orders
Sep 11, 2018
c90df8d
:bomb: parentNode is undefined
Sep 11, 2018
9e6bf36
:bomb: multi session shop
Sep 15, 2018
a813a66
:bomb: key error
Sep 17, 2018
97de761
:bomb: send mini-prpgram orders to POS by shop
Sep 17, 2018
21a0c37
:fire: test_template_sms_mobile_number_verification
Sep 17, 2018
3022f96
:fire_engine: test_template_sms_mobile_number_verification
Sep 17, 2018
5a624d5
:tv:
Sep 17, 2018
d4ce0e5
:lock: update access
Sep 17, 2018
bc83686
:lock: fix access
Sep 18, 2018
1ca921d
:bomb: fix 'int' object is not subscriptable
Sep 18, 2018
e647803
:bomb: get user orders
Sep 18, 2018
50544b6
:bomb: get order and orderlines as JSON
Sep 18, 2018
00770b0
:bomb: fix verification template id
Sep 18, 2018
eeca7e2
:bomb: fix template id
Sep 18, 2018
af27712
:bomb: fix type error
Sep 18, 2018
bc17fa0
:bomb: fix type error
Sep 18, 2018
52242e1
:bomb: fix type error
Sep 18, 2018
672d65f
:bomb: fix type error
Sep 18, 2018
81c4804
:bomb: get country code
Sep 19, 2018
21104b3
:tv: show shop
Sep 19, 2018
8aa99a0
:bomb: miniprogram_order is undefined
Sep 20, 2018
d41f56a
:bomb: miniprogram_order is undefined
Sep 20, 2018
4d27b70
:bomb: filter miniprogram orders
Sep 20, 2018
dcf5d55
:bomb: filter miniprogram orders
Sep 20, 2018
41e8489
:bomb: filter miniprogram orders
Sep 20, 2018
dae4133
:lock: to product attributes
Sep 20, 2018
0ad4a01
:rose: fix design
Sep 20, 2018
0a1483e
:bomb: not load multi-session mp orders
Sep 20, 2018
fd78901
:rose: view
Sep 21, 2018
4cc63fb
:bomb: compatibility with pos_wechat
Sep 21, 2018
4e25160
:bomb: don't show jsapi journal in POS
Sep 21, 2018
4813067
:bomb: journal id is undefined
Sep 21, 2018
67ba130
:bomb: fix 'NoneType' object has no attribute 'get'
Sep 21, 2018
903b174
:bomb: refund wizard
Sep 21, 2018
566477e
:bomb: pos_payment.xml is undefined
Sep 21, 2018
60dd57e
:bomb: fix domain
Sep 21, 2018
774dfd3
:bomb: refund domain
Sep 21, 2018
beba2c0
:bomb: save order ref
Sep 21, 2018
470d9a7
:bomb: miniprogram_order is undefined
Sep 21, 2018
dc10c62
:shield:
Oct 15, 2018
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
68 changes: 68 additions & 0 deletions pos_wechat_miniprogram/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,74 @@

Integrate POS with WeChat mini-program

Verification mobile number
==========================

Quick
-----

Use the mobile phone number specified in your WeChat account.::

authByWeChat: function (e) {
var detail = e.detail;
var params = {
model: 'res.users',
method: 'wechat_mobile_number_verification',
args: [detail],
context: {},
kwargs: {}
};
odooRpc(params).then(function (res) {
wx.setStorageSync('telephoneNumberVerified', res.result);
})
}

With code confirmation
----------------------

You need to enter a phone number and confirm the number using a code from SMS message.::

submitNumber: function(e) {
var value = e.detail.value;
var TemplateID = 1; # id of verification template (model 'qcloud.sms.template')
var params = {
model: 'res.users',
method: 'template_sms_mobile_number_verification',
args: [value.usrtel, TemplateID],
context: {},
kwargs: {}
};
odooRpc(params).then(function (res) {
# your code here ...
});
},
submitCode: function (e) {
var value = e.detail.value;
var params = {
model: 'res.users',
method: 'check_verification_code',
args: [value.code],
context: {},
kwargs: {}
};
odooRpc(params).then(function (res) {
wx.setStorageSync('telephoneNumberVerified', res.result);
});
}

Payments
========

Pay via WeChat mini-program
---------------------------

TODO

Pay via POS
-----------

TODO

Credits
=======

Expand Down
3 changes: 3 additions & 0 deletions pos_wechat_miniprogram/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import models
from . import wizard
from . import report
14 changes: 14 additions & 0 deletions pos_wechat_miniprogram/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@

"depends": [
"wechat_miniprogram",
"qcloud_sms",
"pos_multi_session_restaurant",
"pos_order_note",
"pos_wechat",
"base_geolocalize",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"security/wechat_security.xml",
"security/ir.model.access.csv",
"views/product_view.xml",
"views/pos_wechat_miniprogram_view.xml",
"views/template.xml",
"views/pos_config_view.xml",
"views/pos_restaurant_view.xml",
"views/pos_multi_session_restaurant_view.xml",
"views/res_config_settings_view.xml",
"wizard/qrcode.xml",
"wizard/pos_payment_views.xml",
"report/report_table_qrcode.xml",
],
"demo": [
],
Expand Down
39 changes: 39 additions & 0 deletions pos_wechat_miniprogram/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,42 @@ Installation
============

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

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

WeChat mini-program Journals
----------------------------

WeChat mini-program 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
=====

Generate mini-program QR Codes for tables of restaurant
-------------------------------------------------------

* Go to ``[[ Point of Sale ]] >> WeChat mini-program >> QR Code``
* Specify ``Floor``
* Specify ``Quantity`` - quantity of QR codes for each table
* Specify ``Tables`` of the ``Floor``
* Click on ``[Print]``
* RESULT: You will get a PDF report with QR codes.

Usage of POS
------------
* Go to ``[[ Point of Sale ]] >> Configuration >> Point of Sale``
* Open ``POS`` form
* Click on ``[Edit]``
* Specify ``Allow receiving messages``
* Specify ``Auto Print miniprogram Orders``
* Click on ``[Save]``
* Open ``POS`` session
* Create ``Order`` from WeChat mini-program and pay via mini-program
* Click ``Validate`` in the POS for confirming the ``Order``
* Create new ``Order`` from WeChat mini-program without pay
* Click ``Payment`` in the POS for payment the ``Order``
11 changes: 11 additions & 0 deletions pos_wechat_miniprogram/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import product
from . import user
from . import http
from . import wechat_order
from . import pos_config
from . import pos_order
from . import pos_wechat_miniprogram
from . import pos_restaurant
from . import pos_multi_session_models
from . import res_config_settings
14 changes: 14 additions & 0 deletions pos_wechat_miniprogram/models/http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models
from odoo.http import request


class Http(models.AbstractModel):
_inherit = 'ir.http'

def session_info(self):
result = super(Http, self).session_info()
user = request.env.user
result['number_verified'] = user.partner_id.number_verified
return result
58 changes: 58 additions & 0 deletions pos_wechat_miniprogram/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models, fields, api

MODULE = 'pos_wechat_miniprogram'


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

allow_message_from_miniprogram = fields.Boolean(string='Allow receiving messages',
help='Allow receiving messages from the WeChat mini-program',
default=True)
auto_print_miniprogram_orders = fields.Boolean(string='Auto Print miniprogram Orders',
help='Auto Print miniprogram order to kitchen',
default=True)
shop_id = fields.Many2one(related='multi_session_id.shop_id')

@api.multi
def open_session_cb(self):
res = super(PosConfig, self).open_session_cb()
self.init_pos_wechat_miniprogram_journal()
return res

def init_pos_wechat_miniprogram_journal(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_jsapi_journal_active = journal_obj.search([
('company_id', '=', user.company_id.id),
('wechat', '=', 'jsapi'),
])
if wechat_jsapi_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_jsapi_journal = self._create_wechat_journal(dict(
sequence_name='Wechat JSAPI Payment',
prefix='WMPJSAPI-- ',
journal_name='Wechat JSAPI Payment',
code='WMPJSAPI',
wechat='jsapi',
**options
))

if demo_is_on:
self.write({
'journal_ids': [
(4, wechat_jsapi_journal.id),
],
})
10 changes: 10 additions & 0 deletions pos_wechat_miniprogram/models/pos_multi_session_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2019 Gabbasov Dinar <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo import models, fields


class PosMultiSession(models.Model):
_inherit = 'pos.multi_session'

shop_id = fields.Many2one('res.partner', string='Shop')
26 changes: 26 additions & 0 deletions pos_wechat_miniprogram/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models, api


class PosOrder(models.Model):
_inherit = 'pos.order'

@api.model
def create_from_ui(self, orders):
res = super(PosOrder, self).create_from_ui(orders)
for o in orders:
data = o.get('data')
miniprogram_data = data.get("miniprogram_order") or {}
submitted_references = data.get('name')
order = self.search([('pos_reference', '=', submitted_references)])
if order and miniprogram_data.get('id'):
miniprogram_order = self.env['pos.miniprogram.order'].browse(int(miniprogram_data.get('id')))
if miniprogram_order:
miniprogram_order.write({
'state': 'done',
'order_id': order.id,
'confirmed_from_pos': True,
'order_ref': data.get('miniprogram_order_ref')
})
return res
28 changes: 28 additions & 0 deletions pos_wechat_miniprogram/models/pos_restaurant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import api, models, fields
import werkzeug.urls


class RestaurantTable(models.Model):
_inherit = 'restaurant.table'

wechat_miniprogram_qr = fields.Binary(string='WeChat mini-program QR', attachment=True)

@api.multi
def get_miniprogram_qr_code(self, access_token=False):
self.ensure_one()
if not self.wechat_miniprogram_qr:
param = {
'floor_id': self.floor_id,
'table_id': self.id
}
data = {
"path": '%s?%s' % ('pages/index/index', werkzeug.urls.url_encode(param)),
"width": 430
}
res = self.env['ir.config_parameter'].sudo().get_qr_code(data, access_token)
self.wechat_miniprogram_qr = res
return res

return self.wechat_miniprogram_qr
Loading