Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
8165 Vistas

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 ???

Avatar
Descartar
Mejor respuesta

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

Avatar
Descartar
Autor

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

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

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

Autor

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"

Mejor respuesta

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

Avatar
Descartar
Autor

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

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

Autor

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

Mejor respuesta

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
Avatar
Descartar
Autor Mejor respuesta

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()

Avatar
Descartar

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

Publicaciones relacionadas Respuestas Vistas Actividad
2
mar 15
4980
2
mar 15
4276
0
mar 15
3349
0
ene 25
890
0
sept 22
2899