[FIX]partner_invoicing_mode: Invalid partner_invoice_id key to group sales. Fix #1747 #1749
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm not sure about this, but I already explained it in issue #1747.
It seems there is new code added that wasn't in v15. In my opinion, it's a mistake to use the key partner_invoice_id for grouping. Odoo doesn't use it to compare against the sales order but against the values of the dictionary that will generate the invoice.
https://github.com/odoo/odoo/blob/56946ff1a99a1f02f2ec708161a754e22c25fe80/addons/sale/models/sale_order.py#L1155
That is, it is always evaluated as None. In this dictionary, Odoo assigns the field partner_id the value of partner_invoice_id from the order:
https://github.com/odoo/odoo/blob/56946ff1a99a1f02f2ec708161a754e22c25fe80/addons/sale/models/sale_order.py#L1003
Therefore, if we want to group by invoice address, we should use the key partner_id, since this key is in the invoice value dictionary and already contains the value of the order's partner_invoice_id.