IRC logs of #tryton for Monday, 2013-09-09 #tryton log beginning Mon Sep 9 00:00:02 CEST 2013
2013-09-09 16:27 <jvblasco> I have a question, how do u use a many2many relation through Models?
2013-09-09 16:28 <jvblasco> for example: i need to create a product.template. And i set to true account_category and taxes_category
2013-09-09 16:28 <jvblasco> my question is how do i generate the customer_taxes and supplier_taxes fields through the ORM?
2013-09-09 16:28 -!- jerojasro( has left #tryton
2013-09-09 16:29 <jvblasco> i 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) fields
2013-09-09 16:29 <jvblasco> but not for m2m
2013-09-09 16:29 <jvblasco> do i have to pass the value pairs?
2013-09-09 16:30 <jvblasco> for example: customer_taxes: [2, 4]
2013-09-09 16:30 <jeancavallo1> jvblasco: When you say "through Models", do you mean proteus ?
2013-09-09 16:31 <jvblasco> jeancavallo1: nope through the ModelStorage/ModelSQL
2013-09-09 16:32 <jvblasco> jeancavallo1: i guess that when u do something like self.write([self], [{customer_taxes: [2, 4]}])
2013-09-09 16:32 <jeancavallo1> jvblasco: I think the write method handles the relation table without need for you to do anything
2013-09-09 16:32 <jvblasco> it's ORM work
2013-09-09 16:33 <jeancavallo1> jvblasco: It should be.
2013-09-09 16:33 <jeancavallo1> jvblasco: Doesn't it work ?
2013-09-09 16:33 <jvblasco> but i do something like "line_values = line.on_change_product()
2013-09-09 16:33 <jvblasco> line.write([line], line_values)"
2013-09-09 16:34 <jvblasco> line_values being {'amount': Decimal('25.20000'), 'taxes': [4], 'unit_price': Decimal('25.2000')}
2013-09-09 16:34 <jeancavallo1> jvblasco: I think on_change methods have a special syntax to manipulate lists
2013-09-09 16:34 <jvblasco> and everything explodes xD
2013-09-09 16:35 <jvblasco> jeancavallo1: so, what do i have to provide in a write statement to a m2m field?
2013-09-09 16:35 <jvblasco> jeancavallo1: a list with both ids?
2013-09-09 16:35 <jeancavallo1> jvblasco: I am not sure, but I think you should try
2013-09-09 16:36 <jeancavallo1> jvblasco: You might need to specify the 'write' / 'add' etc... statement in your parameters
2013-09-09 16:38 <jvblasco> jeancavallo1: mmmm, but then syntax of a o2m should change to be usable in a m2m relation
2013-09-09 16:38 <jeancavallo1> jvblasco: Like I said, I am not sure of this one
2013-09-09 16:39 <jvblasco> jeancavallo1: gimme some mins to try the list providing to the field. Will tell u asap how it worked.
2013-09-09 16:39 <jvblasco> jeancavallo1: it's the option that makes more sense to me
2013-09-09 16:40 <jeancavallo1> jvblasco: The thing is, I am almost sure that you should not create lines in the relation table directly
2013-09-09 16:41 <jeancavallo1> jvblasco: You should write the list in the m2m field in you origin model
2013-09-09 16:43 <jeancavallo1> jvblasco: This is the method that will be called when writing your field :
2013-09-09 16:46 <jvblasco> jeancavallo1: o2m link and unlink technique takes sense while reading code.
2013-09-09 16:47 <jeancavallo1> jvblasco: and for m2m ? :D
2013-09-09 16:48 <jvblasco> jeancavallo1: 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.
2013-09-09 16:48 <jeancavallo1> jvblasco: The path is long, but the end is near :)
2013-09-09 16:55 <jvblasco> the 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.
2013-09-09 17:01 <jvblasco> i guess i cand do it by hand, but i'm sure it's not the most elegant way.
2013-09-09 17:01 <jvblasco> omg, accounting is as hard as hell, damn accounting xP
2013-09-09 17:04 <jvblasco> there's a method: get_taxes(self, name) but i can't figure out what name is
2013-09-09 17:12 <jvblasco> got it
2013-09-09 17:12 <jvblasco> xD
2013-09-09 17:13 <jeancavallo1> jvblasco: 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 ?
2013-09-09 17:13 <jeancavallo1> jvblasco: nevermind :)
2013-09-09 17:27 <jvblasco> jeancavallo1: 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.
2013-09-09 17:27 <jeancavallo1> jvblasco: thought so
2013-09-09 17:27 <jeancavallo1> jvblasco: glad you sorted it out
2013-09-09 17:27 <jvblasco> jeancavallo1: i didn't but thnx for tip, i will try to stick that in my mind when debugging and that kind of stuff ;)
2013-09-09 18:05 <jvblasco> mission accomplished
2013-09-09 19:00 -!- vcardon( has left #tryton
2013-09-09 19:51 <jvblasco> see u around guys, bb
2013-09-09 19:51 <jvblasco> and thnx for the help ;)

Generated by 2.17.3 by Marius Gedminas - find it at!