On Sunday, February 14, 2016 at 8:00:03 PM UTC+10, Cédric Krier wrote:
>
> 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. 
>

The available choices for this selection field does not include an option 
with the value None.
 

>
> > 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. 
>


So somehow the client sends the value 'None' for the field State... 

-- 
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/ea7b4c30-41e9-45b2-b469-ca0fe37f3780%40googlegroups.com.

Reply via email to