Hi!
I'm using Odoo13 ent. and I've tried to track a Many2many field. With char, date,... fields I had no problem.
Do anyone know how to track a Many2many, One2many and Many2one fields?
Thank you in advance!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi!
I'm using Odoo13 ent. and I've tried to track a Many2many field. With char, date,... fields I had no problem.
Do anyone know how to track a Many2many, One2many and Many2one fields?
Thank you in advance!
You can override the `mail\.track\.value`\ model\ and\ store\ the\ values\ in\ the\ `old_value_char`\ and\ `new_value_char`\ separated\ by\ a\ comma\.\ Works\ like\ a\ charm\ for\ tracking\ changes\ on\ tags\ for\ example\.
class\ MailTrackingValue\(models\.Model\):
\ \ \ \ _inherit\ =\ 'mail\.tracking\.value'
\ \ \ \ @api\.model
\ \ \ \ def\ create_tracking_values\(self,\ initial_value,\ new_value,\ col_name,\ col_info,\ tracking_sequence,\ model_name\):
\ \ \ \ \ \ \ \ values\ =\ super\(MailTrackingValue,\ self\)\.create_tracking_values\(initial_value,\ new_value,\ col_name,\ col_info,\ tracking_sequence,\ model_name\)
\ \ \ \ \ \ \ \ if\ not\ values\ and\ col_info\['type'\]\ ==\ 'many2many':
\ \ \ \ \ \ \ \ \ \ \ \ field\ =\ self\.env\['ir.model.fields']._get(model_name, col_name)
if not field:
return
values = {
'field': field.id,
'field_desc': col_info['string'],
'field_type': col_info['type'],
'tracking_sequence': tracking_sequence,
'old_value_char': ', '.join([r.name_get()[0][1] for r in initial_value]),
'new_value_char': ', '.join([r.name_get()[0][1] for r in new_value]),
}
return values
Hi,
You can add track_visibility attribute to field's declaration and use 'always' or 'onchange' to track every changes of field.
Ex
partner_id = fields.Many2one('res.partner',track_visibility='always')
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Aug 17
|
2597 | ||
|
2
May 24
|
539 | ||
|
3
Dec 23
|
4055 | ||
|
3
Jul 23
|
32449 | ||
|
2
Jun 23
|
1636 |