diff --git a/pos_eater/__manifest__.py b/pos_eater/__manifest__.py index f5623914f..8539e02ad 100644 --- a/pos_eater/__manifest__.py +++ b/pos_eater/__manifest__.py @@ -14,16 +14,15 @@ "author": "BEES coop - Cellule IT, Coop IT Easy SC", "website": "https://github.com/beescoop/Obeesdoo", "category": "Point Of Sale", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "depends": ["point_of_sale", "eater"], - "data": ["views/assets.xml"], "assets": { "point_of_sale.assets": [ + "pos_eater/static/src/css/pos.css", "pos_eater/static/src/js/**/*.js", "pos_eater/static/src/xml/**/*.xml", ], - } - "qweb": ["static/src/xml/templates.xml"], + }, "installable": True, "license": "AGPL-3", } diff --git a/pos_eater/models/__init__.py b/pos_eater/models/__init__.py index 91fed54d4..3d937eb7a 100644 --- a/pos_eater/models/__init__.py +++ b/pos_eater/models/__init__.py @@ -1 +1,2 @@ +from . import pos_session from . import res_partner diff --git a/pos_eater/models/pos_session.py b/pos_eater/models/pos_session.py new file mode 100644 index 000000000..85b949b09 --- /dev/null +++ b/pos_eater/models/pos_session.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def _loader_params_res_partner(self): + result = super()._loader_params_res_partner() + result["search_params"]["fields"].append("child_eater_ids") + return result diff --git a/pos_eater/static/src/css/pos.css b/pos_eater/static/src/css/pos.css new file mode 100644 index 000000000..1695487eb --- /dev/null +++ b/pos_eater/static/src/css/pos.css @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2024 Coop IT Easy SC + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +.pos .actionpad .button.set-partner .eaters { + font-weight: normal; + display: inline-block; +} diff --git a/pos_eater/static/src/js/ActionpadWidget.js b/pos_eater/static/src/js/ActionpadWidget.js new file mode 100644 index 000000000..bc7901f11 --- /dev/null +++ b/pos_eater/static/src/js/ActionpadWidget.js @@ -0,0 +1,22 @@ +/** @odoo-module alias=pos_eater.ActionpadWidget **/ +// SPDX-FileCopyrightText: 2024 Coop IT Easy SC +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +import Registries from "point_of_sale.Registries"; + +const ActionpadWidget = require("point_of_sale.ActionpadWidget"); + +export const EaterActionpadWidget = (ActionpadWidget) => + class extends ActionpadWidget { + + get eaterNames() { + const names = this.props.partner.child_eater_ids.map( + id => this.env.pos.db.get_partner_by_id(id).name + ); + return names.join(", "); + } + + }; + +Registries.Component.extend(ActionpadWidget, EaterActionpadWidget); diff --git a/pos_eater/static/src/js/screens.js b/pos_eater/static/src/js/screens.js deleted file mode 100644 index 230478928..000000000 --- a/pos_eater/static/src/js/screens.js +++ /dev/null @@ -1,41 +0,0 @@ -odoo.define("pos_eater.screens", function (require) { - "use strict"; - var screens = require("point_of_sale.screens"); - var models = require("point_of_sale.models"); - - models.load_fields("res.partner", "is_company"); - - screens.ActionpadWidget.include({ - renderElement: function () { - var self = this; - var loaded = new $.Deferred(); - this._super(); - var client = this.pos.get_client(); - if (!client) { - return; - } - this._rpc( - { - model: "res.partner", - method: "get_eater", - args: [client.id], - }, - { - shadow: true, - }, - { - timeout: 1000, - } - ) - .then(function (result) { - var eaters = result.join("
"); - self.$(".customer-information-pay").html(eaters); - loaded.resolve(); - }) - .fail(function (type, error) { - loaded.reject(error); - }); - return loaded; - }, - }); -}); diff --git a/pos_eater/static/src/xml/ActionpadWidget.xml b/pos_eater/static/src/xml/ActionpadWidget.xml new file mode 100644 index 000000000..4b9b4dc7f --- /dev/null +++ b/pos_eater/static/src/xml/ActionpadWidget.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/pos_eater/static/src/xml/templates.xml b/pos_eater/static/src/xml/templates.xml deleted file mode 100644 index 8e27f53aa..000000000 --- a/pos_eater/static/src/xml/templates.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -
- - - - -