IRC logs of #tryton for Monday, 2022-09-19

irc.libera.chat #tryton log beginning Mon Sep 19 12:00:01 AM CEST 2022
-!- mrichez(~Maxime@2a02:a03f:c2e8:f900:ed77:85ea:af2b:ba6e) has joined #tryton05:00
-!- tbruyere(~Thunderbi@82.187-182-91.adsl-dyn.isp.belgacom.be) has joined #tryton05:23
-!- springwurm(~springwur@5.104.149.54) has joined #tryton05:35
-!- rpit(~rpit@p200300c88f07c3004b32d530ec5a8be7.dip0.t-ipconnect.de) has joined #tryton06:19
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton06:35
-!- ChanServ changed mode/#tryton -> +o cedk 06:35
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton07:16
-!- acaubet1(~Thunderbi@194.224.31.235) has joined #tryton07:22
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton07:24
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton07:27
-!- nicoe(~nicoe@2a02:578:852a:c00:18c2:1aff:fef9:2b7f) has joined #tryton07:47
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton10:26
-!- nicoe(~nicoe@2a02:578:852a:c00:18c2:1aff:fef9:2b7f) has joined #tryton12:02
-!- springwurm(~springwur@5.104.149.54) has joined #tryton12:12
mrichezhi, i try to remove duplicate objects from a list using a set. I define method __eq__ and __hash__ but got an error about not found attributes (Fault: '.. ' Object has no attribute ..) Any idea ?12:56
cedkmrichez: which attribute?13:25
mrichezcedk: all attributes, i did a debug, __hash__ is called many times and working and then it seems self has no more attributes . So i add a getattr(...) but another error: KeyError: Pool().get('quality.task')(**{})13:28
mrichezcedk: i'm adding some lines of a custom model when shipment is processed by sale... as process  is called many times i try to avoid duplicates 13:29
mrichezcedk: i can't delete already created lines, so i get existing lines with new lines into a set to remove duplicates ...13:30
mrichezcedk: don't if there's a best idea to do such thing ? 13:31
cedkmrichez: which attribute is the error telling?13:33
mrichezcedk: it's a custom model, first error attribute is 'origin'13:34
cedkmrichez: hash is only using id13:35
mrichezcedk: here's a part of my code: https://pastebin.com/MAPKqf6p13:36
cedkmrichez: I'm not sure it is a good idea to modify the __eq__ and __hash__13:38
cedkbut anyway they fail on unsaved instance for which those values have not been set13:39
mrichezcedk: indeed, but how to prevent creating duplicate objects ?13:39
cedkmrichez: add a unique constraint13:43
cedkor write code such that it does not happen13:43
mrichezcedk: ok that's why it thougth about hash ;-) I'll try something else. Thanks13:44
cedkmrichez: if it is only about record to create, you could use just dict of values13:52
cedkbut I think it is better if by design, you do not have to remove duplicates because you do not create duplicates13:53
mrichezcedk: it's working doing a Model.search with key values (but called in a loop) so not very efficient13:54
cedkmrichez: for me it is probably a design issue13:59
mrichezcedk: i think so... here's my code (too many loops): https://pastebin.com/cJQ1hj1R14:01
mrichezcedk: it's creating quality tasks (with origin = shipment_out) defined on party or on product when processing shipment on sale14:02
cedkmrichez: I guess you could get all the existing tasks linked to the shipment14:05
cedkmrichez: and construct a set of quality_task_dictionaries to compare against before creating a new task14:06
mrichezcedk: but to compare, is not hash necessary ?14:07
cedkmrichez: you can probably use tuple(sorted(d.items())14:28
cedkor even better frozenset(d.items())14:31
mrichezcedk: thanks :-)14:39
-!- rpit(~rpit@p200300c88f07c3004b32d530ec5a8be7.dip0.t-ipconnect.de) has joined #tryton15:10
nicoecedk: since https://hg.tryton.org/tryton/rev/30f71de3e567 an on_change is triggered each time a user clicks on a date but also when he changes the month, maybe we shouldn't emit 'date-changed' in cal_popup_changed15:53
cedknicoe: for me it is the good behavior15:57
nicoeWhat is "it" ?15:58
cedknicoe: the current one15:58
nicoecedk: OK thanks15:59
cedkif the date is changed, the on_change must be called15:59
nicoeThe problem is when people go back far in the time there is a dozen or more of useless on_change calls16:00
nicoeAnd since the date-changed signal is emitted anyway once the popup disappear, I thought that we could remove this signal emission16:01
cedkI think it is good that the form is coherent when the date is changed16:04
cedkI'm not sure we manage all the cases of the popup been closed16:04
cedkbut probably we should not emit date-changed on popup hide16:07
cedkand neither when value is set by property16:10
nicoeI tried to close the popup with a focus-out, esc and closing the window ; the all send the signal but using Esc raise a warning16:11
cedknicoe: anyway for me user must see coherent data16:12
nicoes/the/they16:12
cedklike when editing a line on sale, the amount are changed directly and not only after the popup close16:12
nicoeI don't see the problem with not setting the entry and waiting for the popup to close but anyway …16:13
cedknicoe: it is an annoying and bridling behavior because user must close/open popup to see the result when selecting a date16:19
nicoeYes I understand your point of view16:20
cedkthe problem is the poor feature of Gtk.Calendar that does not allow to navigate quicker and without setting a day16:20
cedkone possibility will be to not set the date on day-selected but only on day-selected-double-click16:26
cedkbut I'm affray that user will not understand16:26
nicoeI don't know if the entre field is empty then the user will understand that unless he doublecliks then the entry is not filled16:54
nicoeBut it won't fulfill the need of the use case you explained for the sale16:54
cedkfor me it is really a problem from Gtk.Calendar, in browser you can navigate in the calendar without changing the selected day16:59
nicoeMaybe we should find a common ground then17:06
cedkwell I guess user who need to browse a lot of months, will quickly fill the date with the entry17:08
-!- tbruyere(~Thunderbi@82.187-182-91.adsl-dyn.isp.belgacom.be) has joined #tryton19:41

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