Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create an osv_memory wizard systems in openerp-7 and openerp-8(Odoo)

    • 0
    • 1
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 2.33k
    Comment on it

    To create an osv_memory wizard systems in openerp-7 and openerp-8(Odoo), follow the below steps.


    In the action that opens the object, you can put </br>
         <field name="target"/> 
        It means the object will open in a new window.
        On a button,you can use <button special=cancel/> to close the window.
    


    class config_compute_remaining(osv.osv_memory): 
    _name=config.compute.remaining 
    def _get_remaining(self,cr, uid, ctx): 
    if active_id in ctx: 
    return self.pool.get(project.task).browse(cr,uid,ctx[active_id]).remaining_hours 
    return False 
    _columns = { 
    remaining_hours : fields.float(Remaining Hours, digits=(16,2),), 
    } 
    _defaults = { 
    remaining_hours: _get_remaining 
    } 
    def compute_hours(self, cr, uid, ids, context=None): 
    if active_id in context: 
    remaining_hrs=self.browse(cr,uid,ids)[0].remaining_hours 
    self.pool.get(project.task).write(cr,uid,context[active_id], 
    {remaining_hours : remaining_hrs}) 
    return { 
    type: ir.actions.act_window_close, 
    } 
    config_compute_remaining() 
    

    View is same as normal view (Note buttons)

    <record id="view_config_compute_remaining" model="ir.ui.view"> 
    <field name="name">Compute Remaining Hours </field> 
    <field name="model">config.compute.remaining</field> 
    <field name="type">form</field> 
    <field name="arch" type="xml"> 
    <form string="Remaining Hours"> 
    <separator colspan="4" string="Change Remaining Hours"/> 
    <newline/> 
    <field name="remaining_hours" widget="float_time"/> 
    <group col="4" colspan="4"> 
    <button icon="gtk-cancel" special="cancel" string="Cancel"/> 
    <button icon="gtk-ok" name="compute_hours" string="Update" type="object"/> 
    </group> 
    </form> 
    </field> 
    </record> 
    

    Note: Here in osv_memory wizard I have created a normal object, But instead of inheriting wizrad from osv.osv, I have Inherit it from osv.osv_memory.
    Methods of wizard are in object and if the wizard is complex, You can define workflow on object as I did.

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: