Skip to content

Commit

Permalink
[14.0][ADD] pos_disable_pricelist_selection
Browse files Browse the repository at this point in the history
  • Loading branch information
i1 authored and diga committed May 4, 2022
1 parent 47aa8c3 commit 01af69b
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pos_disable_pricelist_selection/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

A good, one sentence summary in the manifest is also highly recommended.


Automatic changelog generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_.

Just put towncrier compatible changelog fragments into `readme/newsfragments`
and the changelog file will be automatically generated and updated when a new fragment is added.

Please refer to `towncrier` documentation to know more.

NOTE: the changelog will be automatically generated when using `/ocabot merge $option`.
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_.
1 change: 1 addition & 0 deletions pos_disable_pricelist_selection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions pos_disable_pricelist_selection/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Disable Pricelist selection button in POS",
"version": "14.0.1.0.0",
"summary": "Disable Pricelist selection button in POS",
"author": "Ooops, Cetmix, Odoo Community Association (OCA)",
"contributors": "Cetmix",
"license": "LGPL-3",
"category": "Purchase",
"website": "https://github.com/OCA/pos",
"depends": ["point_of_sale"],
"external_dependencies": {},
"demo": [],
"data": ["views/assets.xml", "views/pos_config_view.xml"],
"qweb": ["static/src/xml/ClientDetailsEdit.xml"],
"installable": True,
"application": False,
}
1 change: 1 addition & 0 deletions pos_disable_pricelist_selection/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_config
9 changes: 9 additions & 0 deletions pos_disable_pricelist_selection/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


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

hide_pricelist_button = fields.Boolean(
default=False,
)
1 change: 1 addition & 0 deletions pos_disable_pricelist_selection/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* No configuration is required
2 changes: 2 additions & 0 deletions pos_disable_pricelist_selection/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Ooops404 <https://www.ooops404.com/>
* Cetmix <https://cetmix.com/>
4 changes: 4 additions & 0 deletions pos_disable_pricelist_selection/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Disable Pricelist selection button in POS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Disable Pricelist selection button in POS
4 changes: 4 additions & 0 deletions pos_disable_pricelist_selection/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
14.0.1.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Initial release
3 changes: 3 additions & 0 deletions pos_disable_pricelist_selection/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* In POS configuration enable multiple pricelists
* There will be a checkbox "Hide Pricelist Button"
* If checked pricelist selection button will be hidden in POS Screen
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions pos_disable_pricelist_selection/static/src/js/ProductScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
odoo.define("pos_disable_pricelist_selection.ProductScreen", function (require) {
"use strict";

const ProductScreen = require("point_of_sale.ProductScreen");
const Registries = require("point_of_sale.Registries");

const PosProductScreen = (ProductScreen) =>
class extends ProductScreen {
constructor() {
super(...arguments);
_.each(this.constructor.controlButtons, function (button) {
if (button.name === "SetPricelistButton") {
button.condition = function () {
return (
this.env.pos.config.use_pricelist &&
this.env.pos.pricelists.length > 1 &&
!this.env.pos.config.hide_pricelist_button
);
};
}
});
}
};

Registries.Component.extend(ProductScreen, PosProductScreen);

return ProductScreen;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">

<t
t-name="ClientDetailsEdit"
t-inherit="point_of_sale.ClientDetailsEdit"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//div[@t-if='env.pos.pricelists.length gt 1']"
position="attributes"
>
<attribute
name="t-if"
>env.pos.pricelists.length gt 1 and !env.pos.config.hide_pricelist_button</attribute>
</xpath>
</t>

</templates>
11 changes: 11 additions & 0 deletions pos_disable_pricelist_selection/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/pos_disable_pricelist_selection/static/src/js/ProductScreen.js"
/>
</xpath>
</template>
</odoo>
23 changes: 23 additions & 0 deletions pos_disable_pricelist_selection/views/pos_config_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="pos_config_view_form" model="ir.ui.view">
<field name="name">pos.config.form.view</field>
<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="//div[@id='pricelist_setting']//div[@class='content-group mt16']"
position="inside"
>
<div class="row mt16">
<label
string="Hide Pricelist Button"
for="hide_pricelist_button"
class="col-lg-3 o_light_label"
/>
<field name="hide_pricelist_button" />
</div>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/pos_disable_pricelist_selection/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 01af69b

Please sign in to comment.