account-invoicing icon indicating copy to clipboard operation
account-invoicing copied to clipboard

[MIG] account_global_discount: 16.0

Open ferran-S73 opened this issue 2 years ago • 21 comments

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.

ferran-S73 avatar Jan 04 '23 16:01 ferran-S73

I can't say too much. Maybe you have to override _inverse_tax_totals.

pedrobaeza avatar Jan 04 '23 18:01 pedrobaeza

Hey @OCA/accounting-maintainers this should be ready for review now! :partying_face:

ferran-S73 avatar Jan 19 '23 08:01 ferran-S73

/ocabot migration account_global_discount

tafaRU avatar Feb 10 '23 08:02 tafaRU

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 avatar Apr 21 '23 06:04 ferran-S73

@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. Screenshot 2023-04-25 at 14 01 45

BT-srieskamp avatar Apr 25 '23 12:04 BT-srieskamp

@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. Screenshot 2023-04-25 at 14 01 45

Hi I'll try to reproduce with the same currency and reach you back with anything I find out @BT-skettler

ferran-S73 avatar Apr 25 '23 13:04 ferran-S73

@OCA/accounting-maintainers

ferran-S73 avatar Jun 28 '23 15:06 ferran-S73

/ocabot rebase

rafaelbn avatar Aug 03 '23 20:08 rafaelbn

@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

OCA-git-bot avatar Aug 03 '23 20:08 OCA-git-bot

Hello @ferran-S73 ,

Is this whay you except?

imagen

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!

rafaelbn avatar Aug 03 '23 21:08 rafaelbn

You can review here @BT-skettler ! 🥳

rafaelbn avatar Aug 03 '23 21:08 rafaelbn

@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!

BT-srieskamp avatar Aug 08 '23 12:08 BT-srieskamp

Please, cherry-pick https://github.com/OCA/account-invoicing/pull/1531 to commit history

victoralmau avatar Aug 17 '23 06:08 victoralmau

Please, cherry-pick #1531 to commit history

@victoralmau done

ferran-S73 avatar Aug 17 '23 06:08 ferran-S73

Thank you @ferran-S73 ! @victoralmau your comments are attended, are you agree? 😄

rafaelbn avatar Sep 01 '23 13:09 rafaelbn

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. image

linuxivan avatar Oct 10 '23 15:10 linuxivan

Code Review: LGTM

Could you add unit tests to cover the missing use cases?

You have to look better.

linuxivan avatar Oct 20 '23 09:10 linuxivan

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

hildickethan avatar Nov 10 '23 09:11 hildickethan

FTR still blocked by its dependency https://github.com/OCA/server-backend/pull/221

simahawk avatar Nov 23 '23 12:11 simahawk

Hi, I think it would be interesting to cherry-pick this #PR1448 to commit history.

PauBForgeFlow avatar Jan 03 '24 08:01 PauBForgeFlow

@PauBForgeFlow cherry-pick added.

miguel-S73 avatar Mar 15 '24 12:03 miguel-S73

  • [ ] Depends in https://github.com/OCA/server-backend/pull/221

rafaelbn avatar Apr 01 '24 15:04 rafaelbn

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.

pedrobaeza avatar May 17 '24 07:05 pedrobaeza