Skip to content

Commit

Permalink
Merge pull request #324 from beescoop/12.0-use-max_nb_eater-defined-i…
Browse files Browse the repository at this point in the history
…n-the-share

[FIX] use max_nb_eater defined in the share
  • Loading branch information
remytms authored Apr 14, 2022
2 parents 676b280 + 90abf9f commit 5152bfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 66 deletions.
11 changes: 3 additions & 8 deletions beesdoo_pos/models/beesdoo_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
class BeescoopPosPartner(models.Model):
_inherit = "res.partner"

def _get_eater(self):
eaters = [False, False, False]
for i, eater in enumerate(self.child_eater_ids):
eaters[i] = eater.name
return tuple(eaters)

@api.multi
def get_eater(self):
eater1, eater2, eater3 = self._get_eater()
return eater1, eater2, eater3
self.ensure_one()
# todo check for max eater
return [eater.name for eater in self.child_eater_ids]
54 changes: 13 additions & 41 deletions beesdoo_pos/static/src/js/beesdoo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ 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 = document.createElement("div");
info_div.textContent = value;
if (value) {
el.append(value);
parent.append(info_div);
}
};

Expand All @@ -39,23 +37,12 @@ odoo.define("beesdoo_pos.screens", function (require) {
}
)
.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: "
result.forEach((client_name) =>
set_customer_info.call(
self,
".customer-information-pay",
client_name
)
);
})
.fail(function (type, error) {
Expand Down Expand Up @@ -91,23 +78,8 @@ 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: "
result.forEach((client_name) =>
set_customer_info.call(self, ".customer-delegates", client_name)
);
})
.fail(function (type, error) {
Expand Down
20 changes: 3 additions & 17 deletions beesdoo_pos/static/src/xml/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,16 @@
<t t-extend="ActionpadWidget">
<t t-jquery="t[t-if='widget.pos.get_client()']" t-operation="after">
<t t-if="widget.pos.get_client()">
<div class='customer-information-pay'>
<span class='customer-delegate1' />
<br />
<span class='customer-delegate2' />
<br />
<span class='customer-delegate3' />
</div>
<div class='customer-information-pay' />
</t>
</t>
</t>

<t t-extend="PaymentScreenWidget">
<t t-jquery=".paymentmethods-container" t-operation="inner">
<t t-if="widget.pos.get_client()">
<div class="customer-information">
<span class='customer-name' />
<br />
<span class='customer-delegate1' />
<br />
<span class='customer-delegate2' />
<br />
<span class='customer-delegate3' />
<br />
</div>
<div class="customer-name" />
<div class="customer-delegates" />
</t>
</t>
</t>
Expand Down

0 comments on commit 5152bfc

Please sign in to comment.