[IMP] event_sale: move total sales information from kanban to form view

Purpose of this commit is to slightly improve event / sales integration,
notably finding sale orders from an event.

Specifications

  * remove sales information from event kanban view;
  * add it as a stat button on form view;
  * clicking on this button should redirect to the orders linked to that
    event, in no create mode to avoid creating de-synchronized data;

Task ID 2170831
PR #43173
This commit is contained in:
Debauche Stéphane
2020-01-27 11:21:28 +00:00
committed by Thibault Delavallée
parent 23fae21cc7
commit ea6ab15d39
2 changed files with 24 additions and 12 deletions
+9
View File
@@ -83,3 +83,12 @@ class Event(models.Model):
non_open_events = self.filtered(lambda event: not any(event.event_ticket_ids.mapped('sale_available')))
non_open_events.event_registrations_open = False
super(Event, self - non_open_events)._compute_event_registrations_open()
def action_view_linked_orders(self):
""" Redirects to the orders linked to the current events """
sale_order_action = self.env.ref('sale.action_orders').read()[0]
sale_order_action.update({
'domain': [('state', '!=', 'cancel'), ('order_line.event_id', 'in', self.ids)],
'context': {'create': 0},
})
return sale_order_action
+15 -12
View File
@@ -88,6 +88,21 @@
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<field name="currency_id" invisible="1"/>
<button name="action_view_linked_orders"
type="object" class="oe_stat_button" icon="fa-dollar"
help="Total sales for this event"
attrs="{'invisible': ['|', ('sale_price_subtotal', '=', 0), ('sale_price_subtotal', '=', False)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field string="Sales" name="sale_price_subtotal"
widget="monetary" options="{'currency_field': 'currency_id'}"/>
</span>
<span class="o_stat_text">Sales</span>
</div>
</button>
</xpath>
<page name="event_communication" position="before">
<page string="Tickets" name="tickets">
<field name="event_ticket_ids" context="{'default_name': name}" mode="tree,kanban">
@@ -145,18 +160,6 @@
</field>
</record>
<record id="event_view_kanban" model="ir.ui.view">
<field name="name">event.kanban.inherit</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_event_duration_str')]" position="after">
<field name="currency_id" invisible="1"/>
<div attrs="{'invisible': [('sale_price_subtotal', '&lt;=', 0)]}">Sales <field name="sale_price_subtotal" widget="monetary"/></div>
</xpath>
</field>
</record>
<record id="event_ticket_form_view" model="ir.ui.view">
<field name="name">event.event.ticket.form</field>
<field name="model">event.event.ticket</field>