From f4a5a86c428f37a85bff15c2ddfd6d66e0d8bd2a Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Fri, 18 Mar 2022 15:58:44 +0100 Subject: [PATCH 1/5] [FIX] use max_nb_eater defined in the share --- beesdoo_pos/models/beesdoo_pos.py | 21 +++++++---- beesdoo_pos/static/src/js/beesdoo.js | 54 +++++++++------------------- 2 files changed, 31 insertions(+), 44 deletions(-) diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index 5f6e839f1..2176cfa71 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -4,13 +4,20 @@ class BeescoopPosPartner(models.Model): _inherit = "res.partner" - def _get_eater(self): - eaters = [False, False, False] + @api.multi + def get_eater(self): + eaters = [False] * self._get_max_nb_eater_allowed() for i, eater in enumerate(self.child_eater_ids): eaters[i] = eater.name - return tuple(eaters) + return eaters - @api.multi - def get_eater(self): - eater1, eater2, eater3 = self._get_eater() - return eater1, eater2, eater3 + def _get_max_nb_eater_allowed(self): + if self.eater == "eater": + max_nb_eater_allowed = ( + self.parent_eater_id._cooperator_share_type().max_nb_eater_allowed + ) + else: + max_nb_eater_allowed = ( + self._cooperator_share_type().max_nb_eater_allowed + ) + return max_nb_eater_allowed diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js index 20bee2f21..2589f8b57 100644 --- a/beesdoo_pos/static/src/js/beesdoo.js +++ b/beesdoo_pos/static/src/js/beesdoo.js @@ -38,25 +38,15 @@ odoo.define("beesdoo_pos.screens", function (require) { timeout: 1000, } ) - .then(function (result) { - set_customer_info.call( - self, - ".customer-delegate1", - result[0], - "Eater 1: " - ); - set_customer_info.call( - self, - ".customer-delegate2", - result[1], - "Eater 2: " - ); - set_customer_info.call( - self, - ".customer-delegate3", - result[2], - "Eater 3: " - ); + .then(function(result) { + for (let i = 0; i < result.length; i++) { + set_customer_info.call( + self, + ".customer-delegate".concat(i + 1), + result[i], + "Eater".concat(i + 1, ": ") + ); + } }) .fail(function (type, error) { loaded.reject(error); @@ -91,24 +81,14 @@ odoo.define("beesdoo_pos.screens", function (require) { ".customer-name", self.pos.get_client().name ); - set_customer_info.call( - self, - ".customer-delegate1", - result[0], - "Eater 1: " - ); - set_customer_info.call( - self, - ".customer-delegate2", - result[1], - "Eater 2: " - ); - set_customer_info.call( - self, - ".customer-delegate3", - result[2], - "Eater 3: " - ); + for (let i = 0; i < result.length; i++) { + set_customer_info.call( + self, + ".customer-delegate".concat(i + 1), + result[i], + "Eater".concat(i + 1, ": ") + ); + } }) .fail(function (type, error) { loaded.reject(err); From ff18c5fad629a141163d35ff7c931fb834d1b44b Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Fri, 18 Mar 2022 18:24:55 +0100 Subject: [PATCH 2/5] fixup! [FIX] use max_nb_eater defined in the share --- beesdoo_pos/static/src/js/beesdoo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js index 2589f8b57..331bd5149 100644 --- a/beesdoo_pos/static/src/js/beesdoo.js +++ b/beesdoo_pos/static/src/js/beesdoo.js @@ -38,7 +38,7 @@ odoo.define("beesdoo_pos.screens", function (require) { timeout: 1000, } ) - .then(function(result) { + .then(function (result) { for (let i = 0; i < result.length; i++) { set_customer_info.call( self, From c5ffac7ef6ba932dd2a28875695091de06beca56 Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Tue, 22 Mar 2022 11:29:03 +0100 Subject: [PATCH 3/5] fixup! [FIX] use max_nb_eater defined in the share --- beesdoo_pos/models/beesdoo_pos.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index 2176cfa71..6390a99ad 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -6,6 +6,7 @@ class BeescoopPosPartner(models.Model): @api.multi def get_eater(self): + self.ensure_one() eaters = [False] * self._get_max_nb_eater_allowed() for i, eater in enumerate(self.child_eater_ids): eaters[i] = eater.name @@ -17,7 +18,5 @@ def _get_max_nb_eater_allowed(self): self.parent_eater_id._cooperator_share_type().max_nb_eater_allowed ) else: - max_nb_eater_allowed = ( - self._cooperator_share_type().max_nb_eater_allowed - ) + max_nb_eater_allowed = self._cooperator_share_type().max_nb_eater_allowed return max_nb_eater_allowed From 560d54aa7a1d1f5b09ecf72074ad1f731058406b Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Fri, 25 Mar 2022 14:46:44 +0100 Subject: [PATCH 4/5] [IMP] allow for n eaters in pos --- beesdoo_pos/models/beesdoo_pos.py | 16 +++--------- beesdoo_pos/static/src/js/beesdoo.js | 33 +++++++++--------------- beesdoo_pos/static/src/xml/templates.xml | 20 +++----------- 3 files changed, 19 insertions(+), 50 deletions(-) diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index 6390a99ad..c7e395244 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -7,16 +7,8 @@ class BeescoopPosPartner(models.Model): @api.multi def get_eater(self): self.ensure_one() - eaters = [False] * self._get_max_nb_eater_allowed() - for i, eater in enumerate(self.child_eater_ids): - eaters[i] = eater.name + eaters = [] + # todo check for max eater + for eater in self.child_eater_ids: + eaters.append(eater.name) return eaters - - def _get_max_nb_eater_allowed(self): - if self.eater == "eater": - max_nb_eater_allowed = ( - self.parent_eater_id._cooperator_share_type().max_nb_eater_allowed - ) - else: - max_nb_eater_allowed = self._cooperator_share_type().max_nb_eater_allowed - return max_nb_eater_allowed diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js index 331bd5149..ae62a771c 100644 --- a/beesdoo_pos/static/src/js/beesdoo.js +++ b/beesdoo_pos/static/src/js/beesdoo.js @@ -5,14 +5,11 @@ odoo.define("beesdoo_pos.screens", function (require) { models.load_fields("res.partner", "is_company"); - var set_customer_info = function (el_class, value, prefix) { - var el = this.$(el_class); - el.empty(); - if (prefix && value) { - value = prefix + value; - } + var set_customer_info = function (parent_class, value) { + var parent = this.$(parent_class); + var info_div = $("
").text(value); if (value) { - el.append(value); + parent.append(info_div[0]); } }; @@ -39,14 +36,13 @@ odoo.define("beesdoo_pos.screens", function (require) { } ) .then(function (result) { - for (let i = 0; i < result.length; i++) { + result.forEach((element) => set_customer_info.call( self, - ".customer-delegate".concat(i + 1), - result[i], - "Eater".concat(i + 1, ": ") - ); - } + ".customer-information-pay", + element + ) + ); }) .fail(function (type, error) { loaded.reject(error); @@ -81,14 +77,9 @@ odoo.define("beesdoo_pos.screens", function (require) { ".customer-name", self.pos.get_client().name ); - for (let i = 0; i < result.length; i++) { - set_customer_info.call( - self, - ".customer-delegate".concat(i + 1), - result[i], - "Eater".concat(i + 1, ": ") - ); - } + result.forEach((element) => + set_customer_info.call(self, ".customer-delegates", element) + ); }) .fail(function (type, error) { loaded.reject(err); diff --git a/beesdoo_pos/static/src/xml/templates.xml b/beesdoo_pos/static/src/xml/templates.xml index 02317c03f..b447c139b 100644 --- a/beesdoo_pos/static/src/xml/templates.xml +++ b/beesdoo_pos/static/src/xml/templates.xml @@ -3,13 +3,7 @@ -
- -
- -
- -
+
@@ -17,16 +11,8 @@ -
- -
- -
- -
- -
-
+
+
From 90abf9fb6a70ecc82548cac45d05ce3d75cb2298 Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Mon, 4 Apr 2022 11:47:10 +0200 Subject: [PATCH 5/5] fixup! [IMP] allow for n eaters in pos --- beesdoo_pos/models/beesdoo_pos.py | 5 +---- beesdoo_pos/static/src/js/beesdoo.js | 13 +++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/beesdoo_pos/models/beesdoo_pos.py b/beesdoo_pos/models/beesdoo_pos.py index c7e395244..1f1e58aac 100644 --- a/beesdoo_pos/models/beesdoo_pos.py +++ b/beesdoo_pos/models/beesdoo_pos.py @@ -7,8 +7,5 @@ class BeescoopPosPartner(models.Model): @api.multi def get_eater(self): self.ensure_one() - eaters = [] # todo check for max eater - for eater in self.child_eater_ids: - eaters.append(eater.name) - return eaters + return [eater.name for eater in self.child_eater_ids] diff --git a/beesdoo_pos/static/src/js/beesdoo.js b/beesdoo_pos/static/src/js/beesdoo.js index ae62a771c..3944da752 100644 --- a/beesdoo_pos/static/src/js/beesdoo.js +++ b/beesdoo_pos/static/src/js/beesdoo.js @@ -7,9 +7,10 @@ odoo.define("beesdoo_pos.screens", function (require) { var set_customer_info = function (parent_class, value) { var parent = this.$(parent_class); - var info_div = $("
").text(value); + var info_div = document.createElement("div"); + info_div.textContent = value; if (value) { - parent.append(info_div[0]); + parent.append(info_div); } }; @@ -36,11 +37,11 @@ odoo.define("beesdoo_pos.screens", function (require) { } ) .then(function (result) { - result.forEach((element) => + result.forEach((client_name) => set_customer_info.call( self, ".customer-information-pay", - element + client_name ) ); }) @@ -77,8 +78,8 @@ odoo.define("beesdoo_pos.screens", function (require) { ".customer-name", self.pos.get_client().name ); - result.forEach((element) => - set_customer_info.call(self, ".customer-delegates", element) + result.forEach((client_name) => + set_customer_info.call(self, ".customer-delegates", client_name) ); }) .fail(function (type, error) {