IRC logs of #tryton for Friday, 2013-11-15

chat.freenode.net #tryton log beginning Fri Nov 15 00:00:02 CET 2013
2013-11-15 13:06 <pokoli> Hi, i have two views on the same model with diferent contexts. Is possible to disable the create option on the client depending on the context?
2013-11-15 13:06 <pokoli> s/view/action/
2013-11-15 13:06 <pokoli> So you can create records from one action and you don't from the other
2013-11-15 13:25 <jvblasco> i think i'm having some troubles with contexts too, but they are a great unkown for me
2013-11-15 13:25 <jvblasco> i don't think i can help on that sry
2013-11-15 13:27 <pokoli> jvblasco: I can try helping on your troubles
2013-11-15 13:33 <jvblasco> pokoli: i'm trying to generalize the carrier_grid module i presented in the TUB
2013-11-15 13:35 <jvblasco> pokoli: the problem is that when onchange_carrier is called (with sale_shipment_cost module installed) the method _get_carrier_context is called too in the sale.sale model
2013-11-15 13:36 <cedk> pokoli: no
2013-11-15 13:36 <jvblasco> pokoli: but as i try to access the resource variables it throws an error that they don't exist, i've checked the resource id and it says none, but i can access some resources
2013-11-15 13:37 <jvblasco> pokoli: but i don't know why
2013-11-15 13:37 <cedk> jvblasco: you have to define in the on_change list all the fields you will access in your method
2013-11-15 13:38 <pokoli> cedk: I imagined that wasn't possible so I managed to do in another way. Thanks!
2013-11-15 13:38 <cedk> pokoli: access right should not depend on the context
2013-11-15 13:39 <cedk> pokoli: indeed depending on context should always tried to be avoid
2013-11-15 13:39 <jvblasco> cedk: i c, how do i overload that then?
2013-11-15 13:39 <cedk> jvblasco: you can in __setup__ method
2013-11-15 13:40 <jvblasco> cedk: any code i can check to learn how to do it?
2013-11-15 13:40 <cedk> jvblasco: but I fill an issue to improve that: https://bugs.tryton.org/issue3487
2013-11-15 13:43 <cedk> jvblasco: http://hg.tryton.org/modules/sale_shipment_cost/file/e32344abde19/sale.py#l50
2013-11-15 13:44 <jvblasco> cedk: thnx so much
2013-11-15 13:59 <jvblasco> cedk: solved, thnx so much, btw may i ask what does the second for exactly do? I understand the first for, it's very straightforward, but i cannot figure out the second one
2013-11-15 14:01 <cedk> jvblasco: it is to sync both on_change because on_change_carrier calls on_change_lines
2013-11-15 14:05 <jvblasco> cedk: so, if u have an onchange chain call, like this one, right now one must synchronize all the onchange methods that way and add a for loop for every onchange method called?
2013-11-15 14:47 <cedk> jvblasco: yes
2013-11-15 14:47 <cedk> jvblasco: but it is something that you should try to avoid
2013-11-15 15:15 <jvblasco> cedk: ok, thnx
2013-11-15 16:52 <pokoli> Hi, when an exception is thrown, all the entire transaction is rolled back, isn't it?
2013-11-15 16:52 <pokoli> So what i have to do if I want to save some value in the database?
2013-11-15 16:57 <jvblasco> pokoli: may not be the best idea, but catching the exception and creating a register to save the data?
2013-11-15 16:57 <pokoli> jvblasco: yes but the register is not saved, as the transaction is rolled back :)
2013-11-15 16:57 <pokoli> so I'm trying to start another transaction
2013-11-15 16:58 <jvblasco> pokoli: that's what i mean, in the catch block, create another transaction and save the data u need
2013-11-15 16:58 <jvblasco> pokoli: not sure how catch block is called in python
2013-11-15 16:58 <pokoli> jvblasco: that's what amb trying :)
2013-11-15 16:59 <jvblasco> pokoli: anyway, are u saving the data just for later use?
2013-11-15 16:59 <jeancavallo> pokoli: I already did that somewhere, for logging the rule engine I showed at the tub
2013-11-15 16:59 <jeancavallo> pokoli: But you got to be extra careful in your transaction management
2013-11-15 17:00 <pokoli> jeancavallo: that's why i'm asking, because I have to be very carefull.
2013-11-15 17:01 <jeancavallo> pokoli: If what you are writing in the new cursor has references to instances which where modified in the source transaction, it might save them as well
2013-11-15 17:01 <jeancavallo> pokoli: (Don't know if I am clear enough)
2013-11-15 17:01 <jvblasco> pokoli: i haven't worked with transactions to that lvl yet, i wouldn't recommend my own help lol
2013-11-15 17:01 <jeancavallo> pokoli: Base is : with Transaction().new_cursor():
2013-11-15 17:02 <pokoli> jeancavallo: so I must avoid using self.save and prefer using cls.write?
2013-11-15 17:02 <jeancavallo> pokoli: Only way to be sure is to avoid writing relation fields
2013-11-15 17:02 <pokoli> jeancavallo: I want to write a char field, so I may use cls.write better than self.save()
2013-11-15 17:02 <pokoli> jeancavallo: thanks for your tips, very usefull!
2013-11-15 17:03 <jeancavallo> pokoli: Not what I meant. If you create a new instance, which has a M2O toward a field which is already updated in your 'main' transaction (which will be rollbacked), you're screwed
2013-11-15 17:03 <pokoli> ACTION had written all the code in the wrong way
2013-11-15 17:03 <jeancavallo> pokoli: You may be abnle to manage with setting an id rather than a brwose object, but I am not sure
2013-11-15 17:04 <pokoli> jeancavallo: I understood :) give me some time to try it :P
2013-11-15 17:04 <jeancavallo> pokoli: Anyway, you should find a better way if it exists, like logging, etc...
2013-11-15 17:05 <pokoli> jeancavallo: It's for the babi module, as calculations are done in background, i need to store if the calculation has some errors or is still calculating :P
2013-11-15 17:06 <cedk> pokoli: transactional database are not very good for that
2013-11-15 17:06 <pokoli> cedk: I'm sure that they aren't
2013-11-15 17:07 <jvblasco> how about maybe using another database backend for all the calculation process, and dumping it when finished and checked to the transactional one?
2013-11-15 17:07 <cedk> pokoli: why not link with a task manager? And for example, celery :-)
2013-11-15 17:08 <jeancavallo> pokoli: http://pastebin.com/YwnNZYcT , some ort of example
2013-11-15 17:09 <pokoli> jeancavallo: thanks!
2013-11-15 17:10 <pokoli> cedk: because celery uses and external database to write results and I would need to write a bunch of code to addapt their results to be displayed on tryton client
2013-11-15 17:10 <pokoli> cedk: we're using http://codereview.tryton.org/685003/ :P
2013-11-15 17:11 <pokoli> cedk: there is some plan to release it?
2013-11-15 17:11 <jeancavallo> pokoli: It's a quick copy paste from our source, but it is some sort of logging in case of error (we are in an Except block, exc line 12 is the traceback we extracted)
2013-11-15 17:11 <cedk> pokoli: indeed, I don't know exactly where to put it
2013-11-15 17:11 <cedk> pokoli: I don't think its place is on tryton.org
2013-11-15 17:12 <cedk> pokoli: so probably I will have to create a google host project
2013-11-15 17:13 <pokoli> cedk: or maybe you can create a github account :)
2013-11-15 17:13 <pokoli> ACTION just kidding
2013-11-15 17:13 <cedk> pokoli: about external DB to write result that exactly why it is good in your cases because you are not link to the tryton transaction
2013-11-15 17:13 <pokoli> cedk: way not realeasing on tryton.org as done with proteus?
2013-11-15 17:13 <pokoli> cedk: you may need the same schema versioning
2013-11-15 17:14 <pokoli> cedk: as some changes on the api may cause errors on trytond_celery
2013-11-15 17:14 <pokoli> cedk: about external DB. I know you're absolutily right, I will try to improve it some day :)
2013-11-15 17:17 <cedk> pokoli: about versioning, yes but I don't think it is enough to be part of the standard
2013-11-15 17:17 <cedk> pokoli: most usage of Tryton will not require this tool
2013-11-15 17:17 <cedk> and even, others “connection” will be developped in the furture and I don't think we should host all of them
2013-11-15 17:18 <pokoli> cedk: agree but it's an extension to the tryton framework so can be hold be the tryton foundation
2013-11-15 17:18 <pokoli> cedk: same as offical modules and community one's
2013-11-15 17:19 <pokoli> jeancavallo: You have a except DatabaseOperationError next to the commit?? To rollback if errors on database?
2013-11-15 17:19 <jeancavallo> pokoli: It is handled "above"
2013-11-15 17:20 <pokoli> jeancavallo: you mean in the with statement?
2013-11-15 17:20 <jeancavallo> pokoli: Almost sure of it
2013-11-15 17:20 <jeancavallo> pokoli: But indeed I should check :)
2013-11-15 17:21 <pokoli> ACTION has locked the database :____(
2013-11-15 17:22 <cedk> pokoli: foundation doesn't have yet the ressource to hosts external project
2013-11-15 17:22 <jeancavallo> pokoli: Oops...
2013-11-15 17:23 <jeancavallo> pokoli: Looks like it is not handled properly. Did not bother me because I had no problem in this code, but thanks for pointing out
2013-11-15 17:24 <pokoli> jeancavallo: just pointed it for helping you. No problem.
2013-11-15 17:25 <pokoli> cedk: So i think a google code would be a great pleace
2013-11-15 17:25 <jeancavallo> pokoli: <ninja>github</ninja>
2013-11-15 17:25 <jvblasco> guys may i ask what may be the TODO file format?
2013-11-15 17:26 <pokoli> cedk: IMHO the important think is to have it available on pypi
2013-11-15 17:26 <cedk> pokoli: of course
2013-11-15 19:07 <martinguzman> Hi all! Is there a way to know the ip or mac address that a user is using to be connected?
2013-11-15 19:12 <cedk> martinguzman: it is logged by trytond on login
2013-11-15 19:13 <martinguzman> cedk, but how can I get that info? (on a Wizard, for example)
2013-11-15 19:17 <cedk> martinguzman: you can't
2013-11-15 19:20 <martinguzman> cedk: ok! Thanks
2013-11-15 19:55 -!- vcardon(~vcardon@LNeuilly-152-23-15-185.w193-252.abo.wanadoo.fr) has left #tryton
2013-11-15 22:25 -!- pablovannini(~pablo@181.47.181.28) has left #tryton
2013-11-15 22:51 <hellhound> I'm currently implementing a web client for trytond and recently stumbled on something that seems weird on the ir.ui.menu model, apparently the parameter name in the get_action() method isn't being used
2013-11-15 22:52 <hellhound> you can see what I'm talking about on this pastie http://pastie.org/8483573
2013-11-15 23:23 <plantian> hellhound: I think that is because it is a function field. In order to use the same functions for multiple function fields that param exists, but if you just have 1 to 1 between the functions and the function field then the field name is assumed.

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