Issue 11685

Title
Orders no more grouped when many sales processed at once
Priority
bug
Status
testing
Nosy list
acaubet, ced, pokoli, reviewbot
Assigned to
pokoli
Keywords
review

Created on 2022-09-05.14:05:35 by acaubet, last changed 1 week ago by reviewbot.

Messages

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2022-09-23.20:04:36

Here is review435841003 that fixes both modules

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-06.10:11:18

This should also happen with the shipment grouping.
So I agree with @pokoli, that the first invoice or shipment instantiated because we did not find an existing one must be saved directly. Of course this will penalize the optimization of issue10801 but only when there is a grouping method (and it was any way reduced by the module which does a search for each sale).

Author: [hidden] (acaubet)
Date: 2022-09-05.16:20:21

Could you describe "it generates me wrong lines and total values on the invoices" ??

Don't know why but It duplicates invoice lines many times, causing wrong totals, maybe there is some loop happening with one of my custom modules, I prefer not to focus on this as it's a collateral error of a "trick".

Maybe a solution to avoid the grouping error is to save the first invoice in case None is found, so for the next runs the invoices will be already grouped

Seams reasonable.

Altought your case only is reproducible when deleting I image the behaviour will be also wrong when processing two sales that generate a grouped invoice in a single call as the first invoice won't be saved, so the second sale will create another one.

I thought the same but I ignored as it's not a user can do and thought that if we find a solution this should also work for your scenario.

Author: [hidden] (pokoli) Tryton committer Tryton translator
Date: 2022-09-05.15:53:55

Could you describe "it generates me wrong lines and total values on the invoices" ??

Maybe a solution to avoid the grouping error is to save the first invoice in case None is found, so for the next runs the invoices will be already grouped. Altought your case only is reproducible when deleting I image the behaviour will be also wrong when processing two sales that generate a grouped invoice in a single call as the first invoice won't be saved, so the second sale will create another one.

I do not think update_taxes should be called as its already called for each created invoice. If there is some issues on grouping we just need to take care to return any invoice that will be modified which should already be the case.

Author: [hidden] (acaubet)
Date: 2022-09-05.15:43:04

The trick I mention in previous comment don't work either, it generates me wrong lines and total values on the invoices.
So we need a solution, for now the unique solution that work is reverting the invoice save() and update_taxes() to before the change.

Author: [hidden] (acaubet)
Date: 2022-09-05.15:13:24

The normal workflow works well, so you can create a sale and the generated invoice will be grouped.
But If you try to delete all draft invoices so Tryton can recompute the grouping, it fails (generating the invoices without any grouping), because he can not find any invoice in draft.
This happens since rev/b556db5559b3. As the invoices are not saved in each invoice creation.
The trick for now is to delete all invoices except 1 invoice, so Tryton can find one to group for.
Don't know if this is the desired behaviour, because previously you can be lazzy by deleting all invoices (maybe having parties having grouping and ones that don't) and forget about grouping, after processing you can proceed with the result. But now you need to search through the list selecting the ones you want to delete to regroup.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2022-09-05.15:01:14

Please describe what means "not working".

Author: [hidden] (acaubet)
Date: 2022-09-05.14:05:33

No tested yet on 6.0 or 6.4, but with 6.2 the grouping invoices is not working. It was working weeks ago.
I can not see any changes on sale_invoice_grouping impacting on the log. So I suspect that the issue was from another module.
Any idea?

History
Date User Action Args
2022-09-26 13:31:51reviewbotsetmessages: + msg78337
nosy: + reviewbot
2022-09-23 23:37:40cedsetkeyword: + review
reviews: 435841003
2022-09-23 20:04:36pokolisetassignedto: pokoli
messages: + msg78288
status: chatting -> testing
2022-09-06 10:29:12pokolisettitle: Orders no more grouped when may sales processed at once -> Orders no more grouped when many sales processed at once
2022-09-06 10:11:20cedsetcomponent: + sale_invoice_grouping, sale_shipment_grouping
messages: + msg77887
title: Can not delete all invoices to group -> Orders no more grouped when may sales processed at once
2022-09-05 16:20:21acaubetsetmessages: + msg77886
2022-09-05 15:53:55pokolisetmessages: + msg77885
nosy: + pokoli
status: need-eg -> chatting
2022-09-05 15:43:04acaubetsetmessages: + msg77884
2022-09-05 15:13:24acaubetsetmessages: + msg77883
title: Can not group invoices on 6.2 -> Can not delete all invoices to group
2022-09-05 15:01:14cedsetmessages: + msg77882
nosy: + ced
status: chatting -> need-eg
2022-09-05 14:05:35acaubetcreate