Skip to content

Commit af7c8b8

Browse files
committed
[ADD] pos_customer_comment
1 parent bb66c4d commit af7c8b8

24 files changed

+289
-0
lines changed

pos_customer_comment/README.rst

Whitespace-only changes.

pos_customer_comment/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

pos_customer_comment/__manifest__.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
2+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
4+
5+
{
6+
"name": "Point of Sale - Cashier Comment",
7+
"summary": "Display Customer comment in the PoS front office and allow"
8+
" to edit and save it by the cashier",
9+
"version": "16.0.1.0.0",
10+
"category": "Point of Sale",
11+
"maintainers": ["legalsylvain"],
12+
"author": "GRAP,Odoo Community Association (OCA)",
13+
"website": "https://github.com/OCA/pos",
14+
"license": "AGPL-3",
15+
"depends": ["point_of_sale"],
16+
"data": [
17+
"views/view_res_partner.xml",
18+
],
19+
"assets": {
20+
"point_of_sale.assets": [
21+
"pos_customer_comment/static/src/css/pos_customer_comment.scss",
22+
"pos_customer_comment/static/src/xml/PartnerDetailsEdit.xml",
23+
"pos_customer_comment/static/src/xml/PartnerLine.xml",
24+
],
25+
"web.assets_tests": [
26+
"pos_customer_comment/tests/tours/PosCustomerComment.tour.js",
27+
],
28+
},
29+
"demo": [
30+
"demo/res_partner.xml",
31+
],
32+
"installable": True,
33+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
6+
-->
7+
<odoo>
8+
<record id="base.res_partner_address_31" model="res.partner">
9+
<field
10+
name="pos_comment"
11+
>Important information to display in Point of Sale</field>
12+
</record>
13+
</odoo>
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import pos_session
2+
from . import res_partner
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
2+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
4+
5+
from odoo import models
6+
7+
8+
class PosSession(models.Model):
9+
_inherit = "pos.session"
10+
11+
def _loader_params_res_partner(self):
12+
res = super()._loader_params_res_partner()
13+
res["search_params"]["fields"].append("pos_comment")
14+
return res
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
2+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
4+
5+
from odoo import fields, models
6+
7+
8+
class ResPartner(models.Model):
9+
_inherit = "res.partner"
10+
11+
pos_comment = fields.Text(
12+
string="Cashier Comment",
13+
help="Comment that will be visible and editable in the"
14+
" Point of Sale for the cashiers",
15+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Sylvain LE GAL (https://twitter.com/legalsylvain)
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The development of this module has been financially supported by:
2+
3+
* UGESS, Union Nationale des Groupements des épiceries Sociales et Solidaires (https://ugess.org/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This module extends the functionality of point of sale module, to allow display and edit
2+
customer note field in the point of sale UI for the cashier.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
For the time being, there is no HTML widget available in the point of sale.
2+
For that reason, the Cashier comment (``pos_comment``) is a simple Text field.
3+
If a widget is available in odoo, it could be great to switch to a HTML field text.

pos_customer_comment/readme/USAGE.rst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* Go to your partner view and write or edit new PoS comments
2+
3+
.. figure:: ../static/description/res_partner_form.png
4+
5+
* Then Open your Point of sale
6+
7+
in the customer tree view, a new icon is available to mention that the customer
8+
has a PoS Comment to read:
9+
10+
.. figure:: ../static/description/pos_customer_tree.png
11+
12+
It is possible to see or edit the comment in the customer form view:
13+
14+
.. figure:: ../static/description/pos_customer_form.png
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
3+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
4+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
5+
*/
6+
7+
.pos .partnerlist-screen .partner-details textarea {
8+
padding: 4px;
9+
border-radius: 3px;
10+
border: solid 1px #cecbcb;
11+
margin-bottom: 4px;
12+
background: white;
13+
font-family: "Lato", "Lucida Grande", Helvetica, Verdana, Arial;
14+
color: #555555;
15+
width: 340px;
16+
font-size: 14px;
17+
box-sizing: border-box;
18+
}
19+
20+
.pos .partnerlist-screen .partner-details span.label {
21+
vertical-align: top;
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
6+
-->
7+
<templates id="template" xml:space="preserve">
8+
9+
<t
10+
t-name="PartnerDetailsEdit"
11+
t-inherit="point_of_sale.PartnerDetailsEdit"
12+
t-inherit-mode="extension"
13+
owl="1"
14+
>
15+
<xpath expr="//select[@name='country_id']/.." position="after">
16+
<div class="partner-detail partner-detail-pos-comment">
17+
<span class="label">Comment</span>
18+
<textarea
19+
class="detail"
20+
name="pos_comment"
21+
style="height: 100px;"
22+
t-on-change="captureChange"
23+
t-att-value="props.partner.pos_comment || ''"
24+
placeholder="Comment"
25+
/>
26+
</div>
27+
</xpath>
28+
</t>
29+
30+
</templates>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
6+
-->
7+
<templates id="template" xml:space="preserve">
8+
9+
<t
10+
t-name="PartnerLine"
11+
t-inherit="point_of_sale.PartnerLine"
12+
t-inherit-mode="extension"
13+
owl="1"
14+
>
15+
<xpath expr="//button[@class='edit-partner-button']" position="after">
16+
<div t-if="props.partner.pos_comment != ''">
17+
<i
18+
class="fa fa-comment"
19+
role="img"
20+
aria-label="Has PoS Comment"
21+
title="Has PoS Comment"
22+
/>
23+
</div>
24+
</xpath>
25+
</t>
26+
27+
</templates>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_module
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
2+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
4+
5+
6+
from odoo.tests import tagged
7+
8+
from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon
9+
10+
11+
@tagged("post_install", "-at_install")
12+
class TestUi(TestPointOfSaleHttpCommon):
13+
def test_pos_customer_comment(self):
14+
self.main_pos_config.open_ui()
15+
self.main_pos_config.current_session_id.set_cashbox_pos(0, None)
16+
17+
self.start_tour(
18+
f"/pos/ui?config_id={self.main_pos_config.id}",
19+
"PosCustomerCommentTour",
20+
login="accountman",
21+
)
22+
customer = self.env.ref("base.res_partner_address_31")
23+
self.assertEqual(customer.pos_comment, "New Comment")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
3+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
4+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
5+
*/
6+
odoo.define("pos_customer_comment.tour.PosCustomerComment", function (require) {
7+
"use strict";
8+
9+
const Tour = require("web_tour.tour");
10+
11+
var steps = [
12+
{
13+
content: "Test pos_customer_content: Waiting for loading to finish",
14+
trigger: "body:not(:has(.loader))",
15+
},
16+
{
17+
content: "Test pos_customer_content: open customer list",
18+
trigger: "button.set-partner",
19+
},
20+
{
21+
content: "Test pos_customer_content: select 'Addison Olson' Customer",
22+
trigger: ".partner-line:contains('Addison Olson') .edit-partner-button",
23+
},
24+
{
25+
content: "Test pos_customer_content: Check if value is correctly loaded",
26+
trigger: "textarea[name='pos_comment']",
27+
run: () => {
28+
var content = $("textarea[name='pos_comment']");
29+
if (!content.val().includes("Important")) {
30+
throw new Error("the PoS comment was not loaded in the frontend");
31+
}
32+
},
33+
},
34+
{
35+
content: "Test pos_customer_content: Write new text in PoS Comment field",
36+
trigger: "textarea[name='pos_comment']",
37+
run: "text New Comment",
38+
},
39+
{
40+
content: "Test pos_customer_content: Save Customer changes",
41+
trigger: ".partnerlist-screen .button.highlight",
42+
},
43+
{
44+
content: "Test pos_customer_content: Close the Point of Sale frontend",
45+
trigger: ".header-button",
46+
},
47+
{
48+
content: "Test pos_customer_content: Confirm closing the frontend",
49+
trigger: ".header-button",
50+
},
51+
];
52+
53+
Tour.register("PosCustomerCommentTour", {test: true, url: "/pos/ui"}, steps);
54+
});
55+
56+
/* */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
6+
-->
7+
<odoo>
8+
<record id="view_res_partner_form" model="ir.ui.view">
9+
<field name="model">res.partner</field>
10+
<field name="inherit_id" ref="base.view_partner_form" />
11+
<field name="arch" type="xml">
12+
<xpath expr="//notebook" position="inside">
13+
<page name="page_pos_comment" string="Cashier Comment">
14+
<field
15+
name="pos_comment"
16+
placeholder="Comment that will be visible and editable in the Point of Sale for the cashiers"
17+
/>
18+
</page>
19+
</xpath>
20+
</field>
21+
</record>
22+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../pos_customer_comment

setup/pos_customer_comment/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)