Skip to content

Commit 41f2d0b

Browse files
committed
[MIG] pos_require_product_quantity: Migration to 16.0
1 parent cded1e6 commit 41f2d0b

File tree

11 files changed

+106
-98
lines changed

11 files changed

+106
-98
lines changed

pos_require_product_quantity/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Require Product Quantity in POS
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
20-
:target: https://github.com/OCA/pos/tree/14.0/pos_require_product_quantity
20+
:target: https://github.com/OCA/pos/tree/16.0/pos_require_product_quantity
2121
:alt: OCA/pos
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_require_product_quantity
23+
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_require_product_quantity
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=14.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -45,7 +45,7 @@ Bug Tracker
4545
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
4646
In case of trouble, please check there if your issue has already been reported.
4747
If you spotted it first, help us to smash it by providing a detailed and welcomed
48-
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_require_product_quantity%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
48+
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_require_product_quantity%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
4949

5050
Do not contact contributors directly about support or help with technical issues.
5151

@@ -77,6 +77,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7777
mission is to support the collaborative development of Odoo features and
7878
promote its widespread use.
7979

80-
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/14.0/pos_require_product_quantity>`_ project on GitHub.
80+
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_require_product_quantity>`_ project on GitHub.
8181

8282
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

pos_require_product_quantity/__manifest__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Copyright 2019-2020 Coop IT Easy SCRLfs
22
# Robin Keunen <[email protected]>
3+
# Simon Hick <[email protected]>
34
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
45
{
56
"name": "Require Product Quantity in POS",
6-
"version": "14.0.1.0.0",
7+
"version": "16.0.1.0.0",
78
"author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)",
89
"website": "https://github.com/OCA/pos",
910
"license": "AGPL-3",
@@ -16,8 +17,11 @@
1617
"point_of_sale",
1718
],
1819
"data": [
19-
"views/pos_config.xml",
20-
"views/assets.xml",
20+
"views/res_config_settings_views.xml",
2121
],
22-
"installable": True,
22+
"assets": {
23+
"point_of_sale.assets": [
24+
"pos_require_product_quantity/static/src/js/**/*.js",
25+
]
26+
},
2327
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import pos_config
2+
from . import res_config_settings
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2025 Coop IT Easy SC
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
15
from odoo import fields, models
26

37

@@ -6,5 +10,5 @@ class PosConfig(models.Model):
610

711
require_product_quantity = fields.Boolean(
812
string="Require product quantity in POS",
9-
default=False,
13+
default=True,
1014
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 CoopITEasy - Simon Hick <[email protected]>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
_inherit = "res.config.settings"
9+
10+
pos_require_product_quantity = fields.Boolean(
11+
related="pos_config_id.require_product_quantity",
12+
readonly=False,
13+
)

pos_require_product_quantity/static/description/index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
@@ -369,7 +368,7 @@ <h1 class="title">Require Product Quantity in POS</h1>
369368
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370369
!! source digest: sha256:a1fad00649f0440a0c0f7fbf26ece3565d7cb34b7282ab2904a3051278e1398f
371370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/14.0/pos_require_product_quantity"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_require_product_quantity"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_require_product_quantity"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_require_product_quantity"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373372
<p>This module forbids adding empty order lines on POS orders.</p>
374373
<p>When clicking on the “Payment” button in the Point of Sale,
375374
a popup is shown if product quantity for one or more order
@@ -391,7 +390,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
391390
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
392391
In case of trouble, please check there if your issue has already been reported.
393392
If you spotted it first, help us to smash it by providing a detailed and welcomed
394-
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_require_product_quantity%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
393+
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_require_product_quantity%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
395394
<p>Do not contact contributors directly about support or help with technical issues.</p>
396395
</div>
397396
<div class="section" id="credits">
@@ -417,7 +416,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
417416
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
418417
mission is to support the collaborative development of Odoo features and
419418
promote its widespread use.</p>
420-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/14.0/pos_require_product_quantity">OCA/pos</a> project on GitHub.</p>
419+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_require_product_quantity">OCA/pos</a> project on GitHub.</p>
421420
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
422421
</div>
423422
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/** @odoo-module **/
2+
3+
/*
4+
Copyright 2019 Coop IT Easy SCRLfs
5+
Robin Keunen <[email protected]>
6+
Simon Hick <[email protected]>
7+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
8+
*/
9+
10+
import ProductScreen from "point_of_sale.ProductScreen";
11+
import Registries from "point_of_sale.Registries";
12+
13+
const PosRequireProductQuantityProductScreen = (OriginalProductScreen) =>
14+
class extends OriginalProductScreen {
15+
async _onClickPay() {
16+
if (this.env.pos.config.require_product_quantity) {
17+
const lines_without_qty = _.filter(
18+
this.env.pos.get_order().get_orderlines(),
19+
function (line) {
20+
return line.quantity === 0;
21+
}
22+
);
23+
if (lines_without_qty.length > 0) {
24+
await this.showPopup("ConfirmPopup", {
25+
title: this.env._t("Missing quantities"),
26+
body:
27+
this.env._t("No quantity set for products:") +
28+
"\n" +
29+
_.map(lines_without_qty, function (line) {
30+
return " - " + line.product.display_name;
31+
}).join("\n"),
32+
});
33+
return;
34+
}
35+
}
36+
super._onClickPay(...arguments);
37+
}
38+
};
39+
40+
Registries.Component.extend(ProductScreen, PosRequireProductQuantityProductScreen);

pos_require_product_quantity/static/src/js/screens.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

pos_require_product_quantity/views/assets.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

pos_require_product_quantity/views/pos_config.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)