弹出窗口返回3个字段 - Odoo v8

时间:2017-11-16 17:34:03

标签: python openerp odoo-8

我有这个方法,它从另一个模型创建stock.picking

@api.multi
def create_printy(self):
    copy_record = self.env['stock.picking'] 
    for record in self:
        order_lines = []
        for rec in record.order_lines:
            order_lines.append(
            (0,0,
            {
                'name': 'name',
                'product_id': rec.isbn.id,
                'product_uom': rec.isbn.uom_id.id,
                'date_expected': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                'product_uom_qty': rec.qty,
                'location_id': record.location_id.id,
                'location_dest_id': record.location_dest_id.id,
                }
            ))
        sp_types = self.env['stock.picking.type'].search([
        ('code', '=', 'outgoing')
        ])
        if len(sp_types) > 0:
            copy_record.create({
                'origin': record.name,
                'picking_type_id': sp_types[0].id,
                'move_lines': order_lines, 
                'move_type': 'direct',
                'priority': '1',
                'company_id': record.company_id.id,
            })
       self.write({'state': 'delivered',},)

但在创建新company_id之前,应在弹出窗口中加载其中的location_idlocation_dest_idstock.picking中的3个字段。

我试过这个:

@api.multi
def create_printy(self):
    copy_record = self.env['stock.picking'] 
    for record in self:
        order_lines = []
        for rec in record.order_lines:
            order_lines.append(
            (0,0,
            {
                'name': 'name',
                'product_id': rec.isbn.id,
                'product_uom': rec.isbn.uom_id.id,
                'date_expected': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                'product_uom_qty': rec.qty,
                'location_id': record.location_id.id,
                'location_dest_id': record.location_dest_id.id,
                }
            ))
        sp_types = self.env['stock.picking.type'].search([
        ('code', '=', 'outgoing')
        ])
        if len(sp_types) > 0:
            copy_record.create({
                'origin': record.name,
                'picking_type_id': sp_types[0].id,
                'move_lines': order_lines, 
                'move_type': 'direct',
                'priority': '1',
                'company_id': record.company_id.id,
            })
    tree_view_id = self.env.ref('stock.vpicktree').id
    form_view_id = self.env.ref('stock.view_picking_form').id
    return {
        'name': ('Stock Picking'),
        'type': 'ir.actions.act_window',
        'res_model': 'stock.picking',
        'view_mode': 'tree,form',
        'view_type': 'form',
        'views': [(tree_view_id, 'tree'),(form_view_id, 'form')],
        'view_id':tree_view_id,
        'res_id': [copy_record.id],
        'domain': [('id', 'in', [copy_record.id])]
        }
    self.write({'state': 'delivered',},)

但是return仅返回stock.picking视图,并且没有创建任何内容,如何修改此内容以在弹出窗口中加载这3个字段?

我尝试在没有向导的情况下保持简单,我知道使用向导这可以实现,但我只想修改此方法。

有什么想法吗?

0 个答案:

没有答案