account-invoicing
account-invoicing copied to clipboard
[MIG] account_global_discount: 16.0
Needs https://github.com/OCA/server-backend/pull/221
~~Hi I'm gonna need some help migrating this module @OCA/accounting-maintainers @kirca @omar7r @pedrobaeza~~
~~Many accounting code has been refactored in v16 and so my approach here, since there's no _recompute_tax_lines nor _recompute_dynamic_lines is to do this module's calculations whenever an invoice is created or the field global_discount_ids is written following indications from Odoo's commit description.~~
~~I'm not quite getting the desired results and I was wondering if you could help me pointing if this is a viable approach or if you have any other idea. I also looked at this migration but can't seem to figure how could I do something similar here.~~
~~Thanks in advance to anyone who can help~~
In order to adapt this module to the new way of handling invoices in 16.0 I moved the creation / update of discount lines to the create and write methods of the account.move. We no longer need the recalc the bas amount for the discount lines since it is done automatically by Odoo as well as the total amounts of the invoice.
Also, for the field global_discount_item which was needed because invoice_global_discount_id wasn't properly filled, I checked and that last field is now handled correctly. I'm not removing the global_discount_item altogether for compatibility reasons with old invoices since there's no clear way to migrate it to fill invoice_global_discount_id.
I can't say too much. Maybe you have to override _inverse_tax_totals.
Hey @OCA/accounting-maintainers this should be ready for review now! :partying_face:
/ocabot migration account_global_discount
Hi @OCA/accounting-maintainers I'm having trouble migrating the tests for this module, for some reason when a global discount is added a new tax line is added too instead of updating the existing one. Does anyone have encountered a similar problem? I'd be very thankful if anyone could help me out here. Thanks in advance
@ferran-S73 not sure if this is the right place for feedback to that module. I tested everything and it looks quite good from a users perspective. But the two new lines at the bottom of the Sale Order and Invoice are not in the right place. Maybe this is already fixed? Can you reproduce this? I added an attachment.

@ferran-S73 not sure if this is the right place for feedback to that module. I tested everything and it looks quite good from a users perspective. But the two new lines at the bottom of the Sale Order and Invoice are not in the right place. Maybe this is already fixed? Can you reproduce this? I added an attachment.
Hi I'll try to reproduce with the same currency and reach you back with anything I find out @BT-skettler
@OCA/accounting-maintainers
/ocabot rebase
@rafaelbn The rebase process failed, because command git push --force Studio73 tmp-pr-1338:16.0-mig-account_global_discount failed with output:
remote: Permission to Studio73/account-invoicing.git denied to OCA-git-bot.
fatal: unable to access 'https://github.com/Studio73/account-invoicing/': The requested URL returned error: 403
Hello @ferran-S73 ,
Is this whay you except?
I have beed testing and I don't like to much this module, complicated. REAMDE in configuration should be reviewed.
Any case, testing is OK no error, just some maybe UX?
Up to you!
You can review here @BT-skettler ! 🥳
@ferran-S73 I hope I tested it correctly. On runbot I could see that the summary below the sale order line is aligned (with currency CHF). Thanks a lot for you effort!
Please, cherry-pick https://github.com/OCA/account-invoicing/pull/1531 to commit history
Please, cherry-pick #1531 to commit history
@victoralmau done
Thank you @ferran-S73 ! @victoralmau your comments are attended, are you agree? 😄
There is an error when returning an invoice, it re-applies the discount on the already discounted invoice and the amount is not the same, resulting in a partial payment on the original invoice.
Code Review: LGTM
Could you add unit tests to cover the missing use cases?
You have to look better.
There is an error when returning an invoice, it re-applies the discount on the already discounted invoice and the amount is not the same, resulting in a partial payment on the original invoice.
Fixed, now when creating a refund it will clear the global discount line and recalc it Also fixed a bug with the "apply discount" field not working correctly
FTR still blocked by its dependency https://github.com/OCA/server-backend/pull/221
Hi, I think it would be interesting to cherry-pick this #PR1448 to commit history.
@PauBForgeFlow cherry-pick added.
- [ ] Depends in https://github.com/OCA/server-backend/pull/221
Is there anything else to do? so we can unlock some migrations! Thanks!
ping @pedrobaeza
For unlocking the situation, I have extracted the migration from this PR and remove the depending change in #1724
Closing this one. When the other PR gets unlocked, you can propose the improvement in this module in a new PR.