Skip to content

Commit

Permalink
Merge pull request OCA#4547 from Tecnativa/16.0-fix-stock-multi_locat…
Browse files Browse the repository at this point in the history
…ion_views

[16.0][FIX] stock: Disable multi-location restricting views
  • Loading branch information
pedrobaeza authored Sep 9, 2024
2 parents 7e955f5 + 5454aec commit 504174f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
from openupgradelib import openupgrade


def _handle_multi_location_visibility(env):
"""There are certain views that are disabled/enabled according to the multi-location
security group, as it can be seen in this commit:
https://github.com/odoo/odoo/blob/8f6c56d0794c54bde0/addons/stock/models/
res_config_settings.py#L99-L126
so we need to mimic that behavior in case the group is enabled, as the views exists
by default with active=True.
"""
multi_location_group_xml_id = "stock.group_stock_multi_locations"
if env.ref("base.group_user") in env.ref(multi_location_group_xml_id).implied_ids:
for xml_id in (
"stock.stock_location_view_tree2_editable",
"stock.stock_location_view_form_editable",
):
view = (env.ref(xml_id, raise_if_not_found=False),)
if view:
view.active = False


@openupgrade.migrate()
def migrate(env, version):
_handle_multi_location_visibility(env)
openupgrade.load_data(env.cr, "stock", "16.0.1.1/noupdate_changes.xml")

0 comments on commit 504174f

Please sign in to comment.