diff --git a/pos_usability/__init__.py b/pos_usability/__init__.py index e69de29..0650744 100644 --- a/pos_usability/__init__.py +++ b/pos_usability/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_usability/__manifest__.py b/pos_usability/__manifest__.py index cc14c45..fe5842a 100644 --- a/pos_usability/__manifest__.py +++ b/pos_usability/__manifest__.py @@ -1,8 +1,10 @@ +# Copyright 2014-2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "POS Usability", - "version": "12.0.1.0.0", + "version": "14.0.1.0.0", "category": "Point of sale", "license": "AGPL-3", "summary": "Misc usability improvement for point of sale", @@ -24,6 +26,10 @@ Akretion: "author": "Akretion", "website": "http://www.akretion.com", "depends": ["point_of_sale"], - "data": ["report/pos.xml"], - "installable": False, + "data": [ + "report/pos.xml", + "views/pos_category.xml", + "views/product.xml", + ], + "installable": True, } diff --git a/pos_usability/models/__init__.py b/pos_usability/models/__init__.py new file mode 100644 index 0000000..4d5f90b --- /dev/null +++ b/pos_usability/models/__init__.py @@ -0,0 +1,2 @@ +from . import product +from . import pos_category diff --git a/pos_usability/models/pos_category.py b/pos_usability/models/pos_category.py new file mode 100644 index 0000000..09747c8 --- /dev/null +++ b/pos_usability/models/pos_category.py @@ -0,0 +1,25 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PosCategory(models.Model): + _inherit = 'pos.category' + + product_count = fields.Integer( + '# Products', compute='_compute_product_count', + help="The number of products under this point of sale category " + "(does not consider the children categories)") + + # inspired by the code of odoo/addons/product/models/product.py + def _compute_product_count(self): + read_group_res = self.env['product.template'].read_group( + [('pos_categ_id', 'in', self.ids)], + ['pos_categ_id'], ['pos_categ_id']) + group_data = dict( + (data['pos_categ_id'][0], data['pos_categ_id_count']) for data + in read_group_res) + for pos_categ in self: + pos_categ.product_count = group_data.get(pos_categ.id, 0) diff --git a/pos_usability/models/product.py b/pos_usability/models/product.py new file mode 100644 index 0000000..4e8f2dc --- /dev/null +++ b/pos_usability/models/product.py @@ -0,0 +1,12 @@ +# Copyright 2017-2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + available_in_pos = fields.Boolean(tracking=True) + pos_categ_id = fields.Many2one(tracking=True) diff --git a/pos_usability/views/pos_category.xml b/pos_usability/views/pos_category.xml new file mode 100644 index 0000000..34a17ed --- /dev/null +++ b/pos_usability/views/pos_category.xml @@ -0,0 +1,35 @@ + + + + + + + + + pos_usability.pos.category.form + pos.category + + +
+
+ +
+
+
+
+ + +
diff --git a/pos_usability/views/product.xml b/pos_usability/views/product.xml new file mode 100644 index 0000000..f1e81aa --- /dev/null +++ b/pos_usability/views/product.xml @@ -0,0 +1,43 @@ + + + + + + + + + + usability.pos.product.template + product.template + + + + +
+ +
+
+
+
+ + + pos_usability.product.template.search + product.template + + + + + + + + + + + + +