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 #tryton00:04
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton03:04
-!- thaneor2(~ldlc6@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton04:04
-!- thaneor(~acer8@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton04:04
-!- alidipatrick(~alidipatr@154.126.121.233) has joined #tryton06:04
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton06:04
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton07:04
-!- alidipatrick(~alidipatr@154.126.12.140) has joined #tryton07:04
-!- thaneor(~ldlc6@r167-61-193-125.dialup.adsl.anteldata.net.uy) has joined #tryton07:04
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton08:04
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton08:04
LordVanhi08:04
LordVana quick question: I want to make a selection of a product mandatory for the sale line08:04
LordVanhow would I need to go about that?08:04
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton09:04
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton09:04
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton09:04
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton09:04
mrichezlordvan: hi, you mean a selection field ?09:04
LordVanmrichez, https://github.com/tryton/sale/blob/2fdcc8ab33c0f32462f1b0433d1d08eafc1762a9/sale.py#L109509:04
mrichezLordVan: you've to add a state 'required' for product09:04
LordVanyes but how would I do that without changing anything else on my custom SaleLIne classe?09:04
LordVani mean i could just re-define it by using copy paste from the original and add required09:04
mrichezLordVan: no, better to do a custo and add it in setup method09:04
LordVanhm yeah i'D been thinking if i can somehow add it in a setup method or so09:04
LordVangoing to have to look if i can find an example. thanks09:04
-!- sisalp(~sisalpuse@51.sisalp.net) has joined #tryton10:04
-!- udono(~udono@055-128-067-156.ip-addr.inexio.net) has joined #tryton10:04
-!- Pilou(~Pilou@pdpc/supporter/active/pilou) has joined #tryton10:04
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton10:04
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton10:04
-!- ChanServ(ChanServ@services.) has joined #tryton10:04
-!- yangoon(~mathiasb@p5dd08c0b.dip0.t-ipconnect.de) has joined #tryton10:04
-!- buxy(~rhertzog@helios.freexian.com) has joined #tryton10:04
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton10:04
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton10:04
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton10:04
-!- plaes(~plaes@unaffiliated/amd) has joined #tryton10:04
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton10:04
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton10:04
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton10:04
-!- lucascastro(~lucascast@177-185-133-170.dynamic.isotelco.net.br) has joined #tryton10:04
-!- g5pw(~g5pw@mittelab/sudo/g5pw) has joined #tryton10:04
-!- pokoli(~pokoli@unaffiliated/pokoli) has joined #tryton10:04
-!- kwmiebach(sid16855@gateway/web/irccloud.com/x-xltmgyuuyeyvcory) has joined #tryton10:04
-!- cryptic(~cryptic@142.196.139.17) has joined #tryton10:04
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton10:04
-!- jani-matti(~quassel@93-90-53-6.welcomnet.fi) has joined #tryton10:04
-!- mniip(mniip@freenode/staff/mniip) has joined #tryton10:04
-!- nicoe(~nicoe@2a02:578:852a:c00:224:9bff:fe6c:a1b2) has joined #tryton10:04
-!- ajain(ajain@gateway/shell/hashbang/x-oxqnkotzoxwngjgx) has joined #tryton10:04
-!- sharkcz(~sharkcz@19.161.broadband4.iol.cz) has joined #tryton10:04
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton10:04
LordVanso I would do something like this?: in def __setup__(cls): super(Sale, ....) cls._fields['product']['required'] = True ?11:04
LordVanor is that not the way to do this?11:04
LordVanor cls.product.required = True11:04
LordVanor .. after reading https://discuss.tryton.org/t/overriding-a-module-setting-a-required-attribute-field-to-true/2756/411:04
LordVanmaybe i should just raise an error when adding a sale line11:04
LordVanwithout product11:04
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton11:04
LordVanfor me it seems to make most sense to just do cls.product.required  =True11:04
LordVanin __setup__11:04
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)11:04
cedkLordVan: the problem by adding a required is that other part of the code may rely on it not being required11:04
LordVanyes i read that in the discussion11:04
LordVanso i am unsure what to best do now11:04
LordVanwell i do have an alternative11:04
LordVani already have my own custom fields that used on the report and are read only when there is a product selected11:04
LordVanif i put them permanently read-only then the users have to select a product to get them filled in11:04
LordVanand if in addition to that i make one or more of those required ..11:04
LordVanthen i'D block them too without changing the existing fields11:04
LordVanthough wouldn'T my custom required fields potentially block other workflows too?11:04
cedkLordVan: yes but workflow are rarely triggered by process but only by user11:04
cedkLordVan: also you can just make it a warning so process will ignore them11:04
LordVantrue11:04
LordVancedk, so basically it would be better to just make one of my readonly fields required11:04
LordVan(a field that is filled out by my custom on_change_product method11:04
LordVanhttps://github.com/LordVan/tryton-modules/blob/37e7dd175ab586391108cd9648fb03d93b60c19d/rm_extra_data/sale.py#L124 <- that i mean11:04
LordVanah i just noticed something11:04
LordVanwould i need to add 'product' to the fields.depends too?11:04
cedkLordVan: well most of the time software can not fix user behavior11:04
LordVancedk, no but it can limit11:04
cedkLordVan: so if you want to enforce to fill product on sale line, I guess the best is to add a check on quotation transition11:04
LordVanyes, but then the user needs to go back to the sale line to fix it..11:04
LordVanthus "punishing" the user for not selecting a product11:04
LordVani might just like that best :D11:04
cedkLordVan: or maybe on confirm11:04
cedkyou may need to make quote without already knowning the product11:04
LordVanyes one or the other11:04
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 unsure11:04
mrichezLordVan: you should add 'product' in your depends11:04
LordVanok thanks i will do that.11:04
-!- mariomop(~quassel@181.29.189.235) has joined #tryton12:04
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton13:04
-!- thaneor1(~ldlc6@190.135.79.134) has joined #tryton13:04
-!- thaneor(~acer8@r190-135-79-134.dialup.adsl.anteldata.net.uy) has joined #tryton13:04
-!- thaneor2(~acer8@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton13:04
-!- thaneor1(~ldlc6@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton13:04
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton13:04
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton13:04
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton14:04
mrichezhi, can i use decorator @set_employee on method def create ?14:04
-!- ludo2(~Thunderbi@2001:912:1480:380::1) has joined #tryton14:04
pokolimrichez: no, the set_employee expects a list of records as second parameter but the create has a list of dictionaries14:04
mrichezpokoli: ok, it was to avoid to find another way to store this field if i could use set_employee14:04
mrichezcan we get in a field the employee who create a record ?15:04
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton15:04
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton15:04
pokolimrichez: you can use a default value of context.get('employee')15:04
mrichezpokoli: find a solution here: https://hg.tryton.org/trytond/file/tip/trytond/ir/email_.py#l7215:04
pokolimrichez: That's the user not the employee :P15:04
mrichezpokoli: indeed... :-)15:04
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)15:04
pokolimrichez: at this point if you do not want to set the employee the create_user is the only available information15:04
mrichezpokoli: yes :-)15:04
mrichezpokoli: one last question: can i set a field visible only to a group ?15:04
pokolimrichez: yes, you should create a ir.model.field rule that restricts the read usage to a group15:04
pokoliSo other users will not see15:04
pokolimrichez: IIRC you can even set a ir.rule to a field that the user is not allowed to see15:04
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)15:04
mrichezpokoli: ok, i thought to this possibility but i also find this: https://hg.tryton.org/modules/stock/file/tip/shipment.py#l261515:04
mrichezit's in a wizard, could it be also apply on a form ?15:04
pokolimrichez: this is to restrict a button on a wizard15:04
mrichezpokoli: it won't work on a field ?15:04
pokolimrichez: no for fields you need something like this: https://hg.tryton.org/modules/bank/file/d4d5f1774bd1/party.xml#l1215:04
pokoliIn this case the field is always shown but only users of the group can write to it15:04
pokolisetting perm_read to False on the rule will hide the field15:04
mrichezpokoli: ok, i used this with my yesterday discuss: https://discuss.tryton.org/t/write-access-rules-to-group-depending-on-a-field/4016/615:04
mrichezpokoli: thanks!15:04
pokolimrichez: yes, you already used the field restriction to restrict writting on a field. Same applies for reading :)15:04
mrichez:-)15:04
mrichezpokoli: working nice! thx.16:04
pokolimrichez: you're welcome. rules and fields permissions are very powerfull once you now how to fix it16:04
-!- ludo2(~Thunderbi@221.114.141.88.rev.sfr.net) has joined #tryton18:04
-!- lucascastro(~lucascast@177-185-139-161.dynamic.isotelco.net.br) has joined #tryton20:04
-!- lucascastro(~lucascast@177-185-139-90.dynamic.isotelco.net.br) has joined #tryton21:04
-!- lucascastro(~lucascast@177-185-133-243.dynamic.isotelco.net.br) has joined #tryton21:04

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