Skip to content
Permalink
Browse files

[IMP] event, website_event: sequence ordering added on event categories

Reorganise the categories of the events. Same behavior as "eCommerce Product
categories"

For the changes made in "main.py" I didn't manage to sort the types with
read_group (line 104). I decided to  use sort on the types list while browsing
EventType for the sequences i couldn't retrieve with read_group.

Related to task #1917687
  • Loading branch information...
fja-odoo committed Mar 21, 2019
1 parent 3cbb8d5 commit cbf9763326fbe50edf2f317a48db9c4c93e7bb43
Showing with 11 additions and 0 deletions.
  1. +3 −0 addons/event/models/event.py
  2. +1 −0 addons/event/views/event_views.xml
  3. +7 −0 addons/website_event/controllers/main.py
@@ -22,6 +22,7 @@
class EventType(models.Model):
_name = 'event.type'
_description = 'Event Category'
_order = 'sequence'

@api.model
def _get_default_event_type_mail_ids(self):
@@ -71,6 +72,8 @@ def _get_default_event_type_mail_ids(self):
'event.type.mail', 'event_type_id', string='Mail Schedule',
copy=False,
default=_get_default_event_type_mail_ids)
#misc
sequence = fields.Integer('sequence')

@api.onchange('has_seats_limitation')
def _onchange_has_seats_limitation(self):
@@ -135,6 +135,7 @@
<field name="model">event.type</field>
<field name="arch" type="xml">
<tree string="Event Category">
<field name="sequence" widget="handle"/>
<field name="name"/>
</tree>
</field>
@@ -4,6 +4,7 @@
import re
import werkzeug
import json
import sys

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
@@ -94,8 +95,14 @@ def dom_without(without):
if date[0] != 'old':
date[3] = Event.search_count(dom_without('date') + date[2])

def get_event_type_sequence(elem):
if(elem['event_type_id']):
return EventType.browse(elem['event_type_id'][0]).sequence
return sys.maxsize

domain = dom_without('type')
types = Event.read_group(domain, ["id", "event_type_id"], groupby=["event_type_id"], orderby="event_type_id")
types.sort(key=get_event_type_sequence)
types.insert(0, {
'event_type_id_count': sum([int(type['event_type_id_count']) for type in types]),
'event_type_id': ("all", _("All Categories"))

0 comments on commit cbf9763

Please sign in to comment.
You can’t perform that action at this time.