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

chat.freenode.net #tryton log beginning Wed Sep 11 00:00:02 CEST 2013
-!- priyankarani(~priyanka@122.177.197.148) has left #tryton08:25
-!- priyankarani(~priyanka@122.177.197.148) has left #tryton10:18
-!- priyankarani1(~priyanka@122.177.197.148) has left #tryton10:30
marc0sis 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 once10:56
bechamelmarc0s: shift+click does the trick11:19
marc0sbechamel: oh my... :D11:20
marc0sthanks :)11:20
marc0sas my customer will ask, any way to make this the default mode of operation?11:21
bechamelmarc0s: not without changing the code11:27
marc0sbechamel: ok, thanks11:28
WUDIs 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?14:30
WUDcedk: is there a way to call __init__ method on a ModelSQL subclass?14:51
motaroQuestion: Why when I create a new Employee I have to set the id/code field14:52
motaro┬┐Couldn't just use an increment?14:52
jeancavalloWUD: What kind of modifications are you talking about ?14:53
WUDjeancavallo: I just want to set certain properties of a ModelSQL subclass whenever I press the 'New' button on it14:54
jeancavalloWUD: Are you talking about default values ?14:54
WUDyeah, I want something to have a default value14:55
jeancavalloWUD: Then you can define a classmethod named default_<field_name> which returns the default value you want14:55
WUDbut I need to access a property on the instance I'm accessing14:56
jeancavalloWUD: But you just created the instance... How was this property  set ?14:57
WUDumm, in the initialiser ? It's a M20 field for another class14:58
jeancavalloWUD: 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 ?14:59
WUDMy 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 view15:02
WUDthat's why I was trying to override the __init__ method and do it from there, do some custom inits15:02
jeancavalloWUD: 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(...)15:12
WUDThat's the problem, I am setting the context, but my key values aren't showing up when I access the Transaction in Model B15:12
jeancavalloWUD: How are you setting the context ?15:20
WUDjeancavallo: Transaction().set_context({})15:21
WUDTransaction().set_context({'key': 'value'})15:22
jeancavalloWUD: You need to use the context parameter un your model A field description15:22
jeancavalloWUD: Something like : my_model_b = fields.Many2One('model_A', 'My Model B', context={'my_key': Eval('my_other_field')})15:23
jeancavalloWUD: s/model_A/model_B15:23
WUDI tried this and the other one also15:23
WUDBut this didn't work either15:23
WUDjeancavallo:15:23
WUDI can't access this field on the other model15:24
jeancavalloWUD: Then it looks like a bug. Could you provide your code (in a pastebin) ?15:24
WUDjeancavallo: http://pastebin.com/BnErxHzW15:49
WUDI'm setting the context inside a function field15:49
jeancavalloWUD: I assume the "lines" field is defined in Model A. In this case, your Eval statement is wrong, it should be Eval('field_name')15:50
jeancavalloWUD: And field_name should be presented in your form view15:52
WUDSetting the transaction in a function field works?15:52
jeancavalloWUD: It should. but be careful that Fuction fields are readonly (except if you define the 'setter' parameter)15:55
WUDI have a setter parameter15:55
jeancavalloWUD: Ok. Is your default called properly ?15:56
WUDYeah, well now I can see the key of the Transaction appearing in my default, but It doesn't have a value15:56
WUDTransaction context15:57
jeancavalloWUD: Nice. So that means the Eval returns nothing. Is the field you are trying to get displayed (and set) in your form view ?15:58
WUDNo, it's a M20 field15:58
jvblascocontexts are a thing that i haven't found many documentation about and i think are really important15:58
jeancavallojvblasco: it is... And you're so right15:59
WUDjeancavallo: It's not in my view because it's just a M2O field16:00
jeancavalloWUD: Let's call the field you want to access in your default "foo"16:00
WUDokay16:00
jeancavalloWUD: your Eval should be : Eval('foo')16:00
jeancavalloWUD: right ?16:00
WUDyeah, that's what I have16:00
WUDEval('name of field in my model')16:00
jvblascodoes 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 stuff16:01
jeancavalloWUD: Ok. Try Eval('foo', 10)16:01
WUDjeancavallo: a minute16:01
jvblascoWUD: was the code in the paste bin from model A or B?16:01
jvblascoWUD: cause u are talking about a m2o relation and i see in the code a o2m relation16:02
WUDthe field inside the eval is a m2o16:02
WUDthe field i'm writing is o2m16:02
WUDI did the Eval('foo', 10) thing, it's still an empty string in my context16:03
jeancavalloWUD: Just to be sure, model A is the model of your M2O or the model in which your "lines" field is defined ?16:03
jvblascoWUD: Not sure about this, but as far as i know, Transaction() supports multiple contexts, take care with the context is using16:03
jvblascoWUD: 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 field16:04
jeancavallojvblasco: WUD: That should not be a problem, we're talking about a client call so no risk of multiple context from the framework16:04
jvblascojeancavallo: then i really need to study/read some documentation about contexts16:05
WUDjeancavallo: showing you a better code example16:05
jvblascoWUD: 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.16:06
jvblascoi cannot help much more, my knowledge in tryton is still very limited xP, sorry about that.16:07
WUDhttp://pastebin.com/mr3gmMwd16:07
WUDjeancavallo:16:07
jeancavalloWUD: Which field are you trying to default ? Another field in Model B ?16:10
WUDyeah16:10
WUDyeah jeancavallo16:10
jeancavalloWUD: And otherField is properly displayed along with myField ?16:11
WUDotherField isn't shown in the view16:11
WUDdoes it need to be in the view for Eval to work?16:11
jeancavalloWUD: That's it16:11
jeancavalloWUD: either that or you can add depends=['otherField'] in myField definition16:11
WUDthen I won't have to put it in my view?16:12
WUDjeancavallo: like so? http://pastebin.com/C2vHjf1Q16:12
jeancavalloshould not be necessary16:13
jeancavalloWUD: depends inside the O2M definition, not the Function16:13
WUDOkay16:13
WUDthanks jeancavallo It's finally working16:22
jeancavalloWUD: Nice :)16:22
-!- WUD(~WUD@122.177.197.148) has left #tryton16:28
WUDjeancavallo: 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 it16:32
jeancavalloWUD: That usually means that you tried to read an id that does not exist.16:33
WUDbut the field I just tried to set is the one that causes this problem16:34
WUDthere's also a document type in the same error message16:35
WUDwhich says party.party16:35
jeancavalloWUD: That's not enough information... Only idea I can have is that your default field returns something weird16:37
-!- WUD(~WUD@122.177.197.148) has left #tryton16:41
Wudhmm17:42
-!- Wud(~WUD@123.63.112.93) has left #tryton17:45

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