• Tek Siong, Hock

onChange method in the one2Many field

If you are doing something in the onChange method in the one2Many field, eg, in the order_line in the sales.order, if you want to update additional info to the description ('name' field) upon adding of the product.

There will be a problem to get the parent ID. For example

a) You will not be able to get the id of the parent sale.order with self._origin.id.

b) Use the Context to pass the id of the parent.

<field name="myone2manyfields_ids" context="{'active_id': id}"> 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          order = self.env['sales.order'].search([('id', '=', self.env.context.get('active_id'))], limit=1)
3 views0 comments

Recent Posts

See All

How to backup large database that may not be downloaded, due to time out or zip file error.