IRC logs of #tryton for Wednesday, 2013-11-27 #tryton log beginning Wed Nov 27 00:00:02 CET 2013
2013-11-27 17:44 <martinguzman> Hi all! I'm using Tryton client 3.0.1 and I had this error: Unsupported operand type(s) for *: 'float' and 'Decimal' when the client is trying to display a Numeric field... Here is the error traceback:
2013-11-27 17:44 <martinguzman> Is this a bug or I'm doing something incorrectly?
2013-11-27 17:44 <martinguzman> I fixed it by casting to a float number the factor parameter...
2013-11-27 17:44 <martinguzman> I replaced the return statement of get_client on FloatField class (tryton/gui/window/view_form/model/
2013-11-27 17:44 <martinguzman> return locale.format('%.*f', (digit, value * factor), True)
2013-11-27 17:44 <martinguzman> by:
2013-11-27 17:44 <martinguzman> return locale.format('%.*f', (digit, value * float(factor)), True)
2013-11-27 17:44 <martinguzman> and that fixed the problem, but I'm not sure if it can have some implications...
2013-11-27 17:51 <cedk> martinguzman: already fixed by changeset 0118233a9c34
2013-11-27 17:51 <cedk> martinguzman I think
2013-11-27 18:01 <martinguzman> cedk: I don't think so.. If you see the traceback the problem is that the factor parameter on the get_client method on FloatField is a Decimal type (because of the get_client method on NumericField)
2013-11-27 18:04 <martinguzman> on NumericField class the get_client method is returning: return super(NumericField, self).get_client(record, factor=Decimal(str(factor)))
2013-11-27 18:04 <martinguzman> so the factor is receiving the get_client on FloatField is a Decimal type...
2013-11-27 18:10 <cedk> martinguzman: where do you get that?
2013-11-27 18:12 <martinguzman> cedk: line 16-20 on the error traceback:
2013-11-27 18:13 <martinguzman> if you go to the source code on that lines you can what is happening..
2013-11-27 18:13 <martinguzman> *you can see what is happening..
2013-11-27 18:22 <martinguzman> cedk: the get_client method on NumericField is calling the super method... So this method is calling the get_client method on FloatField, but is sending the factor as a Decimal type...
2013-11-27 18:25 <martinguzman> and the get_client method on FloatField is trying to multiply: value * factor (float type times Decimal type) and that causes the error..
2013-11-27 18:33 <cedk> martinguzman: I don't see anything wrong in the client code so where do you have this issue?
2013-11-27 18:34 <cedk> martinguzman: which module? Because the error is using a float/Decimal digit with a Decimal/float
2013-11-27 18:37 <martinguzman> cedk: I'm sure it is not on any module and its on the client source (tryton/gui/window/view_form/model/
2013-11-27 18:38 <martinguzman> go to the line 328 (return statement of get_client method on NumericField class)
2013-11-27 18:38 <cedk> martinguzman: So you don't want to say where you get the error ?
2013-11-27 18:38 <martinguzman> and this return statement is calling the super method (so it is calling the get_client FloatField method)
2013-11-27 18:39 <martinguzman> cedk: ??! I'm getting the error when the client is trying to display a NumericField on a tree view
2013-11-27 18:39 <cedk> martinguzman: But which field ????
2013-11-27 18:40 <martinguzman> cedk: it is not on tryton module... it is on a module I wrote..
2013-11-27 18:40 <cedk> martinguzman: so fix your module
2013-11-27 18:40 <martinguzman> but when i was using tryton 2.8 everything was working fine..
2013-11-27 18:41 <martinguzman> cedk: why are you so close?
2013-11-27 18:42 <martinguzman> cedk: i'm pretty sure I'm not doing anything wrong...
2013-11-27 18:42 <martinguzman> just see the line 328 and the line 310 on the file...
2013-11-27 18:43 <martinguzman> on 328 you are returning a factor=Decimal(str(factor))
2013-11-27 18:43 <cedk> martinguzman: if you don't show your code, I can not help
2013-11-27 18:47 <martinguzman> cedk: ok, give me a moment and I'm going to try to replicate the error on a smaller module...
2013-11-27 19:47 -!- vcardon( has left #tryton
2013-11-27 22:03 -!- bechamel( has left #tryton
2013-11-27 22:14 <martinguzman> cedk: I figured out what was the problem... When I created the database, I had a float field and I created some example records.. Then I change the float field to a numeric field, so the client gave me that error... Sorry for all the inconvenience.. :)

Generated by 2.17.3 by Marius Gedminas - find it at!