Skip to content

Conversation

@pfertyk
Copy link
Contributor

@pfertyk pfertyk commented Oct 16, 2025

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Oct 16, 2025

Pull request status dashboard

@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 2 times, most recently from 3ac3f55 to 1060fe9 Compare October 16, 2025 11:25
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 3 times, most recently from 0f6e54d to d6263f3 Compare October 27, 2025 10:30
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 5 times, most recently from 055f8e5 to 84b262e Compare November 3, 2025 12:05
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 2 times, most recently from 8a1668d to d1e1881 Compare November 17, 2025 14:13
@svs-odoo svs-odoo marked this pull request as ready for review November 17, 2025 14:20
@C3POdoo C3POdoo requested review from a team and Sehnde and removed request for a team November 17, 2025 14:42
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch from d1e1881 to f7ec7ad Compare November 18, 2025 10:00
Copy link
Contributor

@svs-odoo svs-odoo left a comment

Choose a reason for hiding this comment

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

Yop ! Here the first review !
I let you some comments but it's pretty minor, it seems already very good :)

""" Checks we can't change the product's company if this product has
quant in another company. """
company1 = self.env.ref('base.main_company')
company1 = self.company
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove this line and use directly self.company in the test (same for test_change_product_company_02)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used self.company and renamed company2 to another_company 👍

self.env.user.write({'group_ids': [Command.link(grp_multi_companies.id)]})

company_2 = self.company
company_2 = self.company_2
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you keep this variable to limite the change but I think you can ride off it.
It's useless and since you already refactor the tests here, it's the occasion to remove dead code and useless code.
Same comment for following tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in both tests 👍

Comment on lines 257 to 258
route_manufacture = self.warehouse_1.manufacture_pull_id.route_id.id
route_mto = self.warehouse_1.mto_pull_id.route_id.id
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
route_manufacture = self.warehouse_1.manufacture_pull_id.route_id.id
route_mto = self.warehouse_1.mto_pull_id.route_id.id
route_manufacture_id = self.warehouse_1.manufacture_pull_id.route_id.id
route_mto_id = self.warehouse_1.mto_pull_id.route_id.id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, thanks 👍

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company = cls.env['res.company'].create({
Copy link
Contributor

Choose a reason for hiding this comment

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

Now, a warehouse is automatically created when the company is created, so instead of creating a new warehouse for cls.warehouse_1, I think you should use the company's warehouse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use the company warehouse (with the original values) 👍

self.start_tour('/odoo/purchase', "test_purchase_order_suggest_search_panel_ux", login='admin')
self.start_tour(
'/odoo/purchase', "test_purchase_order_suggest_search_panel_ux", login='admin',
cookies={"cids": f"{self.company.id}"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that using cookies to force the company is a "rubber tape" solution to run the tour with the right config.
The good solution would be to run it with the right user (res_users_purchase_user for example, so login pu instead of admin) but for now, this solution doesn't work because of an access right error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, should I keep my version for now, but add a comment to clarify?

Copy link
Contributor

@svs-odoo svs-odoo Nov 25, 2025

Choose a reason for hiding this comment

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

@pfertyk The PR #236743 (only targeting 19.0 for now) should fix the issue.
For now, you can let that like this, but if the PR is merged in master in the meantime, you can update the login to use the purchase user instead (I'll let you know in this case)

cls.uom_unit = cls.env.ref('uom.product_uom_unit')
cls.uom_pack_6 = cls.env.ref('uom.product_uom_pack_6')
cls.wh = cls.env['stock.warehouse'].search([('company_id', '=', cls.env.user.id)], limit=1)
cls.wh = cls.warehouse_1
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this variable and use warehouse_1 directly instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed 👍

cls.warehouse = warehouse_form.save()

cls.uom_unit = cls.env.ref('uom.product_uom_unit')
cls.warehouse = cls.warehouse_1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think with this kind of changes, it doesn't make a lot of sense to keep variable like this to minimize the change.
I think it would be better to remove them and use directly the real variable (warehouse_1 here.) After all, it's a refactor PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed 👍

@Sehnde Sehnde removed their request for review November 18, 2025 22:09
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 5 times, most recently from 33cdcf0 to d4298c5 Compare November 26, 2025 21:47
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch 3 times, most recently from b7aa854 to c2dbfa4 Compare December 3, 2025 14:48
… custom company in stock tests

This is a part of stock tests refactoring. The final goal is to use only
dedicated data in all stock tests, including a dedicated user to run the
tests. This change introduces only a custom company.
@pfertyk pfertyk force-pushed the master-stock-tests-refactoring-custom-company-pafe branch from c2dbfa4 to 85121a8 Compare December 3, 2025 15:31
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.

4 participants