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

[16.0][MIG] sale_timesheet_line_exclude #569

Merged
merged 15 commits into from
Aug 8, 2023

Conversation

CRogos
Copy link
Contributor

@CRogos CRogos commented Feb 16, 2023

Migration using oca-port tool

@CRogos CRogos force-pushed the 16.0-mig-sale_timesheet_line_exclude branch from ed03ba1 to ccc2313 Compare February 16, 2023 08:10
@CRogos CRogos mentioned this pull request Feb 16, 2023
16 tasks
@CRogos CRogos force-pushed the 16.0-mig-sale_timesheet_line_exclude branch 4 times, most recently from 3b68ebb to 71e5200 Compare February 16, 2023 10:26
@CRogos CRogos marked this pull request as ready for review February 16, 2023 10:31
@CRogos
Copy link
Contributor Author

CRogos commented Feb 16, 2023

@rafaelbn are the codecov steps working properly?

@rafaelbn
Copy link
Member

/ocabor migration sale_timesheet_line_exclude

@nimarosa
Copy link

/ocabot migration sale_timesheet_line_exclude

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Feb 20, 2023
@CRogos CRogos marked this pull request as draft May 8, 2023 15:00
@CRogos CRogos marked this pull request as ready for review May 8, 2023 15:00
@CRogos CRogos closed this May 8, 2023
@CRogos CRogos reopened this May 8, 2023
@CRogos CRogos force-pushed the 16.0-mig-sale_timesheet_line_exclude branch from 71e5200 to e575ace Compare June 19, 2023 07:21
Copy link

@MohamedOsman7 MohamedOsman7 left a comment

Choose a reason for hiding this comment

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

Functional changes & code LGTM

Copy link

@Yadier-Tecnativa Yadier-Tecnativa left a comment

Choose a reason for hiding this comment

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

LGTM

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

1 similar comment
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@@ -5,6 +5,5 @@
from odoo.addons.sale_timesheet.tests import test_sale_service
from odoo.addons.sale_timesheet.tests import test_project_billing
from odoo.addons.sale_timesheet.tests import test_reinvoice
from odoo.addons.sale_timesheet.tests import test_reporting
Copy link
Member

Choose a reason for hiding this comment

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

Why removing these tests?

And please use local imports:

from . import ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added test_project_profitability, but I am unsure what you mean with use local imports.

Shell I create a new test file for the derived sale_timesheet tests?

test_reinvoice.py

from odoo.addons.sale_timesheet.tests.test_reinvoice import TestReInvoice

@tagged('-at_install', 'post_install')
class TestLineExcludeReInvoice(TestReInvoice):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedrobaeza could you give me a hint how to improve the imports?

Copy link
Member

Choose a reason for hiding this comment

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

I was talking about __init__.py file. Inside test files, if they belong to other modules, you should use absolute imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes these test belong to a module this module depends on. But I am not sure how to use absolute imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the idea of adding the base tests was to check, that everything is working as before, when the line exclude option is not checked. I think it is good practice to test the new option once checked and once not checked (here by executing the original tests).

We just had a similar case with the test here, but it was solved by deriving the test class from the base class: (https://github.com/OCA/sale-workflow/blob/16.0/sale_order_revision/tests/test_sale_order_revision.py)

from odoo.addons.base_revision.tests import test_base_revision
class TestSaleOrderRevision(test_base_revision.TestBaseRevision):

So I see the following options:

  • leave it as it is
  • remove the base tests
  • add a derived test class for each base test class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedrobaeza could you have a look on the test changes of my last commit? Is this the correct way to implement? If the changes are fine, I will squash the last two commits.

Copy link
Member

Choose a reason for hiding this comment

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

Do you need to override setUpClass method in inherited classes for this to work?

I think the idea of adding the base tests was to check, that everything is working as before, when the line exclude option is not checked. I think it is good practice to test the new option once checked and once not checked (here by executing the original tests).

Although the idea is not bad, this has a lot of cons:

  • You don't control the upstream tests and the rest of the modules in the repo, so they can break for whatever other reason that it's out of scope of your module (for example, another module in the repo breaking such tests).
  • They are very slow, as they are checking a lot of things that you don't need to recheck.
  • Now with your approach, there's no problem in identifying the errors in the logs. With the previous one, there was.

Due to this, my usual approach when I want to test that an option that can be activated is not interfering with standard flows is to include explicit tests on the module test suite, focusing on the specific features that the option is touching.

This may reduce the scope and may have a side effect not covered, but it's not usually needed when the feature is very clear like this one. If a side effect arises later, a regression tests is the tool to avoid that side effect on the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A class without content causes pre-commit to fail.

	Traceback (most recent call last):
	  File "/home/vscode/.cache/pre-commit/repokwtra7qi/py_env-python3/lib/python3.11/site-packages/pre_commit_hooks/debug_statement_hook.py", line 56, in check_file
	    ast_obj = ast.parse(f.read(), filename=filename)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/usr/local/lib/python3.11/ast.py", line 50, in parse
	    return compile(source, filename, mode, flags,
	           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "sale_timesheet_line_exclude/tests/test_project_billing.py", line 4
	    class TestProjectBillingLineExclude(TestProjectBilling):
	                                                            ^
	IndentationError: expected an indented block after class definition on line 4

Due to this, my usual approach when I want to test that an option that can be activated is not interfering with standard flows is to include explicit tests on the module test suite, focusing on the specific features that the option is touching.

Here you mean copy-past the test? In this case I would rather execute more unnecessary tests with the risk that the original test will break, than applying each change to the copied test.

I think removing the tests should be OK, as there is already a test checking that exclude_from_sale_order False is added to the invoice:
image

@pedrobaeza Do you agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedrobaeza tests removed, can you merge the PR?

@CRogos CRogos force-pushed the 16.0-mig-sale_timesheet_line_exclude branch from e575ace to 8417e30 Compare July 21, 2023 07:28
@pedrobaeza
Copy link
Member

Here you mean copy-past the test? In this case I would rather execute more unnecessary tests with the risk that the original test will break, than applying each change to the copied test.

Not per se, but to test the exactly thing we want to check. That thing can be copied/pasted if it's being tested upstream, but without all the unneeded noise.

I think removing the tests should be OK, as there is already a test checking that exclude_from_sale_order False is added to the invoice:

OK for me too.

@CRogos CRogos force-pushed the 16.0-mig-sale_timesheet_line_exclude branch from 8f464ac to b387b11 Compare August 8, 2023 13:33
@pedrobaeza
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-569-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 9275a0f into OCA:16.0 Aug 8, 2023
6 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at cbca9b3. Thanks a lot for contributing to OCA. ❤️

@CRogos CRogos deleted the 16.0-mig-sale_timesheet_line_exclude branch August 8, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.