26 lines
695 B
Python
26 lines
695 B
Python
# migrations/1.1.0/post-migrate.py
|
|
import os
|
|
import csv
|
|
import logging
|
|
from odoo import api, SUPERUSER_ID
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def migrate(cr, version):
|
|
# 获取环境
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
|
|
ProductionLine = env['sf.production.demand.plan']
|
|
DemandPlan = env['sf.demand.plan']
|
|
|
|
lines = ProductionLine.search([('demand_plan_id', '=', False)])
|
|
for line in lines:
|
|
vals = {
|
|
'sale_order_id': line.sale_order_id.id,
|
|
'sale_order_line_id': line.sale_order_line_id.id,
|
|
'line_ids': line.ids
|
|
}
|
|
new_plan = DemandPlan.create(vals)
|
|
line.write({'demand_plan_id': new_plan.id})
|