Skip to content

Commit

Permalink
[MIG] pos_esign_request: port to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 committed Nov 6, 2024
1 parent 05b8461 commit ad7f910
Show file tree
Hide file tree
Showing 36 changed files with 568 additions and 868 deletions.
10 changes: 9 additions & 1 deletion pos_esign_request/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ You need two devices: one for POS, another one for taking signs
- Open E-Sign Kiosk on the second device

- Open menu ``[[ Point of Sale ]] >> Dashboard``
- Click ``E-Sign`` on the same POS as opened on the first device
- Click three dots on the same POS as opened on the first device
- Click ``E-Sign``

- On the first device click ``Customer`` button

Expand All @@ -70,6 +71,13 @@ You need two devices: one for POS, another one for taking signs
- On the first device for the customer in the **E-Sign** column ✔ sign
appears

Known issues / Roadmap
======================

Current implementation technically depends on ``pos_self_order`` module.
Meanwhile no functional feature are used, only technical feature of self
order screen.

Bug Tracker
===========

Expand Down
22 changes: 15 additions & 7 deletions pos_esign_request/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@
"website": "https://github.com/it-projects-llc/pos-addons",
"license": "LGPL-3",
"depends": [
"pos_longpolling",
"pos_self_order",
],
"assets": {
"pos_self_order.assets": [
"pos_esign_request/static/src/app/**/*",
"web/static/lib/jquery/jquery.js",
"web/static/src/core/signature/name_and_signature.scss",
"web/static/src/core/signature/name_and_signature.xml",
"web/static/src/core/signature/name_and_signature.js",
],
"point_of_sale._assets_pos": [
"pos_esign_request/static/src/overrides/**/*",
],
},
"data": [
"views/assets.xml",
"views/pos_config_view.xml",
"views/partner_views.xml",
"views/pos_config_views.xml",
"views/res_config_settings_views.xml",
],
"demo": [],
"qweb": [
"static/src/xml/pos_esign.xml",
"static/src/xml/est_templates.xml",
],
}
45 changes: 22 additions & 23 deletions pos_esign_request/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
import json
from werkzeug.exceptions import Unauthorized

from odoo import http
from odoo.http import request
from odoo.http import request, route


class PosESignExtension(http.Controller):
@http.route("/pos_longpolling/sign_request", type="json", auth="user")
def sign_request(self, vals):
channel_name = "pos.sign_request.to_est"
config_id = request.env["pos.config"].browse(vals.get("config_id", False))
if (
request.env["ir.config_parameter"]
def _verify_pos_config(self, access_token):
pos_config_sudo = (
request.env["pos.config"]
.sudo()
.get_param("pos_longpolling.allow_public")
):
config_id = config_id.sudo()

config_id.send_to_esign_tab(channel_name, config_id.id, json.dumps(vals))
.search([("access_token", "=", access_token)], limit=1)
)
if not pos_config_sudo or not pos_config_sudo.has_active_session:
raise Unauthorized("Invalid access token")
return pos_config_sudo

@http.route("/pos_longpolling/submit_sign", type="json", auth="user")
def submit_kiosk_sign(self, vals):
config_id = request.env["pos.config"].browse(vals.get("config_id", 0))
@route("/pos_esign_request/sign_response", type="json", auth="public")
def submit_kiosk_sign(self, access_token, vals):
config = self._verify_pos_config(access_token)
res = self.update_partner_sign(vals)

