On 17/01/12 16:48 -0300, Felipe Alvarez Harnecker wrote:
> On Martes 17 Enero 2012 15:43:22 [email protected] escribió:
> > <with vars="myvar = 'foo'">
> > <myvar = 'bar'>
> > Myvar has value <myvar>
> > </with>
> 
> does not work for me, at least with inner loop, i alway get 'foo' instead of 
> bar.

First, it is a bad practice to put data processing in the template
language because most of the time it result into poor performant code
and it makes the code more difficult to maintain.

> 
> looking some templates it appears a sum function, i've read genshi and 
> relatorio docs and never see that, anyway
> 
> in trial_balance odt
> 
> appears SUM(ACCOUNTS,'CREDIT') so i suppose that SUM sums over ACCOUNTS the 
> credit field.
> 
> So i do sum(objects,'tax_amount') and 
> 
> TypeError: sum() can't sum strings [use ''.join(seq) instead]

Of course, the trial_balance report define in the evaluation context a
new function "sum" [1].
As it is not defined in your report, it is the default python sum [2]
that is used.
So you can use the python list comprehension to do what you want:

    sum(x.tax_amount for x in objects)

[1]
http://hg.tryton.org/modules/account/file/e59e1ced9f77/account.py#l1440
[2] http://docs.python.org/library/functions.html#sum

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgpvKgsnKnjtz.pgp
Description: PGP signature

Reply via email to