Hi Bertrand,

Thanks for reply!

Am Dienstag, den 26.10.2010, 23:50 +0200 schrieb Bertrand Chenal:
> Le Tue, 26 Oct 2010 22:11:38 +0200,
> Udo Spallek <[email protected]> a écrit :
> > Hi, 
> > having massive problems to create a purchase with proteus. 
> > Please take a look to my console session pasted here:
> > http://paste.pocoo.org/show/281813/
> If I understand correctly:
> The first
>   >>> purchase_line1.product = Product.find([]).pop()
> on line 6 raise an exception because purchase_line1 is not linked to
> any purchase so no currency is unknown when on_change_product is
> triggered, hence the exception. Maybe we should fix this on_change to
> handle this case, but I'm not sure this make sense to create line
> without purchase. So one think I would try is to first do :
>   >>> purchase_line1.purchase = purchase
>>> purchase = Purchase()
>>> purchase.party = party3
>>> purchase_line1 = PurchaseLine1()
>>> purchase_line1.purchase = purchase
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "proteus/__init__.py", line 89, in set_method
    assert value.id > 0 and not value._changed
AssertionError

But the hint seems to be good anway. 'Assert value.id > 0' means
purchase must be saved before, so again:

>>> purchase = Purchase()
>>> purchase.party = party3
>>> purchase.save()
>>> purchase_line1 = PurchaseLine1()
>>> purchase_line1.purchase = purchase
>>> Heureka! But next step fails:
>>> purchase_line1.product = product
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "proteus/__init__.py", line 120, in set_method
    self._on_change(name)
  File "proteus/__init__.py", line 547, in _on_change
    res = getattr(self._proxy, 'on_change_%s' % name)(args, context)
  File "proteus/config.py", line 72, in __call__
    res = getattr(self._object, self._name)(*args)
  File
"/home/uspallek/workspace/tryton/upstream/tests/trytond/modules/purchase/purchase.py",
 line 994, in on_change_product
    res['amount'] = self.on_change_with_amount(vals)
  File
"/home/uspallek/workspace/tryton/upstream/tests/trytond/modules/purchase/purchase.py",
 line 1033, in on_change_with_amount
    return currency_obj.round(currency, amount)
  File
"/home/uspallek/workspace/tryton/upstream/tests/trytond/modules/currency/currency.py",
 line 174, in round
    return (amount / currency.rounding).quantize(Decimal('1.'),
  File "trytond/model/browse.py", line 184, in __getattr__
    return self[name]
  File "trytond/model/browse.py", line 136, in __getitem__
    datas = self._model.read(ids, [x[0] for x in ffields])
  File "trytond/model/modelsql.py", line 532, in read
    self.raise_user_error('read_error', self._description)
  File "trytond/model/model.py", line 457, in raise_user_error
    raise Exception('UserError', error)
Exception: ('UserError', u"You try to read records that don't exist
anymore!\n(Document type: Currency)")
 
Strange. I thought Currency is set as default on purchase by
company.currency.

TIA, Cheers
-- 
Udo Spallek

------------------------------------
virtual things
Preisler & Spallek GbR
Munich - Aix-la-Chapelle

Windeckstr. 77
81375 Munich - Germany
Tel: +49 (89) 710 481 55
Fax: +49 (89) 710 481 56

[email protected]
http://www.virtual-things.biz


-- 
[email protected] mailing list

Reply via email to