Skip to content

Commit

Permalink
fixup! saved
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 committed Nov 1, 2024
1 parent 1d7b49a commit 7de5e69
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 155 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
3 changes: 1 addition & 2 deletions pos_esign_request/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
],
},
"data": [
# "views/assets.xml", # TODO
# "views/pos_config_view.xml", # TODO
"views/partner_views.xml",
"views/pos_config_views.xml",
"views/res_config_settings_views.xml",
],
"demo": [],
Expand Down
9 changes: 7 additions & 2 deletions pos_esign_request/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from werkzeug.exceptions import Unauthorized

from odoo import http
from odoo.http import request, route
from werkzeug.exceptions import Unauthorized


class PosESignExtension(http.Controller):
def _verify_pos_config(self, access_token):
pos_config_sudo = request.env['pos.config'].sudo().search([('access_token', '=', access_token)], limit=1)
pos_config_sudo = (
request.env["pos.config"]
.sudo()
.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
Expand Down
13 changes: 13 additions & 0 deletions pos_esign_request/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ class PosConfig(models.Model):
)
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):
Expand Down
9 changes: 8 additions & 1 deletion pos_esign_request/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
Expand All @@ -13,3 +13,10 @@ class ResConfigSettings(models.TransientModel):
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ export class ESignKioskPage extends Component {
const vals = this.prepareSignValues();
await this.rpc("/pos_esign_request/sign_response", {
access_token: this.selfOrder.access_token,
vals: vals
vals: vals,
});
this.state.signature = null;
} finally {
this.state.isSubmitting = false;
}
}

onClickReject() {
this.state.signature = null;
}

prepareSignValues() {
return {
partner_id: this.state.partner_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,31 @@
</div>
<div
class="page-buttons d-flex flex-nowrap justify-content-between py-2 px-3 gap-2 gap-md-3 bg-view z-index-1"
>
<!--
>
<button
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0"
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0 w-100"
t-if="this.state.showingTerms == false"
t-on-click="() => this.showTerms()"
>Show Terms and Conditions</button>
<button
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0"
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0 w-100"
t-if="this.state.showingTerms == true"
t-on-click="() => this.hideTerms()"
>Hide Terms and Conditions</button>
-->
>Hide Terms and Conditions</button>
<button
t-if="state.signature"
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0 w-100"
t-on-click="onClickSubmit"
t-att-disabled="state.isSubmitting ? 'disabled' : ''"
>
>
<i t-if="state.isSubmitting" class="fa fa-spinner fa-spin" />
Submit Sign
</button>
<button class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0 w-100" t-on-click="onClickReject">Reject</button>
<button
class="btn btn-primary btn-lg flex-grow-1 flex-md-grow-0 w-100"
t-if="state.signature"
t-on-click="onClickReject"
>Reject</button>
</div>
</t>
</templates>
9 changes: 5 additions & 4 deletions pos_esign_request/static/src/overrides/models/pos_bus.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @odoo-module */

import {patch} from "@web/core/utils/patch";
import {PosBus} from "@point_of_sale/app/bus/pos_bus_service";
import {patch} from "@web/core/utils/patch";

patch(PosBus.prototype, {
// Override
Expand All @@ -12,12 +12,13 @@ patch(PosBus.prototype, {
if (message.type === "ESIGN_RESPONSE" && payload?.partner_id) {
const partner = this.pos.db.get_partner_by_id(payload.partner_id);
if (partner) {
if (this.pos.waiting_for_esign_partner && this.pos.waiting_for_esign_partner.id == partner.id) {
if (
this.pos.waiting_for_esign_partner &&
this.pos.waiting_for_esign_partner.id === partner.id
) {
this.pos.waiting_for_esign_partner = null;
}

// TODO: в каком виде хранить этот sign_attachment_id?
// прям так?
partner.sign_attachment_id = payload.attachment_id;

// Updates screen in general
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ patch(PaymentScreen.prototype, {
// Customer did not sign and it is mandatory
this.popup.add(ErrorPopup, {
title: _t("Error"),
body: _t("Customer hasn't sign yet."),
body: _t("Customer hasn't signed yet."),
});
return false;
} while (false);
} while (false); // eslint-disable-line no-constant-condition

return await super.validateOrder(...arguments);
},
Expand Down
45 changes: 0 additions & 45 deletions pos_esign_request/views/assets.xml

This file was deleted.

77 changes: 0 additions & 77 deletions pos_esign_request/views/pos_config_view.xml

This file was deleted.

Loading

0 comments on commit 7de5e69

Please sign in to comment.