Skip to content

Commit 514bc17

Browse files
committed
[RENAME] Renamed pos_partner_birthdate_warning to pos_customer_age_warning
1 parent d1ccc27 commit 514bc17

20 files changed

+83
-38
lines changed

pos_partner_birthdate_warning/README.rst renamed to pos_customer_age_warning/README.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
=============================
2-
POS Partner Birthdate Warning
3-
=============================
1+
========================
2+
POS Customer Age Warning
3+
========================
44

55
..
66
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -17,10 +17,10 @@ POS Partner Birthdate Warning
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/17.0/pos_partner_birthdate_warning
20+
:target: https://github.com/OCA/pos/tree/17.0/pos_customer_age_warning
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-17-0/pos-17-0-pos_partner_birthdate_warning
23+
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_customer_age_warning
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
2626
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0
@@ -92,7 +92,7 @@ Bug Tracker
9292
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
9393
In case of trouble, please check there if your issue has already been reported.
9494
If you spotted it first, help us to smash it by providing a detailed and welcomed
95-
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_birthdate_warning%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
95+
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_customer_age_warning%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
9696

9797
Do not contact contributors directly about support or help with technical issues.
9898

@@ -125,6 +125,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
125125
mission is to support the collaborative development of Odoo features and
126126
promote its widespread use.
127127

128-
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_partner_birthdate_warning>`_ project on GitHub.
128+
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_customer_age_warning>`_ project on GitHub.
129129

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

pos_partner_birthdate_warning/__manifest__.py renamed to pos_customer_age_warning/__manifest__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2025 Invitu SARL
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
{
4-
"name": "POS Partner Birthdate Warning",
4+
"name": "POS Customer Age Warning",
55
"summary": "Display customer's age in POS interface according to the age setting",
66
"version": "17.0.0.1.0",
77
"category": "Point of sale",
@@ -15,9 +15,11 @@
1515
],
1616
"assets": {
1717
"point_of_sale._assets_pos": [
18-
"pos_partner_birthdate_warning/static/src/xml/actionpad_widget.xml",
19-
"pos_partner_birthdate_warning/static/src/js/PartnerListScreen.esm.js",
20-
"pos_partner_birthdate_warning/static/src/js/pos_store.esm.js",
18+
"pos_customer_age_warning/static/src/xml/actionpad_widget.xml",
19+
"pos_customer_age_warning/static/src/js/PartnerListScreen.esm.js",
20+
"pos_customer_age_warning/static/src/js/ProductScreen.esm.js",
21+
"pos_customer_age_warning/static/src/js/partner_editor.esm.js",
22+
"pos_customer_age_warning/static/src/js/pos_store.esm.js",
2123
]
2224
},
2325
}

pos_partner_birthdate_warning/static/description/index.html renamed to pos_customer_age_warning/static/description/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>POS Partner Birthdate Warning</title>
6+
<title>POS Customer Age Warning</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="pos-partner-birthdate-warning">
364-
<h1 class="title">POS Partner Birthdate Warning</h1>
363+
<div class="document" id="pos-customer-age-warning">
364+
<h1 class="title">POS Customer Age Warning</h1>
365365

366366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:a7e57dda136a17f1f09419221c8e5b52523d147b935e8575002b803e24787aca
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
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/17.0/pos_partner_birthdate_warning"><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-17-0/pos-17-0-pos_partner_birthdate_warning"><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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
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/17.0/pos_customer_age_warning"><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-17-0/pos-17-0-pos_customer_age_warning"><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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module enhances Odoo’s Point of Sale (POS) by introducing an age
374374
verification system. When a customer is selected, their age (based on
375375
their date of birth) is checked against the predefined <strong>“Age Warning”</strong>
@@ -435,7 +435,7 @@ <h3><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h3>
435435
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
436436
In case of trouble, please check there if your issue has already been reported.
437437
If you spotted it first, help us to smash it by providing a detailed and welcomed
438-
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_partner_birthdate_warning%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
438+
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_customer_age_warning%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
439439
<p>Do not contact contributors directly about support or help with technical issues.</p>
440440
</div>
441441
<div class="section" id="credits">
@@ -468,7 +468,7 @@ <h1>Maintainers</h1>
468468
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
469469
mission is to support the collaborative development of Odoo features and
470470
promote its widespread use.</p>
471-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/17.0/pos_partner_birthdate_warning">OCA/pos</a> project on GitHub.</p>
471+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/17.0/pos_customer_age_warning">OCA/pos</a> project on GitHub.</p>
472472
<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>
473473
</div>
474474
</div>

pos_partner_birthdate_warning/static/src/js/PartnerListScreen.esm.js renamed to pos_customer_age_warning/static/src/js/PartnerListScreen.esm.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import {PartnerListScreen} from "@point_of_sale/app/screens/partner_list/partner_list";
44
import {patch} from "@web/core/utils/patch";
5-
import {_t} from "@web/core/l10n/translation";
6-
import {AlertDialog} from "@web/core/confirmation_dialog/confirmation_dialog";
7-
import {sprintf} from "@web/core/utils/strings";
85

