Skip to content

Commit

Permalink
[IMP] event_sale_session: Recovery unconfirmed quantity event
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinafernandez-tecnativa committed May 28, 2024
1 parent 0a4ab8f commit 39dd7ee
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
25 changes: 25 additions & 0 deletions event_sale_session/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
25 changes: 25 additions & 0 deletions event_sale_session/i18n/event_sale_session.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions event_sale_session/models/event_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions event_sale_session/tests/test_event_sale_session.py
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).

Expand Down Expand Up @@ -36,7 +37,9 @@ def setUpClass(cls):

def test_sale_session(self):
"""Sell an event with session"""
self.assertEqual(self.session.unconfirmed_qty, 5)
self.order.action_confirm()
self.assertEqual(self.session.unconfirmed_qty, 0)
regs = self.env["event.registration"].search(
[("sale_order_id", "=", self.order.id)]
)
Expand Down
26 changes: 26 additions & 0 deletions event_sale_session/views/event_session.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,33 @@
widget="statinfo"
/>
</button>
<button
name="button_open_unconfirmed_event_order"
type="object"
class="oe_stat_button"
icon="fa-eye-slash"
help="Unconfirmed orders seats"
>
<field
name="unconfirmed_qty"
widget="statinfo"
string="Unconfirmed order seats"
/>
</button>
</div>
</field>
</record>
<record id="view_event_session_tree" model="ir.ui.view">
<field name="model">event.session</field>
<field name="inherit_id" ref="event_session.view_event_session_tree" />
<field name="arch" type="xml">
<field name="seats_expected" position="after">
<field
name="unconfirmed_qty"
attrs="{'invisible': [('unconfirmed_qty','&lt;', 1)]}"
sum="Total unconfirmed seats in orders"
/>
</field>
</field>
</record>
</odoo>

0 comments on commit 39dd7ee

Please sign in to comment.