Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP][13.0] pos_empty_home : Make it configurable and simplify code #642

Merged
merged 2 commits into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pos_empty_home/__init__.py
@@ -0,0 +1 @@
from . import models
6 changes: 3 additions & 3 deletions pos_empty_home/__manifest__.py
Expand Up @@ -7,12 +7,12 @@
"name": "Point of Sale - Empty Home",
"version": "13.0.1.0.0",
"category": "Point Of Sale",
"summary": """
Point of Sale - Hide products at the start of the Point of Sale""",
"summary": "Point of Sale - Hide products if no category is selected",
"author": "La Louve, GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"data": ["views/assets.xml"],
"data": ["views/assets.xml", "views/pos_config.xml"],
"qweb": ["static/src/xml/pos_empty_home.xml"],
"demo": ["demo/pos_empty_home.xml"],
}
9 changes: 9 additions & 0 deletions pos_empty_home/demo/pos_empty_home.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<!-- Disable empty home on pos_config_main, because it can affect test tours -->
<record id="point_of_sale.pos_config_main" model="pos.config">
<field name="iface_empty_home" eval="False" />
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions pos_empty_home/models/__init__.py
@@ -0,0 +1 @@
from . import pos_config
14 changes: 14 additions & 0 deletions pos_empty_home/models/pos_config.py
@@ -0,0 +1,14 @@
# Copyright 2021 Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


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

iface_empty_home = fields.Boolean(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed your PR. it is good that the code has been reduced and LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

string="Empty Home",
help="Hide products if no category is selected.",
default=True,
)
1 change: 1 addition & 0 deletions pos_empty_home/readme/CONTRIBUTORS.rst
@@ -1,3 +1,4 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Druidoo <https://www.druidoo.io>
* Dhara Solanki <dhara.solanki@initos.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
11 changes: 0 additions & 11 deletions pos_empty_home/static/src/css/pos_empty_home.css

This file was deleted.

6 changes: 3 additions & 3 deletions pos_empty_home/static/src/js/db.js
Expand Up @@ -12,10 +12,10 @@ odoo.define("pos_empty_home.db", function(require) {

PosDB.include({
get_product_by_category: function(category_id) {
if (category_id != 0) {
return this._super(category_id);
if (window.posmodel.config.iface_empty_home && category_id == 0) {
return [];
}
return [];
return this._super.apply(this, arguments);
},
});

Expand Down
25 changes: 0 additions & 25 deletions pos_empty_home/static/src/js/screens.js

This file was deleted.

8 changes: 5 additions & 3 deletions pos_empty_home/static/src/xml/pos_empty_home.xml
Expand Up @@ -7,10 +7,12 @@
-->
<templates id="template" xml:space="preserve">
<t t-extend="ProductListWidget">
<t t-jquery=".product-list" t-operation="before">
<div class="product-list-empty-home">
<t t-jquery=".product-list-empty t[t-else=''] p" t-operation="after">
<p
t-if="widget.product_list.length == 0 &amp;&amp; (!widget.category || widget.category.id == 0)"
>
To select a product, please scan a barcode or search products by category or by name
</div>
</p>
</t>
</t>
</templates>
12 changes: 1 addition & 11 deletions pos_empty_home/views/assets.xml
Expand Up @@ -7,18 +7,8 @@
-->
<odoo>
<template id="assets_frontend" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/pos_empty_home/static/src/js/db.js" />
<script
type="text/javascript"
src="/pos_empty_home/static/src/js/screens.js"
/>
</xpath>
<xpath expr="//link[@id='pos-stylesheet']" position="after">
<link
rel="stylesheet"
href="/pos_empty_home/static/src/css/pos_empty_home.css"
/>
</xpath>
</template>
</odoo>
25 changes: 25 additions & 0 deletions pos_empty_home/views/pos_config.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='start_category']//ancestor::div[hasclass('o_setting_box')]"
position="after"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="iface_empty_home" />
</div>
<div class="o_setting_right_pane">
<label for="iface_empty_home" />
<div class="text-muted">
Hide products if no category is selected.
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>