Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] account_global_discount: Migration to 17.0 #1687

Open
wants to merge 41 commits into
base: 17.0
Choose a base branch
from

Conversation

miguel-S73
Copy link
Contributor

@miguel-S73 miguel-S73 commented Mar 18, 2024

Standard migration to 17.0

Depends:

@pedrobaeza
Copy link
Member

/ocabot migration account_global_discount

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone Jun 17, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request Jun 17, 2024
46 tasks
@miguel-S73 miguel-S73 force-pushed the 17.0-mig-account_global_discount branch 2 times, most recently from 20b1a28 to d6bd7b3 Compare August 14, 2024 16:11
@miguel-S73
Copy link
Contributor Author

@pedrobaeza I apply same change that OCA/server-backend#275 (comment)

@pedrobaeza pedrobaeza changed the title [MIG] account_global_discount: 17.0 [17.0][MIG] account_global_discount: Migration to 17.0 Aug 14, 2024
@pedrobaeza
Copy link
Member

OK, some reviewers should validate this.

@ferran-S73 ferran-S73 force-pushed the 17.0-mig-account_global_discount branch from d6bd7b3 to ad6b296 Compare September 27, 2024 06:36
@miguel-S73 miguel-S73 force-pushed the 17.0-mig-account_global_discount branch 3 times, most recently from ca1c359 to 77a9b48 Compare November 6, 2024 14:34
@miguel-S73
Copy link
Contributor Author

@pedrobaeza all check are green.
We've thoroughly tested this module with multiple clients, and it performs reliably.

@pedrobaeza
Copy link
Member

Great. Now some reviewers are needed. We don't need this module for now.

@miguel-S73
Copy link
Contributor Author

@etobella @gurneyalex @grindtildeath
Could one of you please review my changes?

We've thoroughly tested this module with multiple clients, and it performs reliably.

@Abimael1321
Copy link

Functionally reviewed. LGTM!

@miguel-S73
Copy link
Contributor Author

I’d like to thank @Abimael1321 for testing this PR and confirming that it works as expected.
With this validation, I believe the PR is ready to be merged.
@pedrobaeza, Please let me know if there’s anything else needed. Thanks!

@pedrobaeza
Copy link
Member

2 reviewers are needed, and one coming from a PSC: https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#review

@AinohaBH
Copy link

Functional: LGTM!

Copy link

@dalonsod dalonsod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Most of them look for commit noise reduction, and it seems that there are two errors in views.

