diff --git a/odoo/migration.yml b/odoo/migration.yml index d7f67e66acb..b3bd1b2f117 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -175,3 +175,6 @@ migration: upgrade: - specific_sale - specific_inter_company + operations: + post: + - anthem songs.upgrade.10_0_14.intercompany::main diff --git a/odoo/songs/upgrade/10_0_14/__init__.py b/odoo/songs/upgrade/10_0_14/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/odoo/songs/upgrade/10_0_14/intercompany.py b/odoo/songs/upgrade/10_0_14/intercompany.py new file mode 100644 index 00000000000..d6192e0fc57 --- /dev/null +++ b/odoo/songs/upgrade/10_0_14/intercompany.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +import anthem + + +@anthem.log +def set_intercompany_rules(ctx): + warehouse = ctx.env['stock.warehouse'] + holding = ctx.env.ref('__setup__.roctool_holding') + for company in ctx.env['res.company'].search([('id', '!=', holding.id)]): + warehouse_id = warehouse.search([('company_id', '=', company.id)])[0] + vals = { + 'so_from_po': (company.name == 'RocTool SA'), + 'po_from_so': False, + 'warehouse_id': warehouse_id.id, + 'ref': 'r%s' % company.country_id.code.lower(), + 'customer': 1, + 'supplier': (company.name == 'RocTool SA'), + } + company.write(vals) + + +@anthem.log +def main(ctx): + """ Main: creating intercompany rules """ + set_intercompany_rules(ctx)