forked from OCA/social
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.0] Improving the mail tracking value (OCA#170)
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.
- Loading branch information
Showing
10 changed files
with
505 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============================== | ||
Tracking value change improved | ||
============================== | ||
|
||
This module extends the mail_tracking_value functionality that records | ||
value changes on predefined fields. | ||
It adds support for many2many and one2many fields, which are not handled | ||
well by default. | ||
It also implements a new view (little bit more user friendly than the | ||
existing one) to watch for changes | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
#. Just install the module | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
# No configuration is necessary | ||
|
||
Usage | ||
===== | ||
|
||
To access the new view displaying value changes : | ||
|
||
Settings -> Technical -> Improved tracking values | ||
|
||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* Improve rendering of values depending of type using qweb widgets | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/mail_improved_tracking_value/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Thierry Ducrest <thierry.ducrest@camptocamp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 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', | ||
'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', | ||
'depends': [ | ||
'base', | ||
'mail' | ||
], | ||
'data': [ | ||
'views/mail_tracking_value.xml' | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
88 changes: 88 additions & 0 deletions
88
mail_improved_tracking_value/i18n/mail_improved_tracking_value.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mail_improved_tracking_value | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_form_view | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list | ||
msgid "Field changed" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_form_view | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list | ||
msgid "For" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list_filter | ||
msgid "Group by" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.menu,name:mail_improved_tracking_value.menu_action_view_tracking_changes | ||
msgid "Improved tracking values" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model,name:mail_improved_tracking_value.model_mail_tracking_value | ||
msgid "Mail Tracking Value" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model.fields,field_description:mail_improved_tracking_value.field_mail_tracking_value_record_name | ||
msgid "Message Record Name" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model.fields,field_description:mail_improved_tracking_value.field_mail_tracking_value_model | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list_filter | ||
msgid "Model" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model.fields,help:mail_improved_tracking_value.field_mail_tracking_value_record_name | ||
msgid "Name get of the related document." | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model.fields,field_description:mail_improved_tracking_value.field_mail_tracking_value_new_value_formatted | ||
msgid "New value" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.model.fields,field_description:mail_improved_tracking_value.field_mail_tracking_value_old_value_formatted | ||
msgid "Old value" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list | ||
msgid "On" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list_filter | ||
msgid "Search" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.ui.view,arch_db:mail_improved_tracking_value.tracking_change_list | ||
msgid "Tracking change list" | ||
msgstr "" | ||
|
||
#. module: mail_improved_tracking_value | ||
#: model:ir.actions.act_window,name:mail_improved_tracking_value.action_view_tracking_changes | ||
msgid "View last tracked changes" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import mail_tracking_value |
78 changes: 78 additions & 0 deletions
78
mail_improved_tracking_value/models/mail_tracking_value.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import json | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
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') | ||
|
||
@api.depends('new_value_char', 'new_value_integer', 'new_value_float', | ||
'new_value_text', 'new_value_datetime', 'new_value_monetary', | ||
'old_value_char', 'old_value_integer', 'old_value_float', | ||
'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 | ||
record.old_value_formatted = record.old_value_char | ||
elif record.field_type == 'integer': | ||
record.new_value_formatted = str(record.new_value_integer) | ||
record.old_value_formatted = str(record.old_value_integer) | ||
elif record.field_type == 'float': | ||
record.new_value_formatted = str(record.new_value_float) | ||
record.old_value_formatted = str(record.old_value_float) | ||
elif record.field_type == 'monetary': | ||
record.new_value_formatted = str(record.new_value_monetary) | ||
record.old_value_formatted = str(record.old_value_monetary) | ||
elif record.field_type == 'datetime': | ||
record.new_value_formatted = str(record.new_value_datetime) | ||
record.old_value_formatted = str(record.old_value_datetime) | ||
elif record.field_type == 'text': | ||
record.new_value_formatted = record.new_value_text | ||
record.old_value_formatted = record.old_value_text | ||
|
||
@api.model | ||
def create_tracking_values(self, old_value, new_value, col_name, col_info): | ||
""" Add tacking capabilities for many2many and one2many fields """ | ||
if col_info['type'] in ('many2many', 'one2many'): | ||
|
||
def get_values(source, prefix): | ||
if source: | ||
names = ', '.join(source.mapped('display_name')) | ||
json_ids = json.dumps(source.ids) | ||
else: | ||
names = '' | ||
json_ids = json.dumps([]) | ||
return { | ||
'{}_value_char'.format(prefix): names, | ||
'{}_value_text'.format(prefix): json_ids, | ||
} | ||
|
||
values = { | ||
'field': col_name, | ||
'field_desc': col_info['string'], | ||
'field_type': col_info['type'], | ||
} | ||
values.update(get_values(old_value, 'old')) | ||
values.update(get_values(new_value, 'new')) | ||
return values | ||
else: | ||
return super(MailTrackingValue, self).create_tracking_values( | ||
old_value, new_value, | ||
col_name, col_info | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_improved_tracking_value |
Oops, something went wrong.