Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create an osv_memory wizard systems in Odoo-9 ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.13k
    Comment on it

    In osv_memory wizard, just create a normal object, But in place of inheriting from model.model you should it from Inherit from model.model_memory.
    Methods of wizard are inside the object and if the wizard is complex, You can define workflow on object. In the action that opens the object, you can put

    1- <field name="target">new</field> 
    

    It means the object will open in a new window. On a button,you can use <button special=cancel/> to close the window.
    Example :
    you have to use below code in project.py file.

    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>
    

 0 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: