chat.freenode.net #tryton log beginning Fri Apr 9 12:00:02 AM CEST 2021 | ||
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton | 22:31 | |
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton | 01:47 | |
-!- thaneor2(~ldlc6@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton | 02:31 | |
-!- thaneor(~acer8@r167-61-58-247.dialup.adsl.anteldata.net.uy) has joined #tryton | 02:32 | |
-!- alidipatrick(~alidipatr@154.126.121.233) has joined #tryton | 04:15 | |
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton | 04:54 | |
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton | 05:03 | |
-!- alidipatrick(~alidipatr@154.126.12.140) has joined #tryton | 05:47 | |
-!- thaneor(~ldlc6@r167-61-193-125.dialup.adsl.anteldata.net.uy) has joined #tryton | 05:50 | |
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton | 06:14 | |
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton | 06:33 | |
LordVan | hi | 06:43 |
---|---|---|
LordVan | a quick question: I want to make a selection of a product mandatory for the sale line | 06:43 |
LordVan | how would I need to go about that? | 06:43 |
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton | 07:12 | |
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton | 07:14 | |
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton | 07:15 | |
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton | 07:35 | |
mrichez | lordvan: hi, you mean a selection field ? | 07:39 |
LordVan | mrichez, https://github.com/tryton/sale/blob/2fdcc8ab33c0f32462f1b0433d1d08eafc1762a9/sale.py#L1095 | 07:42 |
mrichez | LordVan: you've to add a state 'required' for product | 07:45 |
LordVan | yes but how would I do that without changing anything else on my custom SaleLIne classe? | 07:45 |
LordVan | i mean i could just re-define it by using copy paste from the original and add required | 07:45 |
mrichez | LordVan: no, better to do a custo and add it in setup method | 07:46 |
LordVan | hm yeah i'D been thinking if i can somehow add it in a setup method or so | 07:47 |
LordVan | going to have to look if i can find an example. thanks | 07:47 |
-!- sisalp(~sisalpuse@51.sisalp.net) has joined #tryton | 08:05 | |
-!- udono(~udono@055-128-067-156.ip-addr.inexio.net) has joined #tryton | 08:05 | |
-!- Pilou(~Pilou@pdpc/supporter/active/pilou) has joined #tryton | 08:05 | |
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton | 08:05 | |
-!- thaneor(~ldlc6@r167-61-169-100.dialup.adsl.anteldata.net.uy) has joined #tryton | 08:05 | |
-!- ChanServ(ChanServ@services.) has joined #tryton | 08:05 | |
-!- yangoon(~mathiasb@p5dd08c0b.dip0.t-ipconnect.de) has joined #tryton | 08:05 | |
-!- buxy(~rhertzog@helios.freexian.com) has joined #tryton | 08:05 | |
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton | 08:05 | |
-!- Timitos(~kpreisler@2001:a61:482:eb01:762b:62ff:fe84:ed7e) has joined #tryton | 08:05 | |
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton | 08:05 | |
-!- plaes(~plaes@unaffiliated/amd) has joined #tryton | 08:05 | |
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton | 08:05 | |
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton | 08:05 | |
-!- srgdts(~srgdts@unaffiliated/srgdts) has joined #tryton | 08:05 | |
-!- lucascastro(~lucascast@177-185-133-170.dynamic.isotelco.net.br) has joined #tryton | 08:05 | |
-!- g5pw(~g5pw@mittelab/sudo/g5pw) has joined #tryton | 08:05 | |
-!- pokoli(~pokoli@unaffiliated/pokoli) has joined #tryton | 08:05 | |
-!- kwmiebach(sid16855@gateway/web/irccloud.com/x-xltmgyuuyeyvcory) has joined #tryton | 08:05 | |
-!- cryptic(~cryptic@142.196.139.17) has joined #tryton | 08:05 | |
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton | 08:06 | |
-!- jani-matti(~quassel@93-90-53-6.welcomnet.fi) has joined #tryton | 08:06 | |
-!- mniip(mniip@freenode/staff/mniip) has joined #tryton | 08:06 | |
-!- nicoe(~nicoe@2a02:578:852a:c00:224:9bff:fe6c:a1b2) has joined #tryton | 08:06 | |
-!- ajain(ajain@gateway/shell/hashbang/x-oxqnkotzoxwngjgx) has joined #tryton | 08:49 | |
-!- sharkcz(~sharkcz@19.161.broadband4.iol.cz) has joined #tryton | 08:49 | |
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton | 08:56 | |
LordVan | so I would do something like this?: in def __setup__(cls): super(Sale, ....) cls._fields['product']['required'] = True ? | 09:13 |
LordVan | or is that not the way to do this? | 09:13 |
LordVan | or cls.product.required = True | 09:15 |
LordVan | or .. after reading https://discuss.tryton.org/t/overriding-a-module-setting-a-required-attribute-field-to-true/2756/4 | 09:15 |
LordVan | maybe i should just raise an error when adding a sale line | 09:16 |
LordVan | without product | 09:16 |
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton | 09:17 | |
LordVan | for me it seems to make most sense to just do cls.product.required =True | 09:20 |
LordVan | in __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 |
cedk | LordVan: the problem by adding a required is that other part of the code may rely on it not being required | 09:23 |
LordVan | yes i read that in the discussion | 09:26 |
LordVan | so i am unsure what to best do now | 09:26 |
LordVan | well i do have an alternative | 09:26 |
LordVan | i already have my own custom fields that used on the report and are read only when there is a product selected | 09:27 |
LordVan | if i put them permanently read-only then the users have to select a product to get them filled in | 09:27 |
LordVan | and if in addition to that i make one or more of those required .. | 09:27 |
LordVan | then i'D block them too without changing the existing fields | 09:28 |
LordVan | though wouldn'T my custom required fields potentially block other workflows too? | 09:28 |
cedk | LordVan: yes but workflow are rarely triggered by process but only by user | 09:40 |
cedk | LordVan: also you can just make it a warning so process will ignore them | 09:41 |
LordVan | true | 09:41 |
LordVan | cedk, so basically it would be better to just make one of my readonly fields required | 09:41 |
LordVan | (a field that is filled out by my custom on_change_product method | 09:42 |
LordVan | https://github.com/LordVan/tryton-modules/blob/37e7dd175ab586391108cd9648fb03d93b60c19d/rm_extra_data/sale.py#L124 <- that i mean | 09:43 |
LordVan | ah i just noticed something | 09:43 |
LordVan | would i need to add 'product' to the fields.depends too? | 09:43 |
cedk | LordVan: well most of the time software can not fix user behavior | 09:43 |
LordVan | cedk, no but it can limit | 09:43 |
cedk | LordVan: so if you want to enforce to fill product on sale line, I guess the best is to add a check on quotation transition | 09:44 |
LordVan | yes, but then the user needs to go back to the sale line to fix it.. | 09:44 |
LordVan | thus "punishing" the user for not selecting a product | 09:45 |
LordVan | i might just like that best :D | 09:45 |
cedk | LordVan: or maybe on confirm | 09:47 |
cedk | you may need to make quote without already knowning the product | 09:47 |
LordVan | yes one or the other | 09:48 |
LordVan | cedk, 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 unsure | 09:48 |
mrichez | LordVan: you should add 'product' in your depends | 09:54 |
LordVan | ok thanks i will do that. | 09:55 |
-!- mariomop(~quassel@181.29.189.235) has joined #tryton | 10:52 | |
-!- LordVan(~LordVAn@gentoo/developer/LordVan) has joined #tryton | 11:01 | |
-!- thaneor1(~ldlc6@190.135.79.134) has joined #tryton | 11:03 | |
-!- thaneor(~acer8@r190-135-79-134.dialup.adsl.anteldata.net.uy) has joined #tryton | 11:19 | |
-!- thaneor2(~acer8@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton | 11:46 | |
-!- thaneor1(~ldlc6@r167-61-145-211.dialup.adsl.anteldata.net.uy) has joined #tryton | 11:47 | |
-!- rpit(~rpit@p200300c88f0235001c42215a17f33f55.dip0.t-ipconnect.de) has joined #tryton | 11:56 | |
-!- ludo2(~Thunderbi@193.33.57.196) has joined #tryton | 11:59 | |
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton | 12:25 | |
mrichez | hi, can i use decorator @set_employee on method def create ? | 12:50 |
-!- ludo2(~Thunderbi@2001:912:1480:380::1) has joined #tryton | 12:50 | |
pokoli | mrichez: no, the set_employee expects a list of records as second parameter but the create has a list of dictionaries | 12:53 |
mrichez | pokoli: ok, it was to avoid to find another way to store this field if i could use set_employee | 12:55 |
mrichez | can we get in a field the employee who create a record ? | 13:00 |
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton | 13:16 | |
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton | 13:22 | |
pokoli | mrichez: you can use a default value of context.get('employee') | 13:25 |
mrichez | pokoli: find a solution here: https://hg.tryton.org/trytond/file/tip/trytond/ir/email_.py#l72 | 13:26 |
pokoli | mrichez: That's the user not the employee :P | 13:27 |
mrichez | pokoli: indeed... :-) | 13:28 |
mrichez | pokoli: 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 |
pokoli | mrichez: at this point if you do not want to set the employee the create_user is the only available information | 13:39 |
mrichez | pokoli: yes :-) | 13:40 |
mrichez | pokoli: one last question: can i set a field visible only to a group ? | 13:47 |
pokoli | mrichez: yes, you should create a ir.model.field rule that restricts the read usage to a group | 13:49 |
pokoli | So other users will not see | 13:49 |
pokoli | mrichez: IIRC you can even set a ir.rule to a field that the user is not allowed to see | 13:50 |
pokoli | mrichez: 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 |
mrichez | pokoli: ok, i thought to this possibility but i also find this: https://hg.tryton.org/modules/stock/file/tip/shipment.py#l2615 | 13:52 |
mrichez | it's in a wizard, could it be also apply on a form ? | 13:52 |
pokoli | mrichez: this is to restrict a button on a wizard | 13:53 |
mrichez | pokoli: it won't work on a field ? | 13:54 |
pokoli | mrichez: no for fields you need something like this: https://hg.tryton.org/modules/bank/file/d4d5f1774bd1/party.xml#l12 | 13:54 |
pokoli | In this case the field is always shown but only users of the group can write to it | 13:54 |
pokoli | setting perm_read to False on the rule will hide the field | 13:54 |
mrichez | pokoli: ok, i used this with my yesterday discuss: https://discuss.tryton.org/t/write-access-rules-to-group-depending-on-a-field/4016/6 | 13:55 |
mrichez | pokoli: thanks! | 13:56 |
pokoli | mrichez: yes, you already used the field restriction to restrict writting on a field. Same applies for reading :) | 13:56 |
mrichez | :-) | 13:56 |
mrichez | pokoli: working nice! thx. | 14:04 |
pokoli | mrichez: you're welcome. rules and fields permissions are very powerfull once you now how to fix it | 14:21 |
-!- ludo2(~Thunderbi@221.114.141.88.rev.sfr.net) has joined #tryton | 16:16 | |
-!- lucascastro(~lucascast@177-185-139-161.dynamic.isotelco.net.br) has joined #tryton | 18:46 | |
-!- lucascastro(~lucascast@177-185-139-90.dynamic.isotelco.net.br) has joined #tryton | 19:45 | |
-!- lucascastro(~lucascast@177-185-133-243.dynamic.isotelco.net.br) has joined #tryton | 19:53 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!