[MIG] mail_improved_tracking_value: migration to Odoo 11

Improve the tracking of changed values on database fields
("mail.tracking.value" functionality) by adding many2many and one2many support.
As well as a more user friendly view to consult changes recorded.
pull/1163/head
Thierry Ducrest 2017-06-07 15:01:30 +02:00 committed by Anna Janiszewska
parent 3fb3480962
commit 8b7b014df5
4 changed files with 40 additions and 41 deletions

View File

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Improved tracking value change',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'summary': 'Improves tracking changed values for certain type of fields.'
'Adds a user-friendly view to consult them.',
'author': 'Camptocamp, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'Tools',
'website': 'http://www.camptocamp.com',
'website': 'https://github.com/OCA/social',
'depends': [
'base',
'mail'
@ -18,6 +17,4 @@
'data': [
'views/mail_tracking_value.xml'
],
'installable': True,
'auto_install': False,
}

View File

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import json
@ -11,13 +10,22 @@ class MailTrackingValue(models.Model):
_inherit = "mail.tracking.value"
new_value_formatted = fields.Char(compute='_compute_formatted_value',
string='New value')
old_value_formatted = fields.Char(compute='_compute_formatted_value',
string='Old value')
record_name = fields.Char(related='mail_message_id.record_name')
model = fields.Char(related='mail_message_id.model', store='True',
string='Model')
new_value_formatted = fields.Char(
compute='_compute_formatted_value',
string='New value',
)
old_value_formatted = fields.Char(
compute='_compute_formatted_value',
string='Old value',
)
record_name = fields.Char(
related='mail_message_id.record_name',
)
model = fields.Char(
related='mail_message_id.model',
store='True',
string='Model',
)
@api.depends('new_value_char', 'new_value_integer', 'new_value_float',
'new_value_text', 'new_value_datetime', 'new_value_monetary',
@ -25,7 +33,6 @@ class MailTrackingValue(models.Model):
'old_value_text', 'old_value_datetime', 'old_value_monetary')
def _compute_formatted_value(self):
""" Sets the value formatted field used in the view """
# Could be improved, by styling in the view depending on type of field
for record in self:
if record.field_type in ('many2many', 'one2many', 'char'):
record.new_value_formatted = record.new_value_char
@ -72,7 +79,7 @@ class MailTrackingValue(models.Model):
values.update(get_values(new_value, 'new'))
return values
else:
return super(MailTrackingValue, self).create_tracking_values(
return super().create_tracking_values(
old_value, new_value,
col_name, col_info
)

View File

@ -7,12 +7,12 @@
<field name="arch" type="xml">
<tree string="Tracking change list" default_order="create_date desc"
create="false" edit="false" delete="false">
<field name="create_date" string="On"/>
<field name="record_name" string="For"/>
<field name="field_desc" string="Field changed"/>
<field name="old_value_formatted"/>
<field name="new_value_formatted"/>
<field name="model"/>
<field name="create_date" string="On"/>
<field name="record_name" string="For"/>
<field name="field_desc" string="Field changed"/>
<field name="old_value_formatted"/>
<field name="new_value_formatted"/>
<field name="model"/>
</tree>
</field>
</record>
@ -24,16 +24,14 @@
<field name="arch" type="xml">
<form>
<sheet>
<field name="create_date" class="oe-inline"/>
<group>
<group string="">
<field name="record_name" string="For"/>
<field name="field_desc" string="Field changed"/>
<field name="old_value_formatted"/>
<field name="new_value_formatted"/>
<field name="model"/>
</group>
</group>
<field name="create_date" class="oe-inline"/>
<group name="main">
<field name="mail_message_id" string="For"/>
<field name="field_desc" string="Field changed"/>
<field name="old_value_formatted"/>
<field name="new_value_formatted"/>
<field name="model"/>
</group>
</sheet>
</form>
</field>
@ -44,11 +42,9 @@
<field name="model">mail.tracking.value</field>
<field name="arch" type="xml">
<search string="Search">
<group>
<field name="model"/>
</group>
<group expand="0" string="Group by">
<filter group_by="group_by_model" string="Model" context="{'group_by':'model'}"/>
<field name="model"/>
<group expand="1" string="Group By">
<filter name="model" string="Model" context="{'group_by':'model'}"/>
</group>
</search>
</field>
@ -66,7 +62,7 @@
<menuitem action="action_view_tracking_changes"
id ="menu_action_view_tracking_changes"
name="Improved tracking values"
name="Improved Tracking Values"
parent="base.menu_email"
sequence="10"
/>