• Tek Siong, Hock

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

Updated: Jun 20

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  



111 views1 comment

©2019 by Excelroot Technology Sdn Bhd.