if res and config_id:
channel_name = "pos.sign_request"
config_id._send_to_channel_by_id(
config_id._cr.dbname, config_id.id, channel_name, json.dumps(res)
if res and config.current_session_id:
session = config.current_session_id
request.env["bus.bus"]._sendone(
session._get_bus_channel_name(), "ESIGN_RESPONSE", res
)

return True
Expand All @@ -37,9 +34,11 @@ def update_partner_sign(self, vals):
if not (partner_id and sign):
return False

partner_id = request.env["res.partner"].browse(int(partner_id))
ir_attachment = request.env["ir.attachment"]
attachment = ir_attachment.create(
Partners = request.env["res.partner"].sudo()
partner_id = Partners.browse(int(partner_id))

Attachments = request.env["ir.attachment"].sudo()
attachment = Attachments.create(
{
"type": "binary",
"name": partner_id.name + "E-Sign",
Expand Down
5 changes: 4 additions & 1 deletion pos_esign_request/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from . import models
from . import pos_config
from . import pos_session
from . import res_config_settings
from . import res_partner
61 changes: 0 additions & 61 deletions pos_esign_request/models/models.py

This file was deleted.

45 changes: 45 additions & 0 deletions pos_esign_request/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from odoo import api, fields, models


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

ask_for_sign = fields.Boolean(string="Ask To Sign", default=False)
mandatory_ask_for_sign = fields.Boolean(
string="Mandatory Ask To Sign", default=False
)
terms_to_sign = fields.Char(string="Terms & Conditions (ESign)")

def _get_esign_route(self):
self.ensure_one()
base_route = f"/pos-self/{self.id}/esign_kiosk"
return f"{base_route}?access_token={self.access_token}"

def preview_esign_app(self):
self.ensure_one()
return {
"type": "ir.actions.act_url",
"url": self._get_esign_route(),
"target": "new",
}

@api.depends("ask_for_sign")
@api.onchange("ask_for_sign")
def _onchange_ask_for_sign(self):
if not self.ask_for_sign:
self.mandatory_ask_for_sign = False

def sign_request(self, **kw):
for config in self:
if config.current_session_id and config.access_token:
self.env["bus.bus"]._sendone(
f"pos_config-{config.access_token}", "ESIGN_REQUEST", kw
)

def _get_self_ordering_data(self):
res = super()._get_self_ordering_data()
res["config"].update(
name=self.name,
terms_to_sign=self.terms_to_sign,
)
return res
10 changes: 10 additions & 0 deletions pos_esign_request/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import models


class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_res_partner(self):
res = super()._loader_params_res_partner()
res["search_params"]["fields"].append("sign_attachment_id")
return res
22 changes: 22 additions & 0 deletions pos_esign_request/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pos_ask_for_sign = fields.Boolean(
related="pos_config_id.ask_for_sign", readonly=False
)
pos_mandatory_ask_for_sign = fields.Boolean(
related="pos_config_id.mandatory_ask_for_sign", readonly=False
)
pos_terms_to_sign = fields.Char(
related="pos_config_id.terms_to_sign", readonly=False
)

@api.onchange("pos_ask_for_sign", "pos_self_ordering_mode")
def _onchange_ask_for_sign(self):
if self.pos_ask_for_sign:
self.pos_self_ordering_mode = "mobile"
else:
self.pos_mandatory_ask_for_sign = False
7 changes: 7 additions & 0 deletions pos_esign_request/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import fields, models


class Partner(models.Model):
_inherit = "res.partner"

sign_attachment_id = fields.Many2one("ir.attachment", "E-Sign")
2 changes: 2 additions & 0 deletions pos_esign_request/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Current implementation technically depends on `pos_self_order` module.
Meanwhile no functional feature are used, only technical feature of self order screen.
3 changes: 2 additions & 1 deletion pos_esign_request/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ You need two devices: one for POS, another one for taking signs
* Open E-Sign Kiosk on the second device

* Open menu `[[ Point of Sale ]] >> Dashboard`
* Click `E-Sign` on the same POS as opened on the first device
* Click three dots on the same POS as opened on the first device
* Click `E-Sign`

* On the first device click `Customer` button
* Select a Customer
Expand Down
30 changes: 19 additions & 11 deletions pos_esign_request/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,12 @@ <h1 class="title">POS E-Sign Request</h1>
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -406,7 +407,8 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<li>Open a POS on a first device</li>
<li>Open E-Sign Kiosk on the second device<ul>
<li>Open menu <tt class="docutils literal">[[ Point of Sale ]] &gt;&gt; Dashboard</tt></li>
<li>Click <tt class="docutils literal"><span class="pre">E-Sign</span></tt> on the same POS as opened on the first device</li>
<li>Click three dots on the same POS as opened on the first device</li>
<li>Click <tt class="docutils literal"><span class="pre">E-Sign</span></tt></li>
</ul>
</li>
<li>On the first device click <tt class="docutils literal">Customer</tt> button</li>
Expand All @@ -419,32 +421,38 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
appears</li>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>Current implementation technically depends on <tt class="docutils literal">pos_self_order</tt> module.
Meanwhile no functional feature are used, only technical feature of self
order screen.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/it-projects-llc/pos-addons/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/it-projects-llc/pos-addons/issues/new?body=module:%20pos_esign_request%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>IT-Projects LLC</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Alexandr Kolusov (<a class="reference external" href="https://github.com/KolushovAlexandr">https://github.com/KolushovAlexandr</a>)</li>
<li>Victor Bykov (<a class="reference external" href="https://github.com/BykovVik">https://github.com/BykovVik</a>)</li>
<li>Eugene Molotov (<a class="reference external" href="https://github.com/em230418">https://github.com/em230418</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is part of the <a class="reference external" href="https://github.com/it-projects-llc/pos-addons/tree/17.0/pos_esign_request">it-projects-llc/pos-addons</a> project on GitHub.</p>
<p>You are welcome to contribute.</p>
</div>
Expand Down
Loading

0 comments on commit ad7f910

Please sign in to comment.