96
patch(PartnerListScreen.prototype, {
107
/**
@@ -13,24 +10,12 @@ patch(PartnerListScreen.prototype, {
1310
*
1411
* @param {Object} partner - The partner object being selected.
1512
*/
16-
clickPartner(partner) {
13+
async clickPartner(partner) {
1714
// If the same partner is selected again, proceed with the default behavior
1815
if (this.state.selectedPartner?.id === partner.id) {
1916
return super.clickPartner(partner);
2017
}
21-
22-
// Show warning if the partner is under the age restriction
23-
if (this.pos.isUnderagePartner(partner)) {
24-
this.env.services.dialog.add(AlertDialog, {
25-
title: _t("Age Restriction"),
26-
body: sprintf(
27-
_t("%s is under %s years old!"),
28-
partner.name,
29-
this.pos.company.age_warning
30-
),
31-
});
32-
}
33-
18+
await this.pos.ageRestrictionDialog(partner);
3419
return super.clickPartner(partner);
3520
},
3621
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** @odoo-module */
2+
3+
import {ProductScreen} from "@point_of_sale/app/screens/product_screen/product_screen";
4+
import {patch} from "@web/core/utils/patch";
5+
6+
patch(ProductScreen.prototype, {
7+
async _barcodePartnerAction(code) {
8+
const partner = await this._getPartnerByBarcode(code);
9+
if (partner) {
10+
await this.pos.ageRestrictionDialog(partner);
11+
}
12+
return super._barcodePartnerAction(code);
13+
},
14+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/** @odoo-module */
2+
3+
import {_t} from "@web/core/l10n/translation";
4+
import {AlertDialog} from "@web/core/confirmation_dialog/confirmation_dialog";
5+
import {PartnerDetailsEdit} from "@point_of_sale/app/screens/partner_list/partner_editor/partner_editor";
6+
import {patch} from "@web/core/utils/patch";
7+
import {sprintf} from "@web/core/utils/strings";
8+
9+
patch(PartnerDetailsEdit.prototype, {
10+
async checkAgeRestriction(partnerName) {
11+
await this.env.services.dialog.add(AlertDialog, {
12+
title: _t("Age Restriction"),
13+
body: sprintf(
14+
_t(
15+
"%s is under %s years old!",
16+
partnerName,
17+
this.pos.company.age_warning
18+
)
19+
),
20+
});
21+
},
22+
async saveChanges() {
23+
const {partner} = this.props;
24+
const {birthdate_date = partner.birthdate_date, name = partner.name} =
25+
this.changes;
26+
if (this.pos.isUnderagePartner(birthdate_date)) {
27+
await this.checkAgeRestriction(name);
28+
}
29+
return super.saveChanges(...arguments);
30+
},
31+
});

pos_partner_birthdate_warning/static/src/js/pos_store.esm.js renamed to pos_customer_age_warning/static/src/js/pos_store.esm.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @odoo-module */
22

3+
import {AlertDialog} from "@web/core/confirmation_dialog/confirmation_dialog";
34
const {DateTime} = luxon;
45
import {PosStore} from "@point_of_sale/app/store/pos_store";
56
import {patch} from "@web/core/utils/patch";
@@ -38,10 +39,9 @@ patch(PosStore.prototype, {
3839
* @param {Object} partner - The partner object.
3940
* @returns {Boolean} - True if the partner is underage, otherwise false.
4041
*/
41-
isUnderagePartner(partner) {
42-
if (!partner || !partner.birthdate_date) return false;
42+
isUnderagePartner(birthdate) {
4343
return (
44-
this.evaluatePartnerAge(partner.birthdate_date) <= this.company.age_warning
44+
birthdate && this.evaluatePartnerAge(birthdate) <= this.company.age_warning
4545
);
4646
},
4747

@@ -55,4 +55,17 @@ patch(PosStore.prototype, {
5555
if (!partner || !partner.birthdate_date) return "";
5656
return sprintf(_t("(%s y)"), this.evaluatePartnerAge(partner.birthdate_date));
5757
},
58+
async ageRestrictionDialog(partner) {
59+
if (!partner || !partner.birthdate_date) return false;
60+
if (this.isUnderagePartner(partner.birthdate_date)) {
61+
await this.env.services.dialog.add(AlertDialog, {
62+
title: _t("Age Restriction"),
63+
body: sprintf(
64+
_t("%s is under %s years old!"),
65+
partner.name,
66+
this.company.age_warning
67+
),
68+
});
69+
}
70+
},
5871
});

pos_partner_birthdate_warning/static/src/xml/actionpad_widget.xml renamed to pos_customer_age_warning/static/src/xml/actionpad_widget.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<xpath expr="//div[@t-if='props.partner']" position="replace">
99
<div
1010
t-if="props.partner"
11-
t-attf-class="{{pos.isUnderagePartner(props.partner) ? 'text-danger' : ' text-action'}}"
11+
t-attf-class="{{pos.isUnderagePartner(props.partner.birthdate_date) ? 'text-danger' : ' text-action'}}"
1212
class="text-truncate fw-bolder"
1313
>
1414
<t t-esc="props.partner.name" />

0 commit comments

Comments
 (0)