Merge lp:~camptocamp/anybox.recipe.openerp/fix-1358353-yvr into lp:anybox.recipe.openerp

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 556
Proposed branch: lp:~camptocamp/anybox.recipe.openerp/fix-1358353-yvr
Merge into: lp:anybox.recipe.openerp
Diff against target: 64 lines (+31/-4)
2 files modified
anybox/recipe/openerp/base.py (+13/-4)
anybox/recipe/openerp/tests/test_base.py (+18/-0)
To merge this branch: bzr merge lp:~camptocamp/anybox.recipe.openerp/fix-1358353-yvr
Reviewer Review Type Date Requested Status
Georges Racinet Approve
Guewen Baconnier @ Camptocamp (community) Approve
Review via email: mp+231218@code.launchpad.net

Description of the change

        We want to keep ordering of addons path.
        If official addons path is missing, we add just after path of base
        addons.
        Otherwise, we do nothing to keep official addons where they are.

        We preserve the order, because it is important for addons with same
        name.
        Only first found addons of duplicate names is considered.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Nice, can I propose a rewording? (could even be better though)

"""
The ordering of the different paths of addons is important, because when several addons in different paths have the same name, the first of them that is found is used. This can be used, for instance, to replace an official addon by another one by placing a different addons' path before the official one.

If the official addons' path is already set in the config file (e.g. at the end), it will leave it at the end of the paths list, if it is not set, it will be placed at the beginning.
"""

review: Approve
557. By Guewen Baconnier @ Camptocamp

reword docstring

558. By Yannick Vaucher @ Camptocamp

reword docstring

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Added your rewording and did few little changes in 2 commits.

Thanks

Revision history for this message
Georges Racinet (gracinet) wrote :

Thanks fort thé MP. I'm currently out of office, will consider it next week.

On 18 août 2014 18:41:44 UTC+02:00, "Yannick Vaucher @ Camptocamp" <email address hidden> wrote:
>Added your rewording and did few little changes in 2 commits.
>
>Thanks
>--
>https://code.launchpad.net/~camptocamp/anybox.recipe.openerp/fix-1358353-yvr/+merge/231218
>You are requested to review the proposed merge of
>lp:~camptocamp/anybox.recipe.openerp/fix-1358353-yvr into
>lp:anybox.recipe.openerp.

--
Sent from my handheld device with K-9 Mail. Please excuse my brevity.

Revision history for this message
Georges Racinet (gracinet) wrote :

LGTM, and I appreciate the docstring work. That being said:

- (minor) for now, everything related to the Github layout is acceptable for the stable branch. I can take care of the backporting if you don't feel comfortable about it.

- I think this deserves a unit test of its own. There's already a test_finalize_addons_path() in test_base.py, you could easily make a companion one for this use-case. And this will ease the backporting as well

If you have trouble launching the unit tests, here's the how-to :

http://docs.anybox.fr/anybox.recipe.openerp/stable/contributing.html#launching-static-analysis-and-unit-tests

Thanks again

review: Needs Fixing
559. By Yannick Vaucher @ Camptocamp

add test for addons path order

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Here we go.

I just added a test for this case.

Revision history for this message
Georges Racinet (gracinet) wrote :

> Here we go.
>
> I just added a test for this case.

Unfortunately, the test passes without the main code modification. That's because you forgot to create the 'odoo_dir/addons' directory (hence the github layout method did not work at all).

I added the missing line and it worked as expected.bzr -> merged

review: Approve
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Ok Georges
I see I missed the os.makedirs(odoo_addons) part.

Thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'anybox/recipe/openerp/base.py'
2--- anybox/recipe/openerp/base.py 2014-07-24 12:44:00 +0000
3+++ anybox/recipe/openerp/base.py 2014-09-04 12:27:51 +0000
4@@ -1259,6 +1259,17 @@
5 If not found (e.g, we are on a nightly for OpenERP <= 7), this method
6 does nothing.
7
8+ The ordering of the different paths of addons is important.
9+ When several addons at different paths have the same name, the first
10+ of them being found is used. This can be used, for instance, to
11+ replace an official addon by another one by placing a different
12+ addons' path before the official one.
13+
14+ If the official addons' path is already set in the config file
15+ (e.g. at the end), it will leave it at the end of the paths list,
16+ if it is not set, it will be placed at the beginning just after
17+ ``base`` addons' path.
18+
19 Care is taken not to break configurations that corrected this manually
20 with a ``local`` source in the ``addons`` option.
21
22@@ -1276,11 +1287,9 @@
23 except ValueError:
24 insert_at = 0
25 try:
26- addons_paths.remove(odoo_git_addons)
27+ addons_paths.index(odoo_git_addons)
28 except ValueError:
29- pass
30-
31- addons_paths.insert(insert_at, odoo_git_addons)
32+ addons_paths.insert(insert_at, odoo_git_addons)
33
34 def cleanup_openerp_dir(self):
35 """Revert local modifications that have been made during installation.
36
37=== modified file 'anybox/recipe/openerp/tests/test_base.py'
38--- anybox/recipe/openerp/tests/test_base.py 2014-06-08 21:55:32 +0000
39+++ anybox/recipe/openerp/tests/test_base.py 2014-09-04 12:27:51 +0000
40@@ -426,6 +426,24 @@
41 self.assertEquals(self.recipe.addons_paths, [base_addons,
42 '/some/separate/addons'])
43
44+ def test_finalize_addons_paths_order(self):
45+ """Test finalize_addons_paths keeps addons_path order
46+ Ensure we don't move odoo addons in addons_path if it has been
47+ set as local
48+ """
49+ self.make_recipe(
50+ version='git http://github.com/odoo/odoo.git odoo 7.0')
51+ self.recipe.version_detected = '7.0-somerev'
52+ oerp_dir = self.recipe.openerp_dir
53+ base_addons = os.path.join(oerp_dir, 'openerp', 'addons')
54+ odoo_addons = os.path.join(oerp_dir, 'addons')
55+ os.makedirs(base_addons)
56+ self.recipe.addons_paths = ['/some/separate/addons',
57+ odoo_addons]
58+ self.recipe.finalize_addons_paths(check_existence=False)
59+ self.assertEquals(self.recipe.addons_paths,
60+ [base_addons, '/some/separate/addons', odoo_addons])
61+
62 def test_finalize_addons_paths_60_layout(self):
63 self.make_recipe(version='6.0.4')
64 recipe = self.recipe

Subscribers

People subscribed via source and target branches