From 2e47f83461835813ea016834ccbf4028a188ffb9 Mon Sep 17 00:00:00 2001 From: Vincent Van Rossem Date: Wed, 9 Sep 2020 11:31:36 +0200 Subject: [PATCH] [12.0][ADD] beesdoo_pos: available_in_pos management maintains "Available in POS" (`available_in_pos`) value when unchecking "Can be Sold" (`sale_ok`). --- beesdoo_pos/README.rst | 4 +++- beesdoo_pos/__manifest__.py | 3 ++- beesdoo_pos/models/__init__.py | 1 + beesdoo_pos/models/product.py | 16 ++++++++++++++++ beesdoo_pos/readme/DESCRIPTION.rst | 4 +++- beesdoo_pos/static/description/index.html | 4 +++- 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 beesdoo_pos/models/product.py diff --git a/beesdoo_pos/README.rst b/beesdoo_pos/README.rst index 5d3621f..ceb68b4 100644 --- a/beesdoo_pos/README.rst +++ b/beesdoo_pos/README.rst @@ -19,7 +19,9 @@ Beescoop Point of sale |badge1| |badge2| |badge3| -This module adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget. +This module : +- adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget. +- maintains "Available in POS" (`available_in_pos`) value when unchecking "Can be Sold" (`sale_ok`). **Table of contents** diff --git a/beesdoo_pos/__manifest__.py b/beesdoo_pos/__manifest__.py index 8ba8be7..0c798e6 100644 --- a/beesdoo_pos/__manifest__.py +++ b/beesdoo_pos/__manifest__.py @@ -1,6 +1,7 @@ # Copyright 2017 - 2020 BEES coop SCRLfs # - Elouan Lebars # - Rémy Taymans +# - Vincent Van Rossem # - Elise Dupont # - Thibault François # - Grégoire Leeuwerck @@ -12,7 +13,7 @@ "author": "Beescoop - Cellule IT, Coop IT Easy SCRLfs", "website": "https://github.com/beescoop/Obeesdoo", "category": "Point Of Sale", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "depends": ["beesdoo_base", "beesdoo_product"], "data": ["views/beesdoo_pos.xml", "data/default_barcode_pattern.xml"], "qweb": ["static/src/xml/templates.xml"], diff --git a/beesdoo_pos/models/__init__.py b/beesdoo_pos/models/__init__.py index 09371b2..28d2ac1 100644 --- a/beesdoo_pos/models/__init__.py +++ b/beesdoo_pos/models/__init__.py @@ -1 +1,2 @@ from . import beesdoo_pos +from . import product diff --git a/beesdoo_pos/models/product.py b/beesdoo_pos/models/product.py new file mode 100644 index 0000000..3da1a45 --- /dev/null +++ b/beesdoo_pos/models/product.py @@ -0,0 +1,16 @@ +from odoo import api, fields, models, _ + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + @api.onchange('sale_ok') + def _onchange_sale_ok(self): + """ Maintains the value of `available_in_pos` when unchecking `sale_ok`, + by storing its value before calling parent's method, + then assigning the stored value. + """ + was_available = self.available_in_pos + super(ProductTemplate, self)._onchange_sale_ok() + if not self.sale_ok: + self.available_in_pos = was_available diff --git a/beesdoo_pos/readme/DESCRIPTION.rst b/beesdoo_pos/readme/DESCRIPTION.rst index 08e6aef..f2e2be1 100644 --- a/beesdoo_pos/readme/DESCRIPTION.rst +++ b/beesdoo_pos/readme/DESCRIPTION.rst @@ -1 +1,3 @@ -This module adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget. +This module : +- adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget. +- maintains "Available in POS" (`available_in_pos`) value when unchecking "Can be Sold" (`sale_ok`). diff --git a/beesdoo_pos/static/description/index.html b/beesdoo_pos/static/description/index.html index ded71a7..5cae370 100644 --- a/beesdoo_pos/static/description/index.html +++ b/beesdoo_pos/static/description/index.html @@ -368,7 +368,9 @@ ul.auto-toc { !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 beescoop/obeesdoo

-

This module adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget.

+

This module : +- adds the eaters of the customer to the POS ActionpadWidget and PaymentScreenWidget. +- maintains “Available in POS” (available_in_pos) value when unchecking “Can be Sold” (sale_ok).

Table of contents