Search code examples
pythonodoo-11

odoo11 log generation when i change data in a field using CSV Import


In Odoo11, When a field is changed by any user, It generates a log. for that I use track_visibility in field.

`audit_user = fields.Many2one('res.users', string='Audit User', track_visibility='onchange')
 audit_date = fields.Datetime(string="Audit Date", track_visibility='onchange')
 is_audited = fields.Boolean(string='Is Audited', track_visibility='onchange')`

enter image description here

That's The log is generated after any user change the data in these fields.

I can also update data of these fields using CSV Import of Odoo.

No log is generating when i changed field using CSV Import.

I want to generate a log when I change field data using CSV Import Option of Odoo.


Solution

  • It can be done by Method Overriding of Import function, providing you an example of custom log note generation code snippets

        self.env['mail.message'].create({
            'body': <your message>,
            'message_type': 'comment',
            'subtype_id': self.env.ref('mail.mt_note').id,
            'model': <your model name>,
            'res_id': <model's object id where you want to post>
        })