IRC logs of #tryton for Friday, 2021-04-09

chat.freenode.net #tryton log beginning Fri Apr 9 12:00:02 AM CEST 2021
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton22:31
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton01:47
-!- thaneor2(~ldlc6@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton02:31
-!- thaneor(~acer8@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton02:32
-!- alidipatrick(~alidipatr@154.126.121.233) has joined #tryton04:15
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton04:54
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton05:03
-!- alidipatrick(~alidipatr@154.126.12.140) has joined #tryton05:47
-!- thaneor(~ldlc6@r167-61-193-125.dialup.adsl.anteldata.net.uy) has joined #tryton05:50
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton06:14
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton06:33
LordVanhi06:43
LordVana quick question: I want to make a selection of a product mandatory for the sale line06:43
LordVanhow would I need to go about that?06:43
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton07:12
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton07:14
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton07:15
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton07:35
mrichezlordvan: hi, you mean a selection field ?07:39
LordVanmrichez, https://github.com/tryton/sale/blob/2fdcc8ab33c0f32462f1b0433d1d08eafc1762a9/sale.py#L109507:42
mrichezLordVan: you've to add a state 'required' for product07:45
LordVanyes but how would I do that without changing anything else on my custom SaleLIne classe?07:45
LordVani mean i could just re-define it by using copy paste from the original and add required07:45
mrichezLordVan: no, better to do a custo and add it in setup method07:46
LordVanhm yeah i'D been thinking if i can somehow add it in a setup method or so07:47
LordVangoing to have to look if i can find an example. thanks07:47
-!- sisalp(~sisalpuse@51.sisalp.net) has joined #tryton08:05
-!- udono(~udono@055-128-067-156.ip-addr.inexio.net) has joined #tryton08:05
-!- Pilou(~Pilou@pdpc/supporter/active/pilou) has joined #tryton08:05
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton08:05
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton08:05
-!- ChanServ(ChanServ@services.) has joined #tryton08:05
-!- yangoon(~mathiasb@p5dd08c0b.dip0.t-ipconnect.de) has joined #tryton08:05
-!- buxy(~rhertzog@helios.freexian.com) has joined #tryton08:05
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton08:05
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton08:05
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton08:05
-!- plaes(~plaes@unaffiliated/amd) has joined #tryton08:05
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton08:05
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton08:05
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton08:05
-!- lucascastro(~lucascast@177-185-133-170.dynamic.isotelco.net.br) has joined #tryton08:05
-!- g5pw(~g5pw@mittelab/sudo/g5pw) has joined #tryton08:05
-!- pokoli(~pokoli@unaffiliated/pokoli) has joined #tryton08:05
-!- kwmiebach(sid16855@gateway/web/irccloud.com/x-xltmgyuuyeyvcory) has joined #tryton08:05
-!- cryptic(~cryptic@142.196.139.17) has joined #tryton08:05
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton08:06
-!- jani-matti(~quassel@93-90-53-6.welcomnet.fi) has joined #tryton08:06
-!- mniip(mniip@freenode/staff/mniip) has joined #tryton08:06
-!- nicoe(~nicoe@2a02:578:852a:c00:224:9bff:fe6c:a1b2) has joined #tryton08:06
-!- ajain(ajain@gateway/shell/hashbang/x-oxqnkotzoxwngjgx) has joined #tryton08:49
-!- sharkcz(~sharkcz@19.161.broadband4.iol.cz) has joined #tryton08:49
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton08:56
LordVanso I would do something like this?: in def __setup__(cls): super(Sale, ....) cls._fields['product']['required'] = True ?09:13
LordVanor is that not the way to do this?09:13
LordVanor cls.product.required = True09:15
LordVanor .. after reading https://discuss.tryton.org/t/overriding-a-module-setting-a-required-attribute-field-to-true/2756/409:15
LordVanmaybe i should just raise an error when adding a sale line09:16
LordVanwithout product09:16
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton09:17
LordVanfor me it seems to make most sense to just do cls.product.required  =True09:20
LordVanin __setup__09:20
LordVan[[the reason i am doing this is because the system users are ... annoying and lazy so they just do not select articles sometimes as it still works with the first reports)09:21
cedkLordVan: the problem by adding a required is that other part of the code may rely on it not being required09:23
LordVanyes i read that in the discussion09:26
LordVanso i am unsure what to best do now09:26
LordVanwell i do have an alternative09:26
LordVani already have my own custom fields that used on the report and are read only when there is a product selected09:27
LordVanif i put them permanently read-only then the users have to select a product to get them filled in09:27
LordVanand if in addition to that i make one or more of those required ..09:27
LordVanthen i'D block them too without changing the existing fields09:28
LordVanthough wouldn'T my custom required fields potentially block other workflows too?09:28
cedkLordVan: yes but workflow are rarely triggered by process but only by user09:40
cedkLordVan: also you can just make it a warning so process will ignore them09:41
LordVantrue09:41
LordVancedk, so basically it would be better to just make one of my readonly fields required09:41
LordVan(a field that is filled out by my custom on_change_product method09:42
LordVanhttps://github.com/LordVan/tryton-modules/blob/37e7dd175ab586391108cd9648fb03d93b60c19d/rm_extra_data/sale.py#L124 <- that i mean09:43
LordVanah i just noticed something09:43
LordVanwould i need to add 'product' to the fields.depends too?09:43
cedkLordVan: well most of the time software can not fix user behavior09:43
LordVancedk, no but it can limit09:43
cedkLordVan: so if you want to enforce to fill product on sale line, I guess the best is to add a check on quotation transition09:44
LordVanyes, but then the user needs to go back to the sale line to fix it..09:44
LordVanthus "punishing" the user for not selecting a product09:45
LordVani might just like that best :D09:45
cedkLordVan: or maybe on confirm09:47
cedkyou may need to make quote without already knowning the product09:47
LordVanyes one or the other09:48
LordVancedk, btw the github link.. are the decorators correct like that or do i need to add product itself too? i mean since it gets triggered on change of the product i did not so far, but sort of unsure09:48
mrichezLordVan: you should add 'product' in your depends09:54
LordVanok thanks i will do that.09:55
-!- mariomop(~quassel@181.29.189.235) has joined #tryton10:52
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton11:01
-!- thaneor1(~ldlc6@190.135.79.134) has joined #tryton11:03
-!- thaneor(~acer8@r190-135-79-134.dialup.adsl.anteldata.net.uy) has joined #tryton11:19
-!- thaneor2(~acer8@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton11:46
-!- thaneor1(~ldlc6@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton11:47
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton11:56
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton11:59
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton12:25
mrichezhi, can i use decorator @set_employee on method def create ?12:50
-!- ludo2(~Thunderbi@2001:912:1480:380::1) has joined #tryton12:50
pokolimrichez: no, the set_employee expects a list of records as second parameter but the create has a list of dictionaries12:53
mrichezpokoli: ok, it was to avoid to find another way to store this field if i could use set_employee12:55
mrichezcan we get in a field the employee who create a record ?13:00
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton13:16
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton13:22
pokolimrichez: you can use a default value of context.get('employee')13:25
mrichezpokoli: find a solution here: https://hg.tryton.org/trytond/file/tip/trytond/ir/email_.py#l7213:26
pokolimrichez: That's the user not the employee :P13:27
mrichezpokoli: indeed... :-)13:28
mrichezpokoli: but usually we have 1 user=1 employee (it's to have an indication for the manager to set the correct employee responsible of a party) . Employee can create party but only manager can set the employee linked to this party. So he needs an information (create_uid seems good)13:31
pokolimrichez: at this point if you do not want to set the employee the create_user is the only available information13:39
mrichezpokoli: yes :-)13:40
mrichezpokoli: one last question: can i set a field visible only to a group ?13:47
pokolimrichez: yes, you should create a ir.model.field rule that restricts the read usage to a group13:49
pokoliSo other users will not see13:49
pokolimrichez: IIRC you can even set a ir.rule to a field that the user is not allowed to see13:50
pokolimrichez: so for example you can set a rule for employees to only see it's parties but allow only a set of users to see the employee of the party (managers)13:50
mrichezpokoli: ok, i thought to this possibility but i also find this: https://hg.tryton.org/modules/stock/file/tip/shipment.py#l261513:52
mrichezit's in a wizard, could it be also apply on a form ?13:52
pokolimrichez: this is to restrict a button on a wizard13:53
mrichezpokoli: it won't work on a field ?13:54
pokolimrichez: no for fields you need something like this: https://hg.tryton.org/modules/bank/file/d4d5f1774bd1/party.xml#l1213:54
pokoliIn this case the field is always shown but only users of the group can write to it13:54
pokolisetting perm_read to False on the rule will hide the field13:54
mrichezpokoli: ok, i used this with my yesterday discuss: https://discuss.tryton.org/t/write-access-rules-to-group-depending-on-a-field/4016/613:55
mrichezpokoli: thanks!13:56
pokolimrichez: yes, you already used the field restriction to restrict writting on a field. Same applies for reading :)13:56
mrichez:-)13:56
mrichezpokoli: working nice! thx.14:04
pokolimrichez: you're welcome. rules and fields permissions are very powerfull once you now how to fix it14:21
-!- ludo2(~Thunderbi@221.114.141.88.rev.sfr.net) has joined #tryton16:16
-!- lucascastro(~lucascast@177-185-139-161.dynamic.isotelco.net.br) has joined #tryton18:46
-!- lucascastro(~lucascast@177-185-139-90.dynamic.isotelco.net.br) has joined #tryton19:45
-!- lucascastro(~lucascast@177-185-133-243.dynamic.isotelco.net.br) has joined #tryton19:53

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