El lunes, 21 de agosto de 2017, 17:15:45 (UTC-3), Francisco Maria Moyano Casco 
escribió:
> El lunes, 21 de agosto de 2017, 14:34:33 (UTC-3), Francisco Maria Moyano 
> Casco escribió:
> > > (You have mixed transition request and method draft in your code... )
> > > 
> > > 
> > > Regards
> > > 
> > > 
> > > Sebastián Marró
> > 
> > Hello Seba,
> >     Thanks for the answer! But, no it isn't that.
> > 
> >     I'm using the richtext widget on a text field, and that is the problem. 
> > When a take it off, the problem is solved by itself. When I put it back, 
> > the problem is on again.
> > 
> >     Can anyone confirm this kind of behaviour? Maybe is a bug.
> > 
> >     Regards,
> >           Francisco
> 
> I study all the alternatives, and this how to reproduce this issue:
> 
>  1. Make a fields.Char or a fields.Text. For now, we will call it 
> simple_string:
> class MyClass(Workflow, ModelSQL, ModelView):
>      ....
>      simple_string = fields.Char('My string')
>      ....
>  2. Add now the transitions and define a button to it:
>     
>      @classmethod
>      def __setup__(cls):
>        super(MyClass, cls).__setup__()
>        cls._transitions |= set((
>           ('draft','request'),
>          ))
> 
>        cls._buttons.update({
>           'draft': {
>               'invisible': Eval('state').in_(['draft']),
>               },
>           'request': {
>               'invisible': Eval('state').in_(['request']),
>               },
>               })
>        
>     @classmethod
>     @ModelView.button
>     @Workflow.transition('request')
>     def request(cls, myRequests):
>          ..........
>          cls.write(myRequests,{
>                  'simple_string': 'something something',
>                 })
> 
>  3. Make a view with a form,menuitem, etc.., and put the field and the button 
> on it, but using the richtext widget on the field
>      <label name="simple_string"/>
>      <field name="simple_string" widget="richtext"/>
>      <button name="request" string="_Request"/>
> 
>  4. Click on the button, and observe that the form will not be saved as it 
> would be without the richtext widget.
> 
>  Can anyone confirm this? Thanks
> 
>        Francisco

Finally, I get it!!!
On the cls.write(), have to be this way:
  cls.write(myRequests,{
                  'simple_string': '<div>something something</div>',
                 })

Things get complicated if you want to add some other string, but conserving the 
one you have. You need to do the following: 

   for each_request in myRequests:
      new_simple_string = simple_string.replace('<div>', '').replace('</div>', 
'')
      cls.write([each_request],{
                  'simple_string': '<div>'+str(new_simple_string) \
                                   +'somthing else </div>'
                    })

Regards
    Francisco

-- 
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/44d2300e-9d44-442e-8b5f-b5221c466404%40googlegroups.com.

Reply via email to