IRC logs of #tryton for Monday, 2013-09-09

chat.freenode.net #tryton log beginning Mon Sep 9 00:00:02 CEST 2013
jvblascoI have a question, how do u use a many2many relation through Models?16:27
jvblascofor example: i need to create a product.template. And i set to true account_category and taxes_category16:28
jvblascomy question is how do i generate the customer_taxes and supplier_taxes fields through the ORM?16:28
-!- jerojasro(~jerojasro@sulaco.devnull.li) has left #tryton16:28
jvblascoi don't really know how to assign a value to a m2m field. I already know how to do that in o2m or m2o (easiest one) fields16:29
jvblascobut not for m2m16:29
jvblascodo i have to pass the value pairs?16:29
jvblascofor example: customer_taxes: [2, 4]16:30
jeancavallo1jvblasco: When you say "through Models", do you mean proteus ?16:30
jvblascojeancavallo1: nope through the ModelStorage/ModelSQL16:31
jvblascojeancavallo1: i guess that when u do something like self.write([self], [{customer_taxes: [2, 4]}])16:32
jeancavallo1jvblasco: I think the write method handles the relation table without need for you to do anything16:32
jvblascoit's ORM work16:32
jeancavallo1jvblasco: It should be.16:33
jeancavallo1jvblasco: Doesn't it work ?16:33
jvblascobut i do something like "line_values = line.on_change_product()16:33
jvblasco line.write([line], line_values)"16:33
jvblascoline_values being {'amount': Decimal('25.20000'), 'taxes': [4], 'unit_price': Decimal('25.2000')}16:34
jeancavallo1jvblasco: I think on_change methods have a special syntax to manipulate lists16:34
jvblascoand everything explodes xD16:34
jvblascojeancavallo1: so, what do i have to provide in a write statement to a m2m field?16:35
jvblascojeancavallo1: a list with both ids?16:35
jeancavallo1jvblasco: I am not sure, but I think you should try http://doc.tryton.org/2.8/trytond/doc/ref/models/fields.html#one2many16:35
jeancavallo1jvblasco: You might need to specify the 'write' / 'add' etc... statement in your parameters16:36
jvblascojeancavallo1: mmmm, but then syntax of a o2m should change to be usable in a m2m relation16:38
jeancavallo1jvblasco: Like I said, I am not sure of this one16:38
jvblascojeancavallo1: gimme some mins to try the list providing to the field. Will tell u asap how it worked.16:39
jvblascojeancavallo1: it's the option that makes more sense to me16:39
jeancavallo1jvblasco: The thing is, I am almost sure that you should not create lines in the relation table directly16:40
jeancavallo1jvblasco: You should write the list in the m2m field in you origin model16:41
jeancavallo1jvblasco: This is the method that will be called when writing your field : http://hg.tryton.org/trytond/file/5a7f41b4200a/trytond/model/fields/many2many.py#l9816:43
jvblascojeancavallo1: o2m link and unlink technique takes sense while reading code.16:46
jeancavallo1jvblasco: and for m2m ? :D16:47
jvblascojeancavallo1: hehehehe, sure makes sense for a m2m relation ;). BTW i think i'm starting to see the light at the end of the tunnel. Things start to make sense.16:48
jeancavallo1jvblasco: The path is long, but the end is near :)16:48
jvblascothe problem is that i create the product template, and set to true taxes_category and account_category, but i cannot find the method the client calls to update that info.16:55
jvblascoi guess i cand do it by hand, but i'm sure it's not the most elegant way.17:01
jvblascoomg, accounting is as hard as hell, damn accounting xP17:01
jvblascothere's a method: get_taxes(self, name) but i can't figure out what name is17:04
jvblascogot it17:12
jvblascoxD17:12
jeancavallo1jvblasco: When you say you do not find the method the client uses to update the info, did you try activating the DEBUG mode on the client to see all requests between client and server ?17:13
jeancavallo1jvblasco: nevermind :)17:13
jvblascojeancavallo1: In the end a m2m field works like a o2m. U need to use add, unlink, create the same way u do in a o2m field.17:27
jeancavallo1jvblasco: thought so17:27
jeancavallo1jvblasco: glad you sorted it out17:27
jvblascojeancavallo1: i didn't but thnx for tip, i will try to stick that in my mind when debugging and that kind of stuff ;)17:27
jvblascomission accomplished18:05
-!- vcardon(~vcardon@LNeuilly-152-23-15-185.w193-252.abo.wanadoo.fr) has left #tryton19:00
jvblascosee u around guys, bb19:51
jvblascoand thnx for the help ;)19:51

Generated by irclog2html.py 2.11.0 by Marius Gedminas - find it at mg.pov.lt!