Skip to content

Commit

Permalink
[ADD] pos_customer_comment
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Oct 17, 2022
1 parent bb66c4d commit af7c8b8
Show file tree
Hide file tree
Showing 24 changed files with 289 additions and 0 deletions.
Empty file added pos_customer_comment/README.rst
Empty file.
1 change: 1 addition & 0 deletions pos_customer_comment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
33 changes: 33 additions & 0 deletions pos_customer_comment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Point of Sale - Cashier Comment",
"summary": "Display Customer comment in the PoS front office and allow"
" to edit and save it by the cashier",
"version": "16.0.1.0.0",
"category": "Point of Sale",
"maintainers": ["legalsylvain"],
"author": "GRAP,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"data": [
"views/view_res_partner.xml",
],
"assets": {
"point_of_sale.assets": [
"pos_customer_comment/static/src/css/pos_customer_comment.scss",
"pos_customer_comment/static/src/xml/PartnerDetailsEdit.xml",
"pos_customer_comment/static/src/xml/PartnerLine.xml",
],
"web.assets_tests": [
"pos_customer_comment/tests/tours/PosCustomerComment.tour.js",
],
},
"demo": [
"demo/res_partner.xml",
],
"installable": True,
}
13 changes: 13 additions & 0 deletions pos_customer_comment/demo/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-->
<odoo>
<record id="base.res_partner_address_31" model="res.partner">
<field
name="pos_comment"
>Important information to display in Point of Sale</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions pos_customer_comment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import pos_session
from . import res_partner
14 changes: 14 additions & 0 deletions pos_customer_comment/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

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("pos_comment")
return res
15 changes: 15 additions & 0 deletions pos_customer_comment/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


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

pos_comment = fields.Text(
string="Cashier Comment",
help="Comment that will be visible and editable in the"
" Point of Sale for the cashiers",
)
1 change: 1 addition & 0 deletions pos_customer_comment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL (https://twitter.com/legalsylvain)
3 changes: 3 additions & 0 deletions pos_customer_comment/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

* UGESS, Union Nationale des Groupements des épiceries Sociales et Solidaires (https://ugess.org/)
2 changes: 2 additions & 0 deletions pos_customer_comment/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of point of sale module, to allow display and edit
customer note field in the point of sale UI for the cashier.
3 changes: 3 additions & 0 deletions pos_customer_comment/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
For the time being, there is no HTML widget available in the point of sale.
For that reason, the Cashier comment (``pos_comment``) is a simple Text field.
If a widget is available in odoo, it could be great to switch to a HTML field text.
14 changes: 14 additions & 0 deletions pos_customer_comment/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
* Go to your partner view and write or edit new PoS comments

.. figure:: ../static/description/res_partner_form.png

* Then Open your Point of sale

in the customer tree view, a new icon is available to mention that the customer
has a PoS Comment to read:

.. figure:: ../static/description/pos_customer_tree.png

It is possible to see or edit the comment in the customer form view:

.. figure:: ../static/description/pos_customer_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions pos_customer_comment/static/src/css/pos_customer_comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
*/

.pos .partnerlist-screen .partner-details textarea {
padding: 4px;
border-radius: 3px;
border: solid 1px #cecbcb;
margin-bottom: 4px;
background: white;
font-family: "Lato", "Lucida Grande", Helvetica, Verdana, Arial;
color: #555555;
width: 340px;
font-size: 14px;
box-sizing: border-box;
}

.pos .partnerlist-screen .partner-details span.label {
vertical-align: top;
}
30 changes: 30 additions & 0 deletions pos_customer_comment/static/src/xml/PartnerDetailsEdit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-->
<templates id="template" xml:space="preserve">

<t
t-name="PartnerDetailsEdit"
t-inherit="point_of_sale.PartnerDetailsEdit"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//select[@name='country_id']/.." position="after">
<div class="partner-detail partner-detail-pos-comment">
<span class="label">Comment</span>
<textarea
class="detail"
name="pos_comment"
style="height: 100px;"
t-on-change="captureChange"
t-att-value="props.partner.pos_comment || ''"
placeholder="Comment"
/>
</div>
</xpath>
</t>

</templates>
27 changes: 27 additions & 0 deletions pos_customer_comment/static/src/xml/PartnerLine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-->
<templates id="template" xml:space="preserve">

<t
t-name="PartnerLine"
t-inherit="point_of_sale.PartnerLine"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//button[@class='edit-partner-button']" position="after">
<div t-if="props.partner.pos_comment != ''">
<i
class="fa fa-comment"
role="img"
aria-label="Has PoS Comment"
title="Has PoS Comment"
/>
</div>
</xpath>
</t>

</templates>
1 change: 1 addition & 0 deletions pos_customer_comment/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_module
23 changes: 23 additions & 0 deletions pos_customer_comment/tests/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2022-Today GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html


from odoo.tests import tagged

from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon


@tagged("post_install", "-at_install")
class TestUi(TestPointOfSaleHttpCommon):
def test_pos_customer_comment(self):
self.main_pos_config.open_ui()
self.main_pos_config.current_session_id.set_cashbox_pos(0, None)

self.start_tour(
f"/pos/ui?config_id={self.main_pos_config.id}",
"PosCustomerCommentTour",
login="accountman",
)
customer = self.env.ref("base.res_partner_address_31")
self.assertEqual(customer.pos_comment, "New Comment")
56 changes: 56 additions & 0 deletions pos_customer_comment/tests/tours/PosCustomerComment.tour.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
*/
odoo.define("pos_customer_comment.tour.PosCustomerComment", function (require) {
"use strict";

const Tour = require("web_tour.tour");

var steps = [
{
content: "Test pos_customer_content: Waiting for loading to finish",
trigger: "body:not(:has(.loader))",
},
{
content: "Test pos_customer_content: open customer list",
trigger: "button.set-partner",
},
{
content: "Test pos_customer_content: select 'Addison Olson' Customer",
trigger: ".partner-line:contains('Addison Olson') .edit-partner-button",
},
{
content: "Test pos_customer_content: Check if value is correctly loaded",
trigger: "textarea[name='pos_comment']",
run: () => {
var content = $("textarea[name='pos_comment']");
if (!content.val().includes("Important")) {
throw new Error("the PoS comment was not loaded in the frontend");
}
},
},
{
content: "Test pos_customer_content: Write new text in PoS Comment field",
trigger: "textarea[name='pos_comment']",
run: "text New Comment",
},
{
content: "Test pos_customer_content: Save Customer changes",
trigger: ".partnerlist-screen .button.highlight",
},
{
content: "Test pos_customer_content: Close the Point of Sale frontend",
trigger: ".header-button",
},
{
content: "Test pos_customer_content: Confirm closing the frontend",
trigger: ".header-button",
},
];

Tour.register("PosCustomerCommentTour", {test: true, url: "/pos/ui"}, steps);
});

/* */
22 changes: 22 additions & 0 deletions pos_customer_comment/views/view_res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (C) 2022-Today GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
-->
<odoo>
<record id="view_res_partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page name="page_pos_comment" string="Cashier Comment">
<field
name="pos_comment"
placeholder="Comment that will be visible and editable in the Point of Sale for the cashiers"
/>
</page>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/pos_customer_comment/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit af7c8b8

Please sign in to comment.