Skip to content

Commit 2869ccd

Browse files
committed
[19.0][MIG] pos partner birthdate: Migration to 19.0
1 parent ec8bff4 commit 2869ccd

6 files changed

Lines changed: 42 additions & 10 deletions

File tree

pos_partner_birthdate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Point of Sale - Partner contact birthdate",
55
"summary": "Adds the birthdate in the customer screen of POS",
6-
"version": "18.0.1.0.0",
6+
"version": "19.0.1.0.0",
77
"development_status": "Beta",
88
"category": "Point of sale",
99
"website": "https://github.com/OCA/pos",

pos_partner_birthdate/static/src/js/PartnerLine.esm.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import {patch} from "@web/core/utils/patch";
55

66
patch(PartnerLine.prototype, {
77
get formatedBirthdate() {
8-
if (!this.props.partner.birthdate_date) {
8+
const birthdate = this.props.partner.birthdate_date;
9+
if (!birthdate) {
910
return "";
1011
}
11-
return formatDate(parseDate(this.props.partner.birthdate_date));
12+
if (typeof birthdate === "string") {
13+
const parsedBirthdate = parseDate(birthdate);
14+
return parsedBirthdate ? formatDate(parsedBirthdate) : "";
15+
}
16+
return formatDate(birthdate);
1217
},
1318
});

pos_partner_birthdate/static/src/js/ResPartner.esm.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ patch(ResPartner.prototype, {
77
get searchString() {
88
let str = super.searchString;
99
if (this.birthdate_date) {
10-
const formattedDate = formatDate(parseDate(this.birthdate_date));
10+
let formattedDate = "";
11+
let rawDate = "";
12+
if (typeof this.birthdate_date === "string") {
13+
const parsedBirthdate = parseDate(this.birthdate_date);
14+
formattedDate = parsedBirthdate ? formatDate(parsedBirthdate) : "";
15+
rawDate = this.birthdate_date;
16+
} else {
17+
formattedDate = formatDate(this.birthdate_date);
18+
rawDate = this.birthdate_date.toISODate?.() || "";
19+
}
20+
if (!formattedDate) {
21+
return str;
22+
}
1123
const compactDate = formattedDate.replace(/[/.-]/g, "");
12-
str += ` ${formattedDate} ${compactDate} ${this.birthdate_date}`;
24+
str += ` ${formattedDate} ${compactDate} ${rawDate}`;
1325
}
1426
return str;
1527
},

pos_partner_birthdate/static/src/xml/screens.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates id="template" xml:space="preserve">
3-
<t t-inherit="point_of_sale.PartnerList" t-inherit-mode="extension" owl="1">
4-
<xpath expr="//thead/tr/th[hasclass('partner-line-email')]" position="before">
5-
<th class="partner-line-birthdate py-2">Birthdate</th>
6-
</xpath>
7-
</t>
83
<t t-inherit="point_of_sale.PartnerLine" t-inherit-mode="extension" owl="1">
94
<xpath expr="//tr/td[hasclass('partner-line-email')]" position="before">
105
<td class="partner-line-birthdate" t-if="!ui.isSmall">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_res_partner
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
from odoo.tests.common import TransactionCase
3+
4+
5+
class TestResPartnerPOSBirthdate(TransactionCase):
6+
@classmethod
7+
def setUpClass(cls):
8+
super().setUpClass()
9+
cls.partner = cls.env["res.partner"].create(
10+
{
11+
"name": "Test Partner",
12+
}
13+
)
14+
cls.config = cls.env["pos.config"].create({"name": "Test POS"})
15+
16+
def test_load_pos_data_fields_includes_birthdate(self):
17+
fields = self.partner._load_pos_data_fields(self.config.id)
18+
self.assertIn("birthdate_date", fields)
19+
self.assertEqual(fields.count("birthdate_date"), 1)

0 commit comments

Comments
 (0)