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.

2

how Fields function update

By
Grante
on 5/26/13, 12:05 PM 2,083 views

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" />

5

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 5/26/13, 1:56 PM

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

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.

Grante
on 5/26/13, 2:15 PM
0

Omal Bastin

--Omal Bastin--
1146
| 6 6 8
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

Omal Bastin
On 5/27/13, 5:37 AM

Following link gives Functional field explanation

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: 5/26/13, 12:05 PM
Seen: 2083 times
Last updated: 3/16/15, 8:10 AM