diff --git a/pos_default_quantity/README.rst b/pos_default_quantity/README.rst
index 8b96f7b9d9..c4c2f28bba 100644
--- a/pos_default_quantity/README.rst
+++ b/pos_default_quantity/README.rst
@@ -30,7 +30,7 @@ Set Default Product Quantity in POS
This module adds a field for a default quantity to Unit of Measure Categories.
When this is filled in, and when this functionality is enabled in the Point of
-Sale Configuration, then adding that product to an order in the Point of Sale
+Sale configuration, then adding that product to an order in the Point of Sale
will set the quantity to that value by default.
**Table of contents**
@@ -38,6 +38,18 @@ will set the quantity to that value by default.
.. contents::
:local:
+Usage
+=====
+
+In order to set this up, you need to do a few things:
+
+- Make sure that you have permissions to manage multiple units of measure.
+- In the settings of Inventory, enable units of measure.
+- For each relevant unit of measure category, determine a default product quantity
+ (default: 1).
+- For each relevant Point of Sale, find 'Set default product quantity' in the
+ 'Technical' section of its settings, and toggle it on.
+
Bug Tracker
===========
diff --git a/pos_default_quantity/__manifest__.py b/pos_default_quantity/__manifest__.py
index 3d281f374b..4c6828ffaf 100644
--- a/pos_default_quantity/__manifest__.py
+++ b/pos_default_quantity/__manifest__.py
@@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Set Default Product Quantity in POS",
- "version": "15.0.1.0.0",
+ "version": "16.0.1.0.0",
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
@@ -15,8 +15,12 @@
""",
"depends": ["point_of_sale"],
"data": [
- "views/pos_config_views.xml",
+ "views/res_config_settings_views.xml",
"views/uom_category_views.xml",
- "static/src/xml/templates.xml",
],
+ "assets": {
+ "point_of_sale.assets": [
+ "pos_default_quantity/static/src/js/**/*.js",
+ ]
+ },
}
diff --git a/pos_default_quantity/models/__init__.py b/pos_default_quantity/models/__init__.py
index 31beb5976d..3e6ea31b02 100644
--- a/pos_default_quantity/models/__init__.py
+++ b/pos_default_quantity/models/__init__.py
@@ -1,2 +1,5 @@
from . import pos_config
+from . import pos_session
+from . import product_template
+from . import res_config_settings
from . import uom_category
diff --git a/pos_default_quantity/models/pos_config.py b/pos_default_quantity/models/pos_config.py
index aba94d0d8e..387a8166d1 100644
--- a/pos_default_quantity/models/pos_config.py
+++ b/pos_default_quantity/models/pos_config.py
@@ -9,5 +9,5 @@ class PosConfig(models.Model):
_inherit = "pos.config"
set_default_product_quantity = fields.Boolean(
- string="Sets default product quantity in POS", default=False
+ string="Set default product quantity in POS", default=False
)
diff --git a/pos_default_quantity/models/pos_session.py b/pos_default_quantity/models/pos_session.py
new file mode 100644
index 0000000000..e8b16628c3
--- /dev/null
+++ b/pos_default_quantity/models/pos_session.py
@@ -0,0 +1,14 @@
+# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+from odoo import models
+
+
+class PosSession(models.Model):
+ _inherit = "pos.session"
+
+ def _loader_params_product_product(self):
+ result = super()._loader_params_product_product()
+ result["search_params"]["fields"].append("pos_default_qty")
+ return result
diff --git a/pos_default_quantity/models/product_template.py b/pos_default_quantity/models/product_template.py
new file mode 100644
index 0000000000..416f966afb
--- /dev/null
+++ b/pos_default_quantity/models/product_template.py
@@ -0,0 +1,11 @@
+# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+from odoo import fields, models
+
+
+class ProductTemplate(models.Model):
+ _inherit = "product.template"
+
+ pos_default_qty = fields.Float(related="uom_id.category_id.pos_default_qty")
diff --git a/pos_default_quantity/models/res_config_settings.py b/pos_default_quantity/models/res_config_settings.py
new file mode 100644
index 0000000000..7e1ae7f51f
--- /dev/null
+++ b/pos_default_quantity/models/res_config_settings.py
@@ -0,0 +1,14 @@
+# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+from odoo import fields, models
+
+
+class ResConfigSettings(models.TransientModel):
+ _inherit = "res.config.settings"
+
+ pos_set_default_product_quantity = fields.Boolean(
+ related="pos_config_id.set_default_product_quantity",
+ readonly=False,
+ )
diff --git a/pos_default_quantity/models/uom_category.py b/pos_default_quantity/models/uom_category.py
index 99a9d2e1cc..78f1ce85cb 100644
--- a/pos_default_quantity/models/uom_category.py
+++ b/pos_default_quantity/models/uom_category.py
@@ -8,4 +8,9 @@
class UoMCategory(models.Model):
_inherit = "uom.category"
- pos_default_qty = fields.Float(string="POS Default Quantity", default=1)
+ # TODO: Should this be hidden behind a boolean toggle?
+ pos_default_qty = fields.Float(
+ string="POS Default Quantity",
+ required=True,
+ default=1,
+ )
diff --git a/pos_default_quantity/readme/DESCRIPTION.rst b/pos_default_quantity/readme/DESCRIPTION.rst
index eb53c274e5..2f4aa20c4c 100644
--- a/pos_default_quantity/readme/DESCRIPTION.rst
+++ b/pos_default_quantity/readme/DESCRIPTION.rst
@@ -1,4 +1,4 @@
This module adds a field for a default quantity to Unit of Measure Categories.
When this is filled in, and when this functionality is enabled in the Point of
-Sale Configuration, then adding that product to an order in the Point of Sale
+Sale configuration, then adding that product to an order in the Point of Sale
will set the quantity to that value by default.
diff --git a/pos_default_quantity/readme/USAGE.rst b/pos_default_quantity/readme/USAGE.rst
new file mode 100644
index 0000000000..b4194c6294
--- /dev/null
+++ b/pos_default_quantity/readme/USAGE.rst
@@ -0,0 +1,8 @@
+In order to set this up, you need to do a few things:
+
+- Make sure that you have permissions to manage multiple units of measure.
+- In the settings of Inventory, enable units of measure.
+- For each relevant unit of measure category, determine a default product quantity
+ (default: 1).
+- For each relevant Point of Sale, find 'Set default product quantity' in the
+ 'Technical' section of its settings, and toggle it on.
diff --git a/pos_default_quantity/static/description/index.html b/pos_default_quantity/static/description/index.html
index 0a9ae974a0..1e42f47e4b 100644
--- a/pos_default_quantity/static/description/index.html
+++ b/pos_default_quantity/static/description/index.html
@@ -371,22 +371,35 @@
Set Default Product Quantity in POS
This module adds a field for a default quantity to Unit of Measure Categories.
When this is filled in, and when this functionality is enabled in the Point of
-Sale Configuration, then adding that product to an order in the Point of Sale
+Sale configuration, then adding that product to an order in the Point of Sale
will set the quantity to that value by default.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
@@ -394,22 +407,22 @@