Skip to content

Commit

Permalink
Merge pull request #2261 from Tecnativa/8.0-stock-fix_security_migration
Browse files Browse the repository at this point in the history
[FIX] stock: Migrate security groups
  • Loading branch information
pedrobaeza committed Mar 30, 2020
2 parents 03c32e9 + 20705fd commit 18ff5fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions addons/stock/migrations/8.0.1.1/post-migration.py
Expand Up @@ -46,6 +46,13 @@
}


@openupgrade.logging()
def _migrate_security(env):
group_stock_manager = env.ref("stock.group_stock_manager")
group_account_user = env.ref("account.group_account_user")
group_stock_manager.implied_ids -= group_account_user


def migrate_product(cr, registry):
"""Migrate track_incoming, track_outgoing"""
prod_tmpl_obj = registry['product.template']
Expand Down Expand Up @@ -1125,14 +1132,15 @@ def populate_stock_move_fields(cr, registry):
WHERE sm1.id = res.id""")


@openupgrade.migrate()
def migrate(cr, version):
@openupgrade.migrate(use_env=True)
def migrate(env, version):
"""
It can be the case that procurement was not installed in the 7.0 database,
as in 7.0 stock was a dependency of procurement and not the other way
around like it is in 8.0. So we need to check if we are migrating a
database in which procurement related stuff needs to be migrated.
"""
cr = env.cr
registry = RegistryManager.get(cr.dbname)
populate_stock_move_fields(cr, registry)
have_procurement = openupgrade.column_exists(
Expand All @@ -1159,3 +1167,4 @@ def migrate(cr, version):
cr, uid, registry, ['stock.production.lot', 'stock.picking'])
migrate_move_inventory(cr, registry)
reset_warehouse_data_ids(cr, registry)
_migrate_security(env)

0 comments on commit 18ff5fc

Please sign in to comment.