Aide

2

how Fields function update

Avatar
Grante

hello,

I a field function stock_qty_avaible on quotation when I edited a line, I selected a product, I want to update the fields function stock_qty_avaible. I try update field stock_qty_avaible it not works. try with store=True, store=False. The update work when click update button on quotation.

Code :

_columns = {
    'stock_qty_available': fields.function(_product_available1, multi='stock_qty_available', type='float', digits_compute=dp.get_precision('Product Unit of Measure'),                 }
 }

def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
    """
    ajout de l'affichage des stocks
    """
    resultProductChange = {}
    resultProductChange =  super(spe_salesOrderLines,self).product_id_change(cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag, context)
    resultProductChange['value']['stock_qty_avaible'] = 12

    return resultProductChange

Code In the Xml

< field name="stock_qty_available" string="stock Qty" />

Avatar
Annuler
2 Réponses
5
Meilleure réponse

Hi Grante

your Function first parameter is function name , which will be called by function class to get value in function field, so your function name should be same as first parameter

it will be like:

     def _product_available1(self,cr,uid,ids,name,arg,context=None):
    res={}

    #  your code here to get the value for function field
            for i in ids:
                res[i]=your_value
    return res

Thats it

Thanks
Sandeep

1 Commentaires
Avatar
Annuler
Avatar
Grante
-

hello, the funtion _product_available1 exits and works, when edit a line product, the function product_id_change is called, i add information after execution super().product_id_change and the fields fonction not change. i try with field discount, it's work, but is not a field function.

0
Avatar
Omal Bastin
Meilleure réponse

Following link gives Functional field explanation

Avatar
Annuler