Odoo Help

Welcome!

This community 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.

0

Error in function to update a stock?

By
MALLE SOULEYMANE
on 1/23/14, 8:15 AM 590 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:
            print'---------------------------------------------'        
            print(res)
            print'--------------------------------------------'
            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)
            else:
                raise osv.except_osv('Sorry', 'Impossible de faire l'approvisionnement!')      
        else:
                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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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