@@ -87,7 +88,7 @@ def _set_global_discounts_by_tax(self):
# incorrect data in discounts
_self = self.filtered("global_discount_ids")
for inv_line in _self.invoice_line_ids.filtered(
lambda l: l.display_type not in ["line_section", "line_note"]
lambda line: line.display_type not in ["line_section", "line_note"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be removed, as unnecessary IMO (in this commit should only be added changes that are required, not cosmetic ones that make more difficult search for required changes related to commit goal according its description)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. I made this change because a red flag was triggered in the pre-commit test.

@@ -161,8 +162,9 @@ def _recompute_global_discount_lines(self):
{
"invoice_global_discount_id": discount.id,
"move_id": self.id,
"name": "%s - %s"
% (discount.name, ", ".join(discount.tax_ids.mapped("name"))),
"name": "{} - {}".format(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

Comment on lines +199 to +201
for discount in move_discounts:
if discount.company_id == move.company_id:
discounts |= discount
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For company filtering filtered expressions, as old code does, could be used instead another for statement here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the internal process of the "filtered" function, a "browse" is performed. In my opinion, this approach is more efficient than using the "filtered" function itself.

Comment on lines +323 to +324
# TODO: To be removed on future versions if invoice_global_discount_id
# is properly filled Provided for compatibility in stable branch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange, shouldn't be placed this change in previous commit, if it was a pre-commit execution consequence?

Comment on lines +371 to +373
domain=(
"[('account_type', 'not in', ['asset_receivable', 'liability_payable'])]"
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

@@ -380,7 +398,7 @@ def test_10_customer_invoice_currency(self):
),
)
tax_line = invoice.line_ids.filtered(
lambda l: l.tax_line_id and not l.invoice_global_discount_id
lambda line: line.tax_line_id and not line.invoice_global_discount_id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

Comment on lines +434 to +438
lambda line: (
line.tax_ids
and not line.invoice_global_discount_id
and not line.product_id
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

@@ -426,7 +448,7 @@ def test_10_customer_invoice_currency(self):
),
)
tax_line = invoice.line_ids.filtered(
lambda l: l.tax_line_id and not l.invoice_global_discount_id
lambda line: line.tax_line_id and not line.invoice_global_discount_id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

@@ -65,7 +66,7 @@
name="invoice_global_discount_ids"
nolabel="1"
readonly="1"
attrs="{'invisible': [('global_discount_ids', '=', [])]}"
invisible="global_discount_ids"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The equivalent expression should be the opposite one, if I'm not wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re absolutely right, thank you for pointing this out. I’ve fixed it now

@@ -100,7 +101,7 @@
name="invoice_global_discount_ids"
nolabel="1"
readonly="1"
attrs="{'invisible': [('global_discount_ids_readonly', '=', [])]}"
invisible="global_discount_ids_readonly"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

chienandalu and others added 7 commits January 8, 2025 12:23
…ine + Discounts in invoice report

[IMP] account_global_discount: Discounts in invoice report

Give discounts info in the invoice report.

[FIX] account_global_discount: link line taxes to discount move line
- We need to take into account invoice lines with multiple taxes, so the link should
  be m2m.
- Migration scripts for preserving the best information on existing installations.
- Tests for checking new conditions.
- Perform sanity check for not ending in an incompatible situation.
- Some refactor done on onchanges for avoiding duplicating operations.
- Adjust UI for not allowing to edit computed invoice global discounts.
- Standard procedure
- Make test more resilient
Replaced by more explicit `_convert` method.
For reducing diff, we rename the method and call it record per record.

Fixes OCA#788
oca-transbot and others added 28 commits January 8, 2025 12:23
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: account-invoicing-13.0/account-invoicing-13.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-13-0/account-invoicing-13-0-account_global_discount/
Currently translated at 100.0% (34 of 34 strings)

Translation: account-invoicing-13.0/account-invoicing-13.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-13-0/account-invoicing-13-0-account_global_discount/es/
When we set the global discount on the create method we must ensure that
the move lines are properly recomputed
Users will need a specific group to set global discounts so it's easier
to decide who's allowed to apply them.

[UPD] Update account_global_discount.pot
…ulti-lines from invoices when global discount is empty
…ove lines

Previously, no taxes were populated as base taxes for global discount
move lines, which means that the tax reports were incorrect.

The global discount lines + move lines has been injected other way for
avoiding inconsistencies, and the rest of the features have been adapted
according this.

A migration script is provided as well for filling taxes in existing
global discount move lines.

[UPD] Update account_global_discount.pot

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: account-invoicing-13.0/account-invoicing-13.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-13-0/account-invoicing-13-0-account_global_discount/
For recomputing the global discounts, now we need to call another method.

TT30077
- Signed amount error in supplier invoices
- computed fields must be stored because the other standard computed fields in same method are
- Filtering global discount in on_change by invoice's company
- Partner in global discount move line
- When writing Odoo doesn't autocomplete amount_currency and it could fail with constraint
Currently translated at 100.0% (36 of 36 strings)

Translation: account-invoicing-14.0/account-invoicing-14.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_global_discount/it/
odoo/odoo@c9d5f06
has changed the number of arguments on the method `_recompute_tax_lines`,
so we need to adapt the overrides to such change.
Currently translated at 100.0% (35 of 35 strings)

Translation: account-invoicing-14.0/account-invoicing-14.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-14-0/account-invoicing-14-0-account_global_discount/pt/
In a foreign currency invoice the amounts (amount_total,
amount_untaxed) are expressed in the `invoice` currency while the
accounting entry lines are expressed in the `company` currency.

The base_before_global_discounts has to be expressed in the invoice
currency as well in such invoices because the discounts need to be
computed in the same currency as the other amounts.

Also set the invoice currency_id on the tax line so that it doesn't
default to the company currency, and convert the discount journal entry
amount to the company currnecy.
- Depending on the installed set of modules, the company currency may
  be USD or EUR. If the second case, these tests will fail, so we make
  sure that the company currency is USD for our tests, doing the change
  by SQL, as there's a Python constraint that prevents it.

Not needed in v17 due to: odoo/odoo#107113.
Currently translated at 100.0% (36 of 36 strings)

Translation: account-invoicing-16.0/account-invoicing-16.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_global_discount/it/
Currently translated at 100.0% (36 of 36 strings)

Translation: account-invoicing-16.0/account-invoicing-16.0-account_global_discount
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_global_discount/it/
@miguel-S73 miguel-S73 force-pushed the 17.0-mig-account_global_discount branch from 77a9b48 to ab1825f Compare January 8, 2025 11:24
@miguel-S73
Copy link
Contributor Author

The remaining test failures are caused by another module, but there’s an active PR that addresses this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.