diff --git a/event_sale_session/i18n/es.po b/event_sale_session/i18n/es.po index 9d05a128d..0c8d56564 100644 --- a/event_sale_session/i18n/es.po +++ b/event_sale_session/i18n/es.po @@ -113,6 +113,11 @@ msgstr "Informe analítico de ventas" msgid "Sales Order Line" msgstr "Línea de pedido de venta" +#. module: event_sale_session +#: model:ir.model.fields,field_description:event_sale_session.field_event_session__order_line_ids +msgid "Sales Order Lines" +msgstr "Líneas de pedido de venta" + #. module: event_sale_session #: model:ir.model.fields,field_description:event_sale_session.field_event_event_configurator__event_session_id #: model:ir.model.fields,field_description:event_sale_session.field_registration_editor_line__session_id @@ -136,6 +141,26 @@ msgstr "Evento estándar + catering" msgid "Total sales for this session" msgstr "Total de ventas para esta sesión" +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_tree +msgid "Total unconfirmed seats in orders" +msgstr "Total plazas de pedidos no confirmados" + +#. module: event_sale_session +#: model:ir.model.fields,field_description:event_sale_session.field_event_session__unconfirmed_qty +msgid "Unconfirmed Qty" +msgstr "Cantidad sin asignar" + +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_form +msgid "Unconfirmed order seats" +msgstr "Plazas en pedidos sin confirmar" + +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_form +msgid "Unconfirmed orders seats" +msgstr "Plazas en pedidos sin confirmar" + #. module: event_sale_session #: model:event.event.ticket,name:event_sale_session.event_ticket_007_vip msgid "VIP" diff --git a/event_sale_session/i18n/event_sale_session.pot b/event_sale_session/i18n/event_sale_session.pot index 641110ceb..2880b8016 100644 --- a/event_sale_session/i18n/event_sale_session.pot +++ b/event_sale_session/i18n/event_sale_session.pot @@ -109,6 +109,11 @@ msgstr "" msgid "Sales Order Line" msgstr "" +#. module: event_sale_session +#: model:ir.model.fields,field_description:event_sale_session.field_event_session__order_line_ids +msgid "Sales Order Lines" +msgstr "" + #. module: event_sale_session #: model:ir.model.fields,field_description:event_sale_session.field_event_event_configurator__event_session_id #: model:ir.model.fields,field_description:event_sale_session.field_registration_editor_line__session_id @@ -132,6 +137,26 @@ msgstr "" msgid "Total sales for this session" msgstr "" +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_tree +msgid "Total unconfirmed seats in orders" +msgstr "" + +#. module: event_sale_session +#: model:ir.model.fields,field_description:event_sale_session.field_event_session__unconfirmed_qty +msgid "Unconfirmed Qty" +msgstr "" + +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_form +msgid "Unconfirmed order seats" +msgstr "" + +#. module: event_sale_session +#: model_terms:ir.ui.view,arch_db:event_sale_session.view_event_session_form +msgid "Unconfirmed orders seats" +msgstr "" + #. module: event_sale_session #: model:event.event.ticket,name:event_sale_session.event_ticket_007_vip msgid "VIP" diff --git a/event_sale_session/models/event_session.py b/event_sale_session/models/event_session.py index 2e28bf7d1..7bdb6528d 100644 --- a/event_sale_session/models/event_session.py +++ b/event_sale_session/models/event_session.py @@ -22,6 +22,37 @@ class EventSession(models.Model): compute="_compute_sale_price_subtotal", groups="sales_team.group_sale_salesman", ) + unconfirmed_qty = fields.Integer( + compute="_compute_unconfirmed_qty", + store=True, + ) + + @api.depends( + "sale_order_lines_ids", + "sale_order_lines_ids.product_uom_qty", + "sale_order_lines_ids.order_id.state", + ) + def _compute_unconfirmed_qty(self): + for session in self: + session.unconfirmed_qty = int( + sum( + session.sale_order_lines_ids.filtered( + lambda x: x.order_id.state in ("draft", "sent") + ).mapped("product_uom_qty") + ) + ) + + def button_open_unconfirmed_event_order(self): + action = self.env["ir.actions.act_window"]._for_xml_id("sale.action_quotations") + sales = ( + self.env["sale.order.line"] + .search([("event_id", "in", self.ids)]) + .mapped("order_id") + .ids + ) + action["domain"] = [("id", "in", sales), ("state", "in", ("draft", "sent"))] + action["context"] = {} + return action @api.depends( "currency_id", diff --git a/event_sale_session/tests/test_event_sale_session.py b/event_sale_session/tests/test_event_sale_session.py index 7e2c99b4f..c8e7d6584 100644 --- a/event_sale_session/tests/test_event_sale_session.py +++ b/event_sale_session/tests/test_event_sale_session.py @@ -1,5 +1,6 @@ # Copyright 2017 Tecnativa - David Vidal # Copyright 2022 Moka Tourisme (https://www.mokatourisme.fr). +# Copyright 2024 Tecnativa - Carolina Fernandez # @author Iván Todorovich # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). @@ -36,7 +37,11 @@ def setUpClass(cls): def test_sale_session(self): """Sell an event with session""" + self.assertEqual(self.session.unconfirmed_qty, 5) + self.assertEqual(self.event.unconfirmed_qty, 5) self.order.action_confirm() + self.assertEqual(self.session.unconfirmed_qty, 0) + self.assertEqual(self.event.unconfirmed_qty, 0) regs = self.env["event.registration"].search( [("sale_order_id", "=", self.order.id)] ) diff --git a/event_sale_session/views/event_session.xml b/event_sale_session/views/event_session.xml index 6cdcb1cc1..17f36f49b 100644 --- a/event_sale_session/views/event_session.xml +++ b/event_sale_session/views/event_session.xml @@ -27,7 +27,33 @@ widget="statinfo" /> + + + event.session + + + + + + +