i want to group_by my projects with its state and the state is a selection field (initiation, implementation, execution, monitoring, testing, closure phase , closed, pending) but the problem is when i group_by the projects it grouped with alphabetical sort but i need it ordered by the same order in the selection field , could anyone help me ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilitat
- Inventari
- PoS
- Project
- MRP
This question has been flagged
1
Respondre
15838
Vistes
In version 8
You need to override the function read_group like this:
@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if 'state' in groupby:
orderby = 'state ASC' + (orderby and (',' + orderby) or '')
return super(trobz_crm_lead, self).read_group( domain, fields, groupby, offset=0, limit=limit, orderby=orderby, lazy=lazy)
Note that in case you need to order on a field many2one, the default order by field of the model will be used. However, the ASC/DESC is ignored so you will need to use a similar way as above to force the ASC/DESC.
@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if 'state_id' in groupby:
orderby = 'state_id ASC' + (orderby and (',' + orderby) or '')
return super(trobz_crm_lead, self).read_group( domain, fields, groupby, offset=0, limit=limit, orderby=orderby, lazy=lazy)
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-seRelated Posts | Respostes | Vistes | Activitat | |
---|---|---|---|---|
|
0
de març 15
|
4095 | ||
|
1
de març 15
|
4730 | ||
|
1
de jul. 25
|
522 | ||
|
2
de juny 25
|
2428 | ||
|
1
de juny 25
|
896 |