Problems to write using Proteus

45 views
Skip to first unread message

Javier Uribe

unread,
Apr 11, 2018, 3:35:14 PM4/11/18
to tryton
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

Sergi Almacellas Abellana

unread,
Apr 12, 2018, 3:27:28 AM4/12/18
to try...@googlegroups.com
El 11/04/18 a les 13:21, Javier Uribe ha escrit:
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

Javier Uribe

unread,
Apr 12, 2018, 5:40:08 AM4/12/18
to tryton
It was my bad, sorry, it didn't have to do with the domain check but thank you.
Reply all
Reply to author
Forward
0 new messages