Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4 Vastaukset
12306 Näkymät

I am on Odoo 12 and I have a state selection field with three values (a, b, c) with (a) as the default value.

Example :

    state = fields.Selection(string="Statut", selection=[('a', 'Statut A'),
                                                         ('b', 'Statut B'), ('c', 'Statut C'),
                                                         ('d', 'Statut D'), ],
                             default="a", track_visibility='onchange', )

Everything was working fine until I added a new value (e), which I wanted to be before (a) and to become the default value, something like this :

    state = fields.Selection(string="Statut", selection=[('e', 'Statut E'),
                                                         ('a', 'Statut A'),
                                                         ('b', 'Statut B'), ('c', 'Statut C'),
                                                         ('d', 'Statut D'), ],
                             default="e", track_visibility='onchange', )

The problem is that when I call this field on the statusbar in the XML code, it doesn't display the status (e), as if it didn't take it as default, and it still takes (a) as the first status whenever I wanted to create a new entry in the form view.

This is the header part of the form view where the statusbar and its buttons should go :

<form string="Form 1">
<header>
<button name="fct4" string="Go to A" class="oe_highlight" states="e" type="object"/>
<button name="fct1" string="Go to B" class="oe_highlight" states="a" type="object"/>
<button name="fct2" string="Go to C" class="oe_highlight" states="b" type="object"/>
<button name="fct3" string="Go to D" states="e,a,b" type="object"/>
<field name="state" widget="statusbar" statusbar_visible="e,a,b,c"/>
</header>


Avatar
Hylkää

Odoo Customization Tips:

Odoo is one of the best option for the ERP.

#odoo #openerp #ERP #customization

#tips #training #development #guide #python

These tips help you to get the basic idea about customization in odoo

https://learnopenerp.tumblr.com/

Paras vastaus
Try like this

state = fields.Selection(string="Statut", selection_add="[('e', 'e')]", default='e')
Avatar
Hylkää
Tekijä

Where do I put this instruction? I tried both in the declaration of the model and in the create function but still no results

Paras vastaus

The answer is simple just change the name of your field from 'state' to 'anythingnelse' then it will work perfect. Thank You

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
huhtik. 22
6377
2
lokak. 23
920
3
tammik. 24
15937
1
tammik. 25
2815
1
toukok. 22
2908