Re: [tryton] Problems to write using Proteus

2018-04-12 Thread Javier Uribe
El jueves, 12 de abril de 2018, 9:27:28 (UTC+2), Sergi Almacellas Abellana  
escribió:
> El 11/04/18 a les 13:21, Javier Uribe ha escrit:
> > I have a wizard to modify data from a model (pretty similar to 
> > http://hg.tryton.org/modules/sale/file/default/sale.py#l1861)
> > 
> > so we have a method default_start:
> > 
> >  def default_start(self, fields):
> > batch = self.get_batch()
> > defaults = {}
> > 
> > for fieldname in fields:
> > value = getattr(batch, fieldname)
> > if isinstance(value, Model):
> > if getattr(batch.__class__, fieldname)._type == 'reference':
> > value = str(value)
> > else:
> > value = value.id
> > elif isinstance(value, (list, tuple)):
> > value = [r.id for r in value]
> > defaults[fieldname] = value
> > 
> > defaults['state'] = 'draft'
> > return defaults
> > 
> > On write method I check that the batch is on draft state so it should fail 
> > but 
> > as I put the state to 'draft' on the default_start method now I can write 
> > without any problem. That is to say, I have mimiced a draft mode so I can 
> > modify the model using the write method. And so it happens and it works 
> > using Tryton client.
> > 
> > Now if I do this on proteus:
> > >>> edit_batch = Wizard('agro.farm.batch.edit', [batch])
> > >>> edit_batch.execute('modify')
> > 
> > The test fails because of domain (the check I said I had on the write 
> > method). So it is like the draft is not considered on proteus or something 
> > weird happens
> > 
> Could you please clarify which tests fails and which error are you
> having? It will be great to have the error traceback for more information.
> 
> -- 
> Sergi Almacellas Abellana
> www.koolpi.com
> Twitter: @pokoli_srk

It was my bad, sorry, it didn't have to do with the domain check but thank you.

-- 
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/04d5aff9-7e84-496c-95d9-d0ae6dbf83be%40googlegroups.com.


Re: [tryton] Problems to write using Proteus

2018-04-12 Thread Sergi Almacellas Abellana
El 11/04/18 a les 13:21, Javier Uribe ha escrit:
> I have a wizard to modify data from a model (pretty similar to 
> http://hg.tryton.org/modules/sale/file/default/sale.py#l1861)
> 
> so we have a method default_start:
> 
>  def default_start(self, fields):
> batch = self.get_batch()
> defaults = {}
> 
> for fieldname in fields:
> value = getattr(batch, fieldname)
> if isinstance(value, Model):
> if getattr(batch.__class__, fieldname)._type == 'reference':
> value = str(value)
> else:
> value = value.id
> elif isinstance(value, (list, tuple)):
> value = [r.id for r in value]
> defaults[fieldname] = value
> 
> defaults['state'] = 'draft'
> return defaults
> 
> On write method I check that the batch is on draft state so it should fail 
> but 
> as I put the state to 'draft' on the default_start method now I can write 
> without any problem. That is to say, I have mimiced a draft mode so I can 
> modify the model using the write method. And so it happens and it works using 
> Tryton client.
> 
> Now if I do this on proteus:
> >>> edit_batch = Wizard('agro.farm.batch.edit', [batch])
> >>> edit_batch.execute('modify')
> 
> The test fails because of domain (the check I said I had on the write 
> method). So it is like the draft is not considered on proteus or something 
> weird happens
> 
Could you please clarify which tests fails and which error are you
having? It will be great to have the error traceback for more information.

-- 
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

-- 
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/767b2650-09f7-1d90-12c9-5593884cb4f5%40koolpi.com.


[tryton] Problems to write using Proteus

2018-04-11 Thread Javier Uribe
I have a wizard to modify data from a model (pretty similar to 
http://hg.tryton.org/modules/sale/file/default/sale.py#l1861)

so we have a method default_start:

 def default_start(self, fields):
batch = self.get_batch()
defaults = {}

for fieldname in fields:
value = getattr(batch, fieldname)
if isinstance(value, Model):
if getattr(batch.__class__, fieldname)._type == 'reference':
value = str(value)
else:
value = value.id
elif isinstance(value, (list, tuple)):
value = [r.id for r in value]
defaults[fieldname] = value

defaults['state'] = 'draft'
return defaults

On write method I check that the batch is on draft state so it should fail but 
as I put the state to 'draft' on the default_start method now I can write 
without any problem. That is to say, I have mimiced a draft mode so I can 
modify the model using the write method. And so it happens and it works using 
Tryton client.

Now if I do this on proteus:
>>> edit_batch = Wizard('agro.farm.batch.edit', [batch])
>>> edit_batch.execute('modify')

The test fails because of domain (the check I said I had on the write method). 
So it is like the draft is not considered on proteus or something weird happens

-- 
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/cbb22377-43d9-40fb-96a4-f809edf63a16%40googlegroups.com.