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 #tryton | 05:00 | |
-!- tbruyere(~Thunderbi@82.187-182-91.adsl-dyn.isp.belgacom.be) has joined #tryton | 05:23 | |
-!- springwurm(~springwur@5.104.149.54) has joined #tryton | 05:35 | |
-!- rpit(~rpit@p200300c88f07c3004b32d530ec5a8be7.dip0.t-ipconnect.de) has joined #tryton | 06:19 | |
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton | 06:35 | |
-!- ChanServ changed mode/#tryton -> +o cedk | 06:35 | |
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton | 07:16 | |
-!- acaubet1(~Thunderbi@194.224.31.235) has joined #tryton | 07:22 | |
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton | 07:24 | |
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton | 07:27 | |
-!- nicoe(~nicoe@2a02:578:852a:c00:18c2:1aff:fef9:2b7f) has joined #tryton | 07:47 | |
-!- acaubet(~Thunderbi@194.224.31.235) has joined #tryton | 10:26 | |
-!- nicoe(~nicoe@2a02:578:852a:c00:18c2:1aff:fef9:2b7f) has joined #tryton | 12:02 | |
-!- springwurm(~springwur@5.104.149.54) has joined #tryton | 12:12 | |
mrichez | hi, 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 |
---|---|---|
cedk | mrichez: which attribute? | 13:25 |
mrichez | cedk: 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 |
mrichez | cedk: 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 |
mrichez | cedk: i can't delete already created lines, so i get existing lines with new lines into a set to remove duplicates ... | 13:30 |
mrichez | cedk: don't if there's a best idea to do such thing ? | 13:31 |
cedk | mrichez: which attribute is the error telling? | 13:33 |
mrichez | cedk: it's a custom model, first error attribute is 'origin' | 13:34 |
cedk | mrichez: hash is only using id | 13:35 |
mrichez | cedk: here's a part of my code: https://pastebin.com/MAPKqf6p | 13:36 |
cedk | mrichez: I'm not sure it is a good idea to modify the __eq__ and __hash__ | 13:38 |
cedk | but anyway they fail on unsaved instance for which those values have not been set | 13:39 |
mrichez | cedk: indeed, but how to prevent creating duplicate objects ? | 13:39 |
cedk | mrichez: add a unique constraint | 13:43 |
cedk | or write code such that it does not happen | 13:43 |
mrichez | cedk: ok that's why it thougth about hash ;-) I'll try something else. Thanks | 13:44 |
cedk | mrichez: if it is only about record to create, you could use just dict of values | 13:52 |
cedk | but I think it is better if by design, you do not have to remove duplicates because you do not create duplicates | 13:53 |
mrichez | cedk: it's working doing a Model.search with key values (but called in a loop) so not very efficient | 13:54 |
cedk | mrichez: for me it is probably a design issue | 13:59 |
mrichez | cedk: i think so... here's my code (too many loops): https://pastebin.com/cJQ1hj1R | 14:01 |
mrichez | cedk: it's creating quality tasks (with origin = shipment_out) defined on party or on product when processing shipment on sale | 14:02 |
cedk | mrichez: I guess you could get all the existing tasks linked to the shipment | 14:05 |
cedk | mrichez: and construct a set of quality_task_dictionaries to compare against before creating a new task | 14:06 |
mrichez | cedk: but to compare, is not hash necessary ? | 14:07 |
cedk | mrichez: you can probably use tuple(sorted(d.items()) | 14:28 |
cedk | or even better frozenset(d.items()) | 14:31 |
mrichez | cedk: thanks :-) | 14:39 |
-!- rpit(~rpit@p200300c88f07c3004b32d530ec5a8be7.dip0.t-ipconnect.de) has joined #tryton | 15:10 | |
nicoe | cedk: 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_changed | 15:53 |
cedk | nicoe: for me it is the good behavior | 15:57 |
nicoe | What is "it" ? | 15:58 |
cedk | nicoe: the current one | 15:58 |
nicoe | cedk: OK thanks | 15:59 |
cedk | if the date is changed, the on_change must be called | 15:59 |
nicoe | The problem is when people go back far in the time there is a dozen or more of useless on_change calls | 16:00 |
nicoe | And since the date-changed signal is emitted anyway once the popup disappear, I thought that we could remove this signal emission | 16:01 |
cedk | I think it is good that the form is coherent when the date is changed | 16:04 |
cedk | I'm not sure we manage all the cases of the popup been closed | 16:04 |
cedk | but probably we should not emit date-changed on popup hide | 16:07 |
cedk | and neither when value is set by property | 16:10 |
nicoe | I tried to close the popup with a focus-out, esc and closing the window ; the all send the signal but using Esc raise a warning | 16:11 |
cedk | nicoe: anyway for me user must see coherent data | 16:12 |
nicoe | s/the/they | 16:12 |
cedk | like when editing a line on sale, the amount are changed directly and not only after the popup close | 16:12 |
nicoe | I don't see the problem with not setting the entry and waiting for the popup to close but anyway … | 16:13 |
cedk | nicoe: it is an annoying and bridling behavior because user must close/open popup to see the result when selecting a date | 16:19 |
nicoe | Yes I understand your point of view | 16:20 |
cedk | the problem is the poor feature of Gtk.Calendar that does not allow to navigate quicker and without setting a day | 16:20 |
cedk | one possibility will be to not set the date on day-selected but only on day-selected-double-click | 16:26 |
cedk | but I'm affray that user will not understand | 16:26 |
nicoe | I don't know if the entre field is empty then the user will understand that unless he doublecliks then the entry is not filled | 16:54 |
nicoe | But it won't fulfill the need of the use case you explained for the sale | 16:54 |
cedk | for me it is really a problem from Gtk.Calendar, in browser you can navigate in the calendar without changing the selected day | 16:59 |
nicoe | Maybe we should find a common ground then | 17:06 |
cedk | well I guess user who need to browse a lot of months, will quickly fill the date with the entry | 17:08 |
-!- tbruyere(~Thunderbi@82.187-182-91.adsl-dyn.isp.belgacom.be) has joined #tryton | 19:41 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!