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.

1

how can i fill the note field automatically in product_id_change()

By
mohamed abdelwahed
on 5/19/13, 2:15 PM 2,385 views

hello everybody , i want to know how can i put some notes in the "note" fields in sale.order obj from the product_id_change() function ???

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/20/13, 3:37 AM

Hi mohamed abdelwahed

you can override method product_id_change as like below

example:

def product_id_change(self, cr, uid, ids, uom_id,uom_po_id, context=None):
   vals = super(sale_order, self).product_id_change(cr, uid, ids, uom_id, uom_po_id)
   note = "Mys Notes"
   vals['value'].update({'note':note})
   return vals

Good Luck Thanks

i inherit the "sale.order.line" and i override the product_id_change() but nothing seems to work :/

mohamed abdelwahed
on 5/20/13, 7:54 AM

i gave an example , in real case you should use the place of vals.update({'note':note}) to vals['value'].update({'note':note})

Sandeep
on 5/20/13, 7:58 AM

for your information , there is no field note in sale.order.line object

Sandeep
on 5/20/13, 8:01 AM

i know that there is no field "note" in "sale.order.line" but my question is to know if there is a trick that allow me to access the "sale.order" field from "sale.order.line"

mohamed abdelwahed
on 5/20/13, 9:14 AM
2
le_dilem
On 5/20/13, 7:47 AM

Hi you can not use product_id_change in sale.order. Because it is in sale.order.line

Sale.order = the header Sale.order.line = a detail

So in sale.order.line you generates a field with product_id_change ans in sale.order you change your field note in function.

the principle of this function :

she travels sale.order.line your field x_discount, and affect in the header "note".

thanks le dilem for all your support but i'm a newbie in openerp and python so i can't understand your solution :/ i'm really stacked

mohamed abdelwahed
on 5/20/13, 10:12 AM

ok step by step : http://help.openerp.com/question/16336/how-i-can-create-module-openerp-7/

le_dilem
on 5/20/13, 10:31 AM

can you add me on facebook so we can speak french please here is my profile facebook.com/looser87

mohamed abdelwahed
on 5/20/13, 10:35 AM
1

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

Keyur
On 5/20/13, 3:29 AM

You can set note field of sale.order model by overriding product_id_change() method.

Here is the example,

def product_id_change(self, cr, uid, ids, .. ):
    vals = super(your_class, self).product_id_change(cr, uid, ids, uom_id, uom_po_id)
    note = "My Sale Order note"
    vals = {'value':{'note':note}}
    return vals
0
mohamed abdelwahed
On 5/20/13, 7:37 AM

thank you sir but here is my code and it dont seems to work

class sale_order(osv.osv):

_name='sale.order'
_inherit='sale.order'

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):
    vals = super(sale_order, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
    uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
    lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
    note = "Mys Notes"
    vals.update({'note':note})
    return vals

sale_order()

Please add your query in comment section not in answer section & product_id_change method is not of sale.order model. It is of sale.order.line model. Hope now it will work. Thanks

Keyur
on 5/20/13, 7:47 AM

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

2 follower(s)

Stats

Asked: 5/19/13, 2:15 PM
Seen: 2385 times
Last updated: 3/16/15, 8:10 AM