0
votes

helo,

I need to update a field (e.g description ) in order line (e.g purchase.order.line tree view) once I select a product in inline edit mode, how can I fetch the selected product in the backend and then update the desired field in the front end?

Model purchase.order.line:

description

product_id

thank you,

1
What have you tried so far? Do you know how the onchange events are used in Odoo?CZoellner
I have tried the onchange declared under model purchase.order.line but it's doesn't triggered when I add new product-line. I'm checking about other function declared in XML, it's defined on Onchange attribute on product_id field: <field name="product_id" on_change="onchange_product_id(p..)Salim
Did you try to override onchange_product_id()?CZoellner
yes I already try it and it works, thank you for your commentSalim

1 Answers

0
votes

overriding the onchange_product_id() will solve my problem, and I'm able to handle the new selected product and update another field in tree view:

class purchase_ordr_line(models.Model):

_inherit = "purchase.order.line"


@api.multi
def onchange_product_id(self, pricelist_id, product_id, qty, uom_id,
        partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
        name=False, price_unit=False, state='draft'):
        dic_res = super(purchase_ordr_line, self).onchange_product_id(pricelist_id, product_id, qty, uom_id,partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
        name=False, price_unit=False, state='draft')
       #Following the custom code:
       dic_value = dic_res['value']
       dic_value['new_field_to_update'] = new_value
       return dic_res