IRC logs of #tryton for Wednesday, 2014-02-19

chat.freenode.net #tryton log beginning Wed Feb 19 00:00:01 CET 2014
2014-02-19 00:58 -!- redDave_(~quassel@83.70.138.18) has joined #tryton
2014-02-19 01:04 -!- cedk(~ced@gentoo/developer/cedk) has joined #tryton
2014-02-19 01:28 -!- martynushka(o7j3fl9gj7@unaffiliated/martynushka) has joined #tryton
2014-02-19 02:12 -!- digitalsatori(~Thunderbi@116.234.234.90) has joined #tryton
2014-02-19 02:21 -!- jcm(~jcm@cxr69-10-88-172-230-130.fbx.proxad.net) has joined #tryton
2014-02-19 03:40 -!- redDave(~quassel@83.70.138.18) has joined #tryton
2014-02-19 04:32 -!- breno(~breno@190.237.8.53) has joined #tryton
2014-02-19 06:01 -!- yangoon1(~mathiasb@p549F16C7.dip0.t-ipconnect.de) has joined #tryton
2014-02-19 06:19 -!- defyasdf(~defyasdf@ec2-54-234-60-70.compute-1.amazonaws.com) has joined #tryton
2014-02-19 06:40 -!- frispete(~frispete@p54A93A72.dip0.t-ipconnect.de) has joined #tryton
2014-02-19 07:20 -!- udono(~udono@ip-109-90-114-182.unitymediagroup.de) has joined #tryton
2014-02-19 07:38 -!- sharoonthomas(~sharoonth@122.177.202.244) has joined #tryton
2014-02-19 07:44 -!- pobsteta(~Thunderbi@4cb54-3-88-160-87-54.fbx.proxad.net) has joined #tryton
2014-02-19 07:51 -!- grasbauer(~jan@ipservice-092-208-143-080.pools.arcor-ip.net) has joined #tryton
2014-02-19 08:09 -!- mfladischer(~fladische@2a01:4f8:191:4a4:f8c1:98ff:fe1b:f56c) has joined #tryton
2014-02-19 08:19 -!- vernichon(~Thunderbi@gex01-1-78-234-55-95.fbx.proxad.net) has joined #tryton
2014-02-19 08:28 -!- corro(~corro@46.22.23.85) has joined #tryton
2014-02-19 09:03 -!- digitalsatori(~Thunderbi@114.92.211.41) has joined #tryton
2014-02-19 09:08 -!- grasbauer1(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 09:13 -!- jvblasco(~seba@62.43.196.37.static.user.ono.com) has joined #tryton
2014-02-19 09:23 -!- jvblasco(~seba@62.43.196.37.static.user.ono.com) has joined #tryton
2014-02-19 09:23 <jvblasco> morning everyone
2014-02-19 09:29 <defyasdf> morning
2014-02-19 09:40 -!- nicoe(~nicoe@109.133.138.125) has joined #tryton
2014-02-19 09:42 -!- littlebit(~Thunderbi@ulmg-5d8442ee.pool.mediaWays.net) has joined #tryton
2014-02-19 09:49 -!- digitalsatori(~Thunderbi@114.92.211.41) has joined #tryton
2014-02-19 09:55 -!- grasbauer(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 09:55 <corro> Is anyone experienced in stock management in Tryton? What's the intended strategy for assigning goods to outgoing shipments once they are purchased?
2014-02-19 10:07 -!- cedk(~ced@gentoo/developer/cedk) has joined #tryton
2014-02-19 10:18 -!- strebitz(~sebastian@91.183.59.105) has joined #tryton
2014-02-19 10:49 -!- jeancavallo(~giovanni@LVelizy-156-46-68-52.w80-12.abo.wanadoo.fr) has joined #tryton
2014-02-19 10:51 -!- Telesight(~anthony@77-175-168-222.FTTH.ispfabriek.nl) has joined #tryton
2014-02-19 11:06 -!- jeancavallo(~giovanni@LVelizy-156-46-68-52.w80-12.abo.wanadoo.fr) has left #tryton
2014-02-19 11:07 -!- jeancavallo(~giovanni@LVelizy-156-46-68-52.w80-12.abo.wanadoo.fr) has joined #tryton
2014-02-19 11:24 -!- sharoonthomas(~sharoonth@122.177.202.244) has joined #tryton
2014-02-19 12:03 -!- sharoonthomas(~sharoonth@122.177.202.244) has joined #tryton
2014-02-19 12:21 -!- grasbauer(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 12:31 -!- smarro(~sebastian@200.107.230.29) has joined #tryton
2014-02-19 12:35 -!- vcardon(~vcardon@LNeuilly-152-23-15-185.w193-252.abo.wanadoo.fr) has joined #tryton
2014-02-19 12:41 -!- nicoe(~nicoe@2001:6f8:3aa:0:b699:baff:fe56:2328) has joined #tryton
2014-02-19 13:47 <jvblasco> can anyone point me some code making use of function fields? Not the field definition, the usage of the field.
2014-02-19 13:48 <jvblasco> i'm trying to understand how do function fields exactly work, they seem powerfull but i cannot figure out how to use them just from the API documentation.
2014-02-19 13:49 <meanmicio> jvblasco : check the patient age in GNU Health
2014-02-19 13:54 <jvblasco> meanmicio: where i find the code? i mean, do u have any public repo i can check?
2014-02-19 13:54 <jvblasco> where can i*
2014-02-19 13:55 <jeancavallo> jvblasco: Have a look here : http://hg.tryton.org/modules/account/file/a1176be9fa2d/party.py#l57
2014-02-19 13:55 <meanmicio> jvblasco : http://health.gnu.org or the mercurial repo http://hg.savannah.gnu.org/hgweb/health/
2014-02-19 13:56 <jeancavallo> jvblasco: Function fields are useful to display / search calculated data based on the stored columns of the model
2014-02-19 13:56 <jeancavallo> jvblasco: To use them in your code, they are supposed to behave as normal fields, except for the fact that they cannot be set (unless you define the setter function)
2014-02-19 13:57 <jvblasco> jeancavallo: but can i use them like normal fields. eg: Party.my_function_field?
2014-02-19 13:57 <jeancavallo> jvblasco: yes
2014-02-19 13:57 <jvblasco> jeancavallo: and display them in views without problems?
2014-02-19 13:57 <jeancavallo> jvblasco: A few limitations : no setting (unless explicitely allowed in the field definition), not calculated while the record is not saved
2014-02-19 13:59 <jeancavallo> jvblasco: As I said, if you display the view on an already existing record, no problem
2014-02-19 14:00 <jeancavallo> jvblasco: If you want your function field to be calculated even though the record is not yet saved, the best approach is to use an on_change_with on your field, and use it as the getter of the function field.
2014-02-19 14:00 <jvblasco> jeancavallo: ic
2014-02-19 14:01 <jvblasco> jeancavallo: and do i need to implement the getter to be able to use it like a normal field?
2014-02-19 14:01 <jeancavallo> jvblasco: Function fields are very powerful, but there are some tricks to know :)
2014-02-19 14:01 <jeancavallo> jvblasco: Well, if you don't tryton will have no way to know what is the value of your field
2014-02-19 14:02 <jeancavallo> jvblasco: And I think the getter is mandatory ;)
2014-02-19 14:02 <jeancavallo> jvblasco: The setter / searcher are not though
2014-02-19 14:02 <jvblasco> jeancavallo: i will need to experiment with that
2014-02-19 14:03 <jeancavallo> jvblasco: Good luck
2014-02-19 14:03 <jvblasco> jeancavallo: it REALLY looks powerfull
2014-02-19 14:03 <jeancavallo> jvblasco: The link I sent you is some of the best use you can have
2014-02-19 14:03 <jeancavallo> jvblasco: The getter is a classmethod (it can be an instance method as well), so the computation is done at the database level for lists of records
2014-02-19 14:04 <jeancavallo> jvblasco: It is a little complex though.
2014-02-19 14:05 <jeancavallo> jvblasco: Another example is "rec_name". When you override get_rec_name, you override the getter of the function field "rec_name" (sort of)
2014-02-19 14:05 <jvblasco> jeancavallo: i already realized about complexity
2014-02-19 14:06 <jvblasco> jeancavallo: so, to check my understanding, in the link with the def get_receivable_payable(cls, parties, names): i guess parties are party instances, and names are the name of the fields u want to use?
2014-02-19 14:06 <jvblasco> jeancavallo: i don't really understand the method signature
2014-02-19 14:08 <jeancavallo> jvblasco: That's it
2014-02-19 14:08 <jeancavallo> jvblasco: You can use the same method as a getter for multiple fields (hence the "name" parameter
2014-02-19 14:10 <jvblasco> jeancavallo: i will try to implement one for a use case i have around the code, i hope to be able to with that explanation
2014-02-19 14:10 <jvblasco> jeancavallo: i think i understand them a little better now ;)
2014-02-19 14:10 <jvblasco> jeancavallo: thnx so much for all the help
2014-02-19 14:13 <jeancavallo> jvblasco: np
2014-02-19 14:35 -!- Streward(~quassel@85.183.31.24) has joined #tryton
2014-02-19 14:46 -!- littlebit(~Thunderbi@ulmg-5d8442ee.pool.mediaWays.net) has joined #tryton
2014-02-19 15:29 -!- vernichon(~Thunderbi@gex01-1-78-234-55-95.fbx.proxad.net) has joined #tryton
2014-02-19 15:45 -!- pablovannini(~pablo@181.47.181.28) has joined #tryton
2014-02-19 15:57 <jvblasco> jeancavallo: u said that usually function fields are implemented as classmethods, but that sometimes can be implemented as instance methods, how do i know which one is the best way for a precise impelmentation?
2014-02-19 15:58 <jeancavallo> jvblasco: It is the opposite
2014-02-19 15:58 <jeancavallo> jvblasco: Usually they are implemented as instance method
2014-02-19 15:59 <jvblasco> jeancavallo: i c, and how do i know when a classmethod is more convenient?
2014-02-19 15:59 <jeancavallo> jvblasco: The use of classmethod is for when the computation is rather db intensive (aggregates...), so it is more efficient to to it by groups
2014-02-19 15:59 <jvblasco> jeancavallo: i c, 1000 thnx ;)
2014-02-19 16:00 <jeancavallo> jvblasco: The example I sent earlier is db intensive, so it is a classmethod
2014-02-19 16:00 <jeancavallo> jvblasco: Bottom line is : classmethod when you have performance issues can help
2014-02-19 16:01 <jvblasco> jeancavallo: ok, not my case right now, i hope ;)
2014-02-19 16:01 <corro> jvblasco: also getter instance methods can often also be used as on_change method at the same time. this can be an advantage (less duplication).
2014-02-19 16:02 <jvblasco> corro, jeancavallo: that could be usefull for realtime view value rendering, as jean was sugesting b4?
2014-02-19 16:02 <jeancavallo> jvblasco: yeah
2014-02-19 16:03 <jvblasco> jeancavallo, corro: i c
2014-02-19 16:03 <jeancavallo> jvblasco: my_field = fields.Function(fields.Char('Party Name', on_change_with=['party']), 'on_change_with_my_field')
2014-02-19 16:03 <jvblasco> omg
2014-02-19 16:03 <jeancavallo> jvblasco: Just do not forget to add a name=None parameter in the on_change_with_my_field definition so it is both callable as a on_change_with and as a function field getter
2014-02-19 16:04 <jvblasco> jeancavallo: i c
2014-02-19 16:05 <jvblasco> btw the getter signature is getter(self, models, names), in case of instance methods what will i receive to models when i try to use the fields as a regular field?
2014-02-19 16:05 <jvblasco> and do i receive instances, or just the class?
2014-02-19 16:05 <jvblasco> sry about this but those fields, as powerfull as they are, they are rather complex too
2014-02-19 16:07 <jvblasco> in the example i see it receives parties, but i can't figure out how those parties list is generated
2014-02-19 16:09 <jeancavallo> jvblasco: It is automatic. You should never have to call the getter manually
2014-02-19 16:10 <jeancavallo> jvblasco: and the signature for instance methods is : def my_getter(self, name) where name will be the field calling the getter
2014-02-19 16:10 -!- strebitz(~sebastian@91.183.59.105) has left #tryton
2014-02-19 16:13 <jvblasco> so no models in the call?
2014-02-19 16:16 <jvblasco> i guess it's because the example b4 is a classmethod and not an instance one
2014-02-19 16:16 <jvblasco> could it be?
2014-02-19 16:16 <jeancavallo> jvblasco: If you mean the party.receivable / payable, yes
2014-02-19 16:34 <jvblasco> and what do i need to return in the getter function? i mean the structure. In my case i'm making a Function field for a boolean field
2014-02-19 16:35 <cedk> jvblasco: http://doc.tryton.org/3.0/trytond/doc/ref/models/fields.html?highlight=function#trytond.model.fields.Function.getter
2014-02-19 16:36 <jvblasco> cedk: but i don't know from those docs the structure of the value i need to return
2014-02-19 16:36 <jvblasco> cedk: if i return a boolean and exception is rised
2014-02-19 16:37 <jvblasco> cedk: TypeError: 'bool' object has no attribute '__getitem__'
2014-02-19 16:37 <jeancavallo> jvblasco: What is the exception ? You should return the type corresponding to the main field (integers for M2O !)
2014-02-19 16:37 <cedk> jvblasco: the doc is pretty clear about the return
2014-02-19 16:38 <jeancavallo> jvblasco: It means you are using a classmethod, so it's expected to return a dict matching ids and values
2014-02-19 16:38 <cedk> jvblasco: but of course it is abvious that the value is the value
2014-02-19 16:40 <jvblasco> cedk, jeancavallo: so in a definition: fields.Function(fields.Boolean('Blackout') the getter i guess must return a boolean, doesn't it?
2014-02-19 16:42 <jvblasco> i'm implementing the getter as an instance method with def get_blackout(self, names): signature
2014-02-19 16:42 <cedk> jvblasco: names -> name
2014-02-19 16:45 <jvblasco> jeancavallo, cedk: that was the issue, thnx so much both of you for the help
2014-02-19 16:53 <jvblasco> cedk: btw, u were right, in the documentation is clear the return value
2014-02-19 17:19 -!- grasbauer(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 17:34 -!- rafiu(~Adium@host81-139-178-190.in-addr.btopenworld.com) has joined #tryton
2014-02-19 17:49 -!- grasbauer(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 18:59 <jvblasco> i'm trying to figure out what tuples does the searcher need to return, but i cannot seem to
2014-02-19 19:00 <jvblasco> i created a model Website with a m2o relation to a party, the party has a o2m relation to the website model
2014-02-19 19:00 <jvblasco> the website model has a blackout boolean field
2014-02-19 19:00 <jvblasco> the party has a Function field that checks if any of his websites is in blackout
2014-02-19 19:01 <jvblasco> if any one of those is, then the field sets to True
2014-02-19 19:01 <jvblasco> if not to false
2014-02-19 19:01 <jvblasco> but i want to search if a party has a blackout
2014-02-19 19:01 <jvblasco> using the function field, what means a searcher needs to be implemented
2014-02-19 19:02 <jvblasco> but i can't figure out the list of tuples the searcher needs to return
2014-02-19 19:03 <jvblasco> for example: Party.search([('blackout', '=', True)])
2014-02-19 19:03 <jvblasco> what will the tupple the searcher returns contain?
2014-02-19 19:05 <jvblasco> [('party.id', '=', party.id)]?
2014-02-19 19:05 <jvblasco> for parties that have a web with blackout = True?
2014-02-19 19:05 <jvblasco> i don't really get what is done with that list of tuples, or what it is for
2014-02-19 19:07 <jvblasco> sry for the text wall
2014-02-19 19:08 <cedk> jvblasco: http://doc.tryton.org/3.0/trytond/doc/ref/models/fields.html?highlight=function#trytond.model.fields.Function.searcher
2014-02-19 19:09 <jvblasco> but i don't understand what does the domain it returns contain
2014-02-19 19:10 <cedk> jvblasco: read the domain doc
2014-02-19 19:16 -!- grasbauer(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 19:18 -!- zodman(~zodman@foresight/developer/zodman) has joined #tryton
2014-02-19 19:45 -!- cjbarnes18(~craig@host31-54-129-199.range31-54.btcentralplus.com) has joined #tryton
2014-02-19 20:28 -!- chitrank(~chitrank@113.193.107.176) has joined #tryton
2014-02-19 20:28 <chitrank> Hello Tryton developers
2014-02-19 20:37 -!- cjbarnes18(~craig@host31-54-129-199.range31-54.btcentralplus.com) has joined #tryton
2014-02-19 20:55 -!- grasbauer1(~jan@dslb-092-078-089-071.pools.arcor-ip.net) has joined #tryton
2014-02-19 21:11 -!- pobsteta(~Thunderbi@4cb54-3-88-160-87-54.fbx.proxad.net) has joined #tryton
2014-02-19 21:13 -!- pobsteta(~Thunderbi@4cb54-3-88-160-87-54.fbx.proxad.net) has joined #tryton
2014-02-19 21:50 -!- frispete(~frispete@p54A93A72.dip0.t-ipconnect.de) has joined #tryton
2014-02-19 21:54 -!- yangoon1(~mathiasb@p549F16C7.dip0.t-ipconnect.de) has left #tryton
2014-02-19 22:27 -!- yangoon(~mathiasb@p549F16C7.dip0.t-ipconnect.de) has joined #tryton
2014-02-19 22:42 -!- smarro(~sebastian@201.251.135.150) has joined #tryton
2014-02-19 22:47 -!- swayf(~swayf@188-193-123-49-dynip.superkabel.de) has joined #tryton

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