On 2016-02-13 14:44, Vincent Bastos wrote:
> 
> 
> On Sunday, February 14, 2016 at 12:15:04 AM UTC+10, Cédric Krier wrote:
> >
> > On 2016-02-13 02:20, Vincent Bastos wrote: 
> > > Hey, 
> > > 
> > > I am getting the following error for a state field: 
> > > 
> > > The value "None" of field "State" on "..." is not in the selection. 
> > > 
> > > However I do have the default method in the class: 
> > > 
> > >     @staticmethod 
> > >     def default_state(): 
> > >         return 'draft' 
> >
> > This means that you are creating a record with the value 'None' for the 
> > state field. The default value method is only used if there is no key 
> > for the field in the dictionary. 
> >
> 
> Tryton is telling me that I am trying to save a record with the field state 
> with a value None, but this field is required, so this is wrong. Right?

No, the field is not required but the value None is not in the selection
list.

> How can that be if the selection dictionary does not have any keys with 
> None values, and there is even a default method?

I don't understand what you are talking about. What are you calling
"selection dictionary"?
As I said default method is only used if you don't specify a value. Here
it is pretty sure that you put 'None' as value.

> Also, even the client displays the value 'draft' in that field before save 
> button is pressed.

You can not trust the client to display the erroneous value because it
is limited to display only value from the selection.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20160214095518.GA11535%40tetsuo.

Reply via email to