IRC logs of #tryton for Wednesday, 2013-09-11

chat.freenode.net #tryton log beginning Wed Sep 11 00:00:02 CEST 2013
2013-09-11 08:25 -!- priyankarani(~priyanka@122.177.197.148) has left #tryton
2013-09-11 10:18 -!- priyankarani(~priyanka@122.177.197.148) has left #tryton
2013-09-11 10:30 -!- priyankarani1(~priyanka@122.177.197.148) has left #tryton
2013-09-11 10:56 <marc0s> is there any way to allow multiple tabs opened for the same model? I'm using version 2.6 and customer would like to have multiple party entries opened at once
2013-09-11 11:19 <bechamel> marc0s: shift+click does the trick
2013-09-11 11:20 <marc0s> bechamel: oh my... :D
2013-09-11 11:20 <marc0s> thanks :)
2013-09-11 11:21 <marc0s> as my customer will ask, any way to make this the default mode of operation?
2013-09-11 11:27 <bechamel> marc0s: not without changing the code
2013-09-11 11:28 <marc0s> bechamel: ok, thanks
2013-09-11 14:30 <WUD> Is there a way that I can override the init method and set certain properties on a <ModelSQL> class whenever I initialise an instance from the GTK?
2013-09-11 14:51 <WUD> cedk: is there a way to call __init__ method on a ModelSQL subclass?
2013-09-11 14:52 <motaro> Question: Why when I create a new Employee I have to set the id/code field
2013-09-11 14:52 <motaro> ¿Couldn't just use an increment?
2013-09-11 14:53 <jeancavallo> WUD: What kind of modifications are you talking about ?
2013-09-11 14:54 <WUD> jeancavallo: I just want to set certain properties of a ModelSQL subclass whenever I press the 'New' button on it
2013-09-11 14:54 <jeancavallo> WUD: Are you talking about default values ?
2013-09-11 14:55 <WUD> yeah, I want something to have a default value
2013-09-11 14:55 <jeancavallo> WUD: Then you can define a classmethod named default_<field_name> which returns the default value you want
2013-09-11 14:56 <WUD> but I need to access a property on the instance I'm accessing
2013-09-11 14:57 <jeancavallo> WUD: But you just created the instance... How was this property set ?
2013-09-11 14:58 <WUD> umm, in the initialiser ? It's a M20 field for another class
2013-09-11 14:59 <jeancavallo> WUD: So you got an instance of model A with a M2O to a model B and you want to set default values when creating a new B instance from the link ?
2013-09-11 15:02 <WUD> My scenario is I have a Model B, which as an M2O to Model A, now this Model B has been subclassed, and I want to set a property on it, whenever it's initialised from Model A's view
2013-09-11 15:02 <WUD> that's why I was trying to override the __init__ method and do it from there, do some custom inits
2013-09-11 15:12 <jeancavallo> WUD: You can use the context to pass some informations from your model A instance. You can then access it in the default methods of model B through Transaction().context.get(...)
2013-09-11 15:12 <WUD> That's the problem, I am setting the context, but my key values aren't showing up when I access the Transaction in Model B
2013-09-11 15:20 <jeancavallo> WUD: How are you setting the context ?
2013-09-11 15:21 <WUD> jeancavallo: Transaction().set_context({})
2013-09-11 15:22 <WUD> Transaction().set_context({'key': 'value'})
2013-09-11 15:22 <jeancavallo> WUD: You need to use the context parameter un your model A field description
2013-09-11 15:23 <jeancavallo> WUD: Something like : my_model_b = fields.Many2One('model_A', 'My Model B', context={'my_key': Eval('my_other_field')})
2013-09-11 15:23 <jeancavallo> WUD: s/model_A/model_B
2013-09-11 15:23 <WUD> I tried this and the other one also
2013-09-11 15:23 <WUD> But this didn't work either
2013-09-11 15:23 <WUD> jeancavallo:
2013-09-11 15:24 <WUD> I can't access this field on the other model
2013-09-11 15:24 <jeancavallo> WUD: Then it looks like a bug. Could you provide your code (in a pastebin) ?
2013-09-11 15:49 <WUD> jeancavallo: http://pastebin.com/BnErxHzW
2013-09-11 15:49 <WUD> I'm setting the context inside a function field
2013-09-11 15:50 <jeancavallo> WUD: I assume the "lines" field is defined in Model A. In this case, your Eval statement is wrong, it should be Eval('field_name')
2013-09-11 15:52 <jeancavallo> WUD: And field_name should be presented in your form view
2013-09-11 15:52 <WUD> Setting the transaction in a function field works?
2013-09-11 15:55 <jeancavallo> WUD: It should. but be careful that Fuction fields are readonly (except if you define the 'setter' parameter)
2013-09-11 15:55 <WUD> I have a setter parameter
2013-09-11 15:56 <jeancavallo> WUD: Ok. Is your default called properly ?
2013-09-11 15:56 <WUD> Yeah, well now I can see the key of the Transaction appearing in my default, but It doesn't have a value
2013-09-11 15:57 <WUD> Transaction context
2013-09-11 15:58 <jeancavallo> WUD: Nice. So that means the Eval returns nothing. Is the field you are trying to get displayed (and set) in your form view ?
2013-09-11 15:58 <WUD> No, it's a M20 field
2013-09-11 15:58 <jvblasco> contexts are a thing that i haven't found many documentation about and i think are really important
2013-09-11 15:59 <jeancavallo> jvblasco: it is... And you're so right
2013-09-11 16:00 <WUD> jeancavallo: It's not in my view because it's just a M2O field
2013-09-11 16:00 <jeancavallo> WUD: Let's call the field you want to access in your default "foo"
2013-09-11 16:00 <WUD> okay
2013-09-11 16:00 <jeancavallo> WUD: your Eval should be : Eval('foo')
2013-09-11 16:00 <jeancavallo> WUD: right ?
2013-09-11 16:00 <WUD> yeah, that's what I have
2013-09-11 16:00 <WUD> Eval('name of field in my model')
2013-09-11 16:01 <jvblasco> does anyone know a place to check some documentation about contexts in tryton? I was able to understand them in other plataforms (eg. magento) but i don't really understand the contexts here as they are associated to the transaction object, u can have multiple contexts and that kind of stuff
2013-09-11 16:01 <jeancavallo> WUD: Ok. Try Eval('foo', 10)
2013-09-11 16:01 <WUD> jeancavallo: a minute
2013-09-11 16:01 <jvblasco> WUD: was the code in the paste bin from model A or B?
2013-09-11 16:02 <jvblasco> WUD: cause u are talking about a m2o relation and i see in the code a o2m relation
2013-09-11 16:02 <WUD> the field inside the eval is a m2o
2013-09-11 16:02 <WUD> the field i'm writing is o2m
2013-09-11 16:03 <WUD> I did the Eval('foo', 10) thing, it's still an empty string in my context
2013-09-11 16:03 <jeancavallo> WUD: Just to be sure, model A is the model of your M2O or the model in which your "lines" field is defined ?
2013-09-11 16:03 <jvblasco> WUD: Not sure about this, but as far as i know, Transaction() supports multiple contexts, take care with the context is using
2013-09-11 16:04 <jvblasco> WUD: if u did something like Transaction().set_user(0) in your code, the context changes and may not have the values used in the function field
2013-09-11 16:04 <jeancavallo> jvblasco: WUD: That should not be a problem, we're talking about a client call so no risk of multiple context from the framework
2013-09-11 16:05 <jvblasco> jeancavallo: then i really need to study/read some documentation about contexts
2013-09-11 16:05 <WUD> jeancavallo: showing you a better code example
2013-09-11 16:06 <jvblasco> WUD: jeancavallo: anyway i'm using tryton in the backside. I'm working very little with the client. All i do there is extend some views to add some fields.
2013-09-11 16:07 <jvblasco> i cannot help much more, my knowledge in tryton is still very limited xP, sorry about that.
2013-09-11 16:07 <WUD> http://pastebin.com/mr3gmMwd
2013-09-11 16:07 <WUD> jeancavallo:
2013-09-11 16:10 <jeancavallo> WUD: Which field are you trying to default ? Another field in Model B ?
2013-09-11 16:10 <WUD> yeah
2013-09-11 16:10 <WUD> yeah jeancavallo
2013-09-11 16:11 <jeancavallo> WUD: And otherField is properly displayed along with myField ?
2013-09-11 16:11 <WUD> otherField isn't shown in the view
2013-09-11 16:11 <WUD> does it need to be in the view for Eval to work?
2013-09-11 16:11 <jeancavallo> WUD: That's it
2013-09-11 16:11 <jeancavallo> WUD: either that or you can add depends=['otherField'] in myField definition
2013-09-11 16:12 <WUD> then I won't have to put it in my view?
2013-09-11 16:12 <WUD> jeancavallo: like so? http://pastebin.com/C2vHjf1Q
2013-09-11 16:13 <jeancavallo> should not be necessary
2013-09-11 16:13 <jeancavallo> WUD: depends inside the O2M definition, not the Function
2013-09-11 16:13 <WUD> Okay
2013-09-11 16:22 <WUD> thanks jeancavallo It's finally working
2013-09-11 16:22 <jeancavallo> WUD: Nice :)
2013-09-11 16:28 -!- WUD(~WUD@122.177.197.148) has left #tryton
2013-09-11 16:32 <WUD> jeancavallo: i'm getting an error 'you try to read records that don't exist', what's the cause of something like this? I did all that so that I could set a field in my ModelB, which I thought was causing it
2013-09-11 16:33 <jeancavallo> WUD: That usually means that you tried to read an id that does not exist.
2013-09-11 16:34 <WUD> but the field I just tried to set is the one that causes this problem
2013-09-11 16:35 <WUD> there's also a document type in the same error message
2013-09-11 16:35 <WUD> which says party.party
2013-09-11 16:37 <jeancavallo> WUD: That's not enough information... Only idea I can have is that your default field returns something weird
2013-09-11 16:41 -!- WUD(~WUD@122.177.197.148) has left #tryton
2013-09-11 17:42 <Wud> hmm
2013-09-11 17:45 -!- Wud(~WUD@123.63.112.93) has left #tryton

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!