Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7672 มุมมอง

Hello!

We have a Kanban view grouped by a field called "state". This field only has 4 possible values (New, Allotted, Released, Invoiced).

When sorting by state field, we can only do ascending or descending. The ascending order is as follows: Allotted-Invoiced-New-Released.

How can we do the following sort?: New - Allotted - Released - Invoiced


Odoo 14: Community.


Regards!

Alberto

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

if the field 'state' is of the type 'Selection', you would hardly achieve the goal in a simple manner.

The point is that 'Selection' represents char (string) in the database, so ordering means alphabetical order. In such a case the easiest way, is to rename the states (e.g. to have a number at the beginning).

Otherwise, make the state of the many2one type with a reference to another model (have a look how it is done in crm.lead & crm.stage). In such a case you would be able to select the param _order of that related model (e.g. sequence in the case of crm.lead)

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hello faOtools,

Thanks for you answer. In effect, the field is type "selection":

state = fields.Selection([('new','New'),('allotted','Allotted'),('released','Released'),('invoiced','Invoiced')], string="Stages", default="new", required=True, tracking=True)

Is there way to do it with the field type "selection"?

อวตาร
ละทิ้ง

Hello, as I said in the answer the easiest way is to add an integer at the beginning: ('1_new', '1. New').

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ค. 20
10597
1
มิ.ย. 23
2672
2
พ.ค. 20
5900
1
ก.พ. 19
6903
0
ม.ค. 19
5921