On 2017-08-16 22:01, Francisco Maria Moyano Casco wrote:
> Hi,
>     I'm using tryton 3.8. I'm trying to make a workflow that goes from draft 
> state to request state. I defined the transitions, updates, and buttons:
>       
>      @classmethod
>      def __setup__(cls):
>        super(myClass, cls).__setup__()
>        cls._transitions |= set((
>           ('draft','request'),
>          ))
> 
>        cls._buttons.update({
>           'draft': {
>               'invisible': Eval('state').in_(['request']),
>               },
>           'request': {
>               'invisible': Eval('state').in_(['draft']),
>               },
>               })
>        
>     @classmethod
>     @ModelView.button
>     @Workflow.transition('request')
>     def draft(cls, myRequests):
>          ..........
>          cls.write(myRequests,{
>                  'request_date': datetime.now(),
>                 })
> 
> 
> The thing is, that I had defined two pair of views for the same model.
> On both pair when I clicked on the draft button, doesn't save the register. 
> Only does what it has to do (put the datetime.now() on request_date field).
> When I wanted to close the form, one of the form only close after confirm the 
> a save message.
> On the other form, it doesn't close. Ask me over and over again to save the 
> register.
> 
> When I comment the line cls.write(....), acts normally, but doesn't do what I 
> want it to do.


Is 'request_date' a Date field? Or is it a DateTime?
If it is a Date, you must use date.today() instead of datetime.now()
(and even better to use Pool().get('ir.date').today())

-- 
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/20170817065649.GA3705%40kei.

Reply via email to