This question has been flagged
3293 Views

Hi,ereryone, I want to use wizard to do the "Add an Item". I add "My add" after "Add an Item". when I click "My add", it will pop wizard. But after I choose product, move_lines doesn't have any data lines. the following is my question: How can I move my wizard data to move_lines?

my_wizard.py:

class stock_move_product(osv.osv_memory): _name = "stock.move.product" _columns = { 'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
}

def default_get(self, cr, uid, fields, context=None):
    if context is None:
        context = {}
    res = super(stock_move_product, self).default_get(cr, uid, fields, context=context)
    '''move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
    if 'product_id' in fields:
        res.update({'product_id': move.product_id.id})
    if 'product_uom' in fields:
        res.update({'product_uom': move.product_uom.id})'''
    res.update({'product_uom':1})
    return res

def do_move_product(self, cr, uid, ids, context=None):
    return {'type': 'ir.actions.act_window_close'}

my_wizard_view.xml:

<openerp> <data> <record id="view_stock_move_product_wizard" model="ir.ui.view"> <field name="name">Product Move</field> <field name="model">stock.move</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Product Move" version="7.0"> <group string="Move Products"> <field name="product_id"/> <field name="product_qty"/> </group> <footer> <button name="do_move_product" string="Ok" type="object" class="oe_highlight"/> or <button string="Cancel" class="oe_link" special="cancel"/> </footer> </form> </field> </record>

    <record id="move_product" model="ir.actions.act_window">
        <field name="name">Product Move</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">stock.move</field>
        <field name="src_model">product.product</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
</data>

</openerp>

Avatar
Discard