Odoo Help


Error in function to update a stock?

on 1/23/14, 8:15 AM 1,049 views

Hi, I wrote a function to update my stock equipment. In fact I have 3 classes, one that contains all my equipment, which contains a point of the stock and the last which allows for supply, I put the function in the class of supply, I execute from a button as follows:

<button name="act_order_instock" type="objet" string="In stock" class="oe_highlight" attrs="{'invisible':[('state','=','instock')]}"/>  <field name="state" widget="statusbar" statusbar_visible = "draft,instock"/>

and here is the function:

def act_order_instock(self, cr, uid,ids,context=None):
    val = 0.0    
    res = {}
    for record in self.browse(cr, uid,ids,context=context):
        cr.execute("select quantity from material_equipmentstock p where id=%s",(record.equipmentstock_id.id,))
        res = cr.dictfetchall()
        if res:
            for elt in res:
                st = elt['quantity']
                print elt
                val = st + record.quantity
            if val > 0:
                cr.execute("UPDATE material_equipmentstock SET quantity=%s "\
                  "where id=%s",(val,record.equipmentstock_id.id))
                self.write(cr, uid, ids,{'state':'instock'},context=context)
                raise osv.except_osv('Sorry', 'Impossible de faire l'approvisionnement!')      
                raise osv.except_osv('Sorry', 'Impossible')
    return True

The problem is that when I click the button, nothing happens, I have need of your help, thank you.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/23/14, 8:15 AM
Seen: 1049 times
Last updated: 3/16/15, 8:10 AM