top of page

Track changes in Odoo line item (One-to-Many Field)

  • Writer: Tek Siong, Hock
    Tek Siong, Hock
  • Mar 15, 2020
  • 1 min read

Updated: Mar 28, 2021

This Odoo technical development blog is my way to contribute back to the Odoo Community, for all the selfless and great sharing by the community members.


Odoo has the standard feature of tracking the changes of the document with chatter, by declaring in the field.

track_visibility='onchange'

However, this cannot be applicable to One-to-Many field on the line item.

Don't freak, here is the solution, to override the write and create method on the One-to-Many field.


Click "Like" at the bottom of this blog, to motivate us to continue sharing more Odoo tips.

@api.model
def create(self, vals):
    res = super(FreightOperationLine, self).create(vals)
    content = ""
    content = content + "  \u2022 Container: " + str(vals.get("container_no")) + "<br/>"
    res.operation_id.message_post(body=content)

    return res

@api.multi
def write(self, vals):
    res = super(FreightOperationLine, self).write(vals)
    content = ""
    if vals.get("container_no"):
        content = content + "  \u2022 Container: " + str(vals.get("container_no")) + "<br/>"
    self.operation_id.message_post(body=content)

    return res  


Recent Posts

See All
Odoo Performance Profile for debugging

Odoo Performance Profile for debugging, If you are on Odoo 16 and below, and need a good tool for debugging the performance of your Odoo system, this will be the right content for you.

 
 
 

1 Comment


browseinfo.in
Jul 06, 2020

Thank you so much for sharing this very informative content. It's very useful for us. Keep blogging.

Like

Subscribe Form

  • facebook
  • linkedin

©2019 by Excelroot Technology Sdn Bhd.

bottom of page