mako con openerp

197 views
Skip to first unread message

alfonso olavarria

unread,
May 14, 2013, 3:30:44 PM5/14/13
to mako-d...@googlegroups.com
Hola,

estoy haciendo un reporte en openerp que ya tengo un poco adelantado en cuanto al diseño en html y  css, pero en la manipulacion de los datos se me ha complicado encuanto a:

1. no puedo sumar los objetos que mako recibe
por ejemplo

%for orden in objects:

con esta parte voy a empezar a iterar en mi objeto el cual tiene un campo llamado amount_total que es el que quiero totalizar pero no se como hacer.

yo puedo hacer ${orden.amount_total} y me imprime en cada vuelta el valor pero no se como sumarlos.

gracias de ante mano... 











Mariano Mara

unread,
May 14, 2013, 3:34:52 PM5/14/13
to mako-d...@googlegroups.com


On 05/14/2013 04:30 PM, alfonso olavarria wrote:
> Hola,
>
> estoy haciendo un reporte en openerp que ya tengo un poco adelantado en
> cuanto al dise�o en html y css, pero en la manipulacion de los datos se
> me ha complicado encuanto a:
>
> 1. no puedo sumar los objetos que mako recibe
> por ejemplo
>
> %for orden in objects:
>
> con esta parte voy a empezar a iterar en mi objeto el cual tiene un
> campo llamado amount_total que es el que quiero totalizar pero no se
> como hacer.
>
> yo puedo hacer ${orden.amount_total} y me imprime en cada vuelta el
> valor pero no se como sumarlos.
>
> gracias de ante mano...
>
>
>

Esta es una lista que solo provee soporte en ingl�s as� que para la
pr�xima us� ese idioma (o escrib� a la lista de Python Argentina donde
hay varios que saben mako y te van a responder en espa�ol).

Con respecto a tu pregunta, tenes que generar una variable para ir
guardando ese valor (no testeado):


<%
variable_acumulada = 0
%>
% for orden in objects:
variable_acumulada += orden.amount_total
% endfor



alfonso olavarria

unread,
May 15, 2013, 11:00:26 AM5/15/13
to mako-d...@googlegroups.com
but so I can not because in the mako that I have when I embed this.


<%
      variable_acumulada = 0
   %>

   % for order in objects:
       variable_acumulada + = orden.amount_total
% endfor

I print to pdf variable_acumuladora + = orden.amount_total

and if I put it like that.


<%
      variable_acumulada = 0
   %>
   % for order in objects:
       variable_acumulada + = $ {orden.amount_total}
% endfor

prints for each turn me this.

lap 1
variable_acumuladora + = 86.5

turn 2
variable_acumuladora + = 1.05

Thanks for responding.

 

Mariano Mara

unread,
May 15, 2013, 3:04:09 PM5/15/13
to mako-d...@googlegroups.com


On 05/15/2013 12:00 PM, alfonso olavarria wrote:
>
>
> El martes, 14 de mayo de 2013 15:00:44 UTC-4:30, alfonso olavarria escribi�:
>
> Hola,
>
> estoy haciendo un reporte en openerp que ya tengo un poco adelantado
> en cuanto al dise�o en html y css, pero en la manipulacion de los
It seems my code had a mistake (like I said, it was not tested):

<%
variable_acumulada = 0
for orden in objects:
variable_acumulada += orden.amount_total
%>
el valor acumulado total es ${variable_acumulada}

as you can see, in the <% %> I work with regular python idioms and later
I print the result from the routine. There are multiple ways to do the
same, depending on how you want to lay out your code.

I strongly suggest reading this chapter from the docs:
http://docs.makotemplates.org/en/latest/syntax.html#control-structures

Mariano

> --
> You received this message because you are subscribed to the Google
> Groups "Mako Templates for Python" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mako-discuss...@googlegroups.com.
> To post to this group, send email to mako-d...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mako-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

alfonso olavarria

unread,
May 15, 2013, 4:10:38 PM5/15/13
to mako-d...@googlegroups.com
I really appreciate Mariano I really worked very well.

I'll be reading that documentation of mako.

thanks for giving me that hand, I count on you for another question future ...


2013/5/15 Mariano Mara <marian...@gmail.com>


On 05/15/2013 12:00 PM, alfonso olavarria wrote:


El martes, 14 de mayo de 2013 15:00:44 UTC-4:30, alfonso olavarria escribió:

    Hola,

    estoy haciendo un reporte en openerp que ya tengo un poco adelantado
    en cuanto al diseño en html y  css, pero en la manipulacion de los

To post to this group, send email to mako-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/mako-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to a topic in the Google Groups "Mako Templates for Python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mako-discuss/27rxwO3qk9o/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mako-discuss+unsubscribe@googlegroups.com.

alfonso olavarria

unread,
May 20, 2013, 9:12:59 AM5/20/13
to mako-d...@googlegroups.com

alfonso olavarria

unread,
Jun 19, 2013, 3:40:05 PM6/19/13
to mako-d...@googlegroups.com
Hi Mariano, Greetings. I hope you are well.

Seber wanted to know about this.

know that I have python 2.7 and 2.6

in the 2.7 install pymssql 1.0.2 to connect to MS-SQL but I do returns no value.

Python 2.6.8 (default, April 26, 2013, 16:56:05)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Pymssql >>> import
Pymssql.connect >>> c = (host = 'IP', user = 'user', password = 'pass', database = 'db')
C.cursor >>> cur = ()
Cur.execute >>> ro = ("select * from tab where tbl_mia = 12345")
Ro >>> print
none
>>>

Greetings.



2013/5/20 alfonso olavarria <alfon...@gmail.com>
Reply all
Reply to author
Forward
0 new messages