From 152ced4a89855e7642148c406ca374ece3a58cec Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 11 Jul 2014 12:21:20 +0600 Subject: [PATCH 01/14] new module mail_partner_lang --- __init__.py | 1 + __openerp__.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 __init__.py create mode 100644 __openerp__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..bff786c --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +import models diff --git a/__openerp__.py b/__openerp__.py new file mode 100644 index 0000000..269dcde --- /dev/null +++ b/__openerp__.py @@ -0,0 +1,13 @@ +{ + 'name' : 'Use partner language in mail', + 'version' : '1.0.0', + 'author' : 'Ivan Yelizariev', + 'category' : 'Mail', + 'website' : 'https://it-projects.info', + + 'depends' : ['mail'], + 'data':[], + 'installable': True, + 'description': ''' + ''', +} From 68ccc18cf06b87f9940716d60e5165a16e8f035c Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 11 Jul 2014 12:21:42 +0600 Subject: [PATCH 02/14] copy-paste code from mail_thread.py --- models.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 models.py diff --git a/models.py b/models.py new file mode 100644 index 0000000..71db677 --- /dev/null +++ b/models.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +from openerp.osv import osv,fields +from openerp import SUPERUSER_ID + +class mail_thread(osv.Model): + _inherit = "mail.thread" + + def message_track(self, cr, uid, ids, tracked_fields, initial_values, context=None): + + def convert_for_display(value, col_info): + if not value and col_info['type'] == 'boolean': + return 'False' + if not value: + return '' + if col_info['type'] == 'many2one': + return value.name_get()[0][1] + if col_info['type'] == 'selection': + return dict(col_info['selection'])[value] + return value + + def format_message(message_description, tracked_values): + message = '' + if message_description: + message = '%s' % message_description + for name, change in tracked_values.items(): + message += '
    • %s: ' % change.get('col_info') + if change.get('old_value'): + message += '%s → ' % change.get('old_value') + message += '%s
' % change.get('new_value') + return message + + if not tracked_fields: + return True + + for browse_record in self.browse(cr, uid, ids, context=context): + initial = initial_values[browse_record.id] + changes = set() + tracked_values = {} + + # generate tracked_values data structure: {'col_name': {col_info, new_value, old_value}} + for col_name, col_info in tracked_fields.items(): + initial_value = initial[col_name] + record_value = getattr(browse_record, col_name) + + if record_value == initial_value and getattr(self._all_columns[col_name].column, 'track_visibility', None) == 'always': + tracked_values[col_name] = dict(col_info=col_info['string'], + new_value=convert_for_display(record_value, col_info)) + elif record_value != initial_value and (record_value or initial_value): # because browse null != False + if getattr(self._all_columns[col_name].column, 'track_visibility', None) in ['always', 'onchange']: + tracked_values[col_name] = dict(col_info=col_info['string'], + old_value=convert_for_display(initial_value, col_info), + new_value=convert_for_display(record_value, col_info)) + if col_name in tracked_fields: + changes.add(col_name) + if not changes: + continue + + # find subtypes and post messages or log if no subtype found + subtypes = [] + for field, track_info in self._track.items(): + if field not in changes: + continue + for subtype, method in track_info.items(): + if method(self, cr, uid, browse_record, context): + subtypes.append(subtype) + + posted = False + for subtype in subtypes: + subtype_rec = self.pool.get('ir.model.data').xmlid_to_object(cr, uid, subtype, context=context) + if not (subtype_rec and subtype_rec.exists()): + _logger.debug('subtype %s not found' % subtype) + continue + message = format_message(subtype_rec.description if subtype_rec.description else subtype_rec.name, tracked_values) + self.message_post(cr, uid, browse_record.id, body=message, subtype=subtype, context=context) + posted = True + if not posted: + message = format_message('', tracked_values) + self.message_post(cr, uid, browse_record.id, body=message, context=context) + return True From 818e88386f2a682a36b4f631a6c17ff0b467d3c6 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 11 Jul 2014 12:43:49 +0600 Subject: [PATCH 03/14] update lang context to partner value --- models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models.py b/models.py index 71db677..23c4406 100644 --- a/models.py +++ b/models.py @@ -33,6 +33,10 @@ class mail_thread(osv.Model): return True for browse_record in self.browse(cr, uid, ids, context=context): + p = getattr(browse_record, 'partner_id', None) + if p: + browse_record._context.update({'lang':p.lang}) + initial = initial_values[browse_record.id] changes = set() tracked_values = {} From 776b783247e9bd808eab32184cb1d0b204ee4722 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Thu, 17 Jul 2014 20:10:13 +0600 Subject: [PATCH 04/14] [FIX] colulmn name was not translated --- models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models.py b/models.py index 23c4406..1836778 100644 --- a/models.py +++ b/models.py @@ -5,7 +5,7 @@ from openerp import SUPERUSER_ID class mail_thread(osv.Model): _inherit = "mail.thread" - def message_track(self, cr, uid, ids, tracked_fields, initial_values, context=None): + def message_track(self, cr, uid, ids, tracked_fields, initial_values, context={}): def convert_for_display(value, col_info): if not value and col_info['type'] == 'boolean': @@ -32,6 +32,8 @@ class mail_thread(osv.Model): if not tracked_fields: return True + update_fields = [f for f in tracked_fields] + for browse_record in self.browse(cr, uid, ids, context=context): p = getattr(browse_record, 'partner_id', None) if p: @@ -41,6 +43,9 @@ class mail_thread(osv.Model): changes = set() tracked_values = {} + # update translation + tracked_fields = self._get_tracked_fields(cr, uid, update_fields, browse_record._context) + # generate tracked_values data structure: {'col_name': {col_info, new_value, old_value}} for col_name, col_info in tracked_fields.items(): initial_value = initial[col_name] From 95da5bb69865ea6910a86ce67e3827e57cbe4e1e Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Thu, 19 Feb 2015 19:36:02 +0200 Subject: [PATCH 05/14] new website https://yelizariev.github.io/ --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 269dcde..01c8628 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -3,7 +3,7 @@ 'version' : '1.0.0', 'author' : 'Ivan Yelizariev', 'category' : 'Mail', - 'website' : 'https://it-projects.info', + 'website' : 'https://yelizariev.github.io', 'depends' : ['mail'], 'data':[], From b18ca4cab031991584579601aa218872c5892d85 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 10 Apr 2015 15:23:44 +0200 Subject: [PATCH 06/14] [DOC] add fixme note --- README.rst | 4 ++++ __openerp__.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..6e16513 --- /dev/null +++ b/README.rst @@ -0,0 +1,4 @@ +Use partner language in mail +============================ + +FIXME: there is issue with frozen dict in new odoo. diff --git a/__openerp__.py b/__openerp__.py index 01c8628..a0b06ea 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -8,6 +8,4 @@ 'depends' : ['mail'], 'data':[], 'installable': True, - 'description': ''' - ''', } From 2fb04d592f4cf70f5344b50b26058cf4b005f6c7 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Thu, 2 Jul 2015 16:35:12 +0500 Subject: [PATCH 07/14] [DOC] add icon --- static/description/icon.png | Bin 0 -> 2140 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/description/icon.png diff --git a/static/description/icon.png b/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..79f7d8fe294f838cf2996940c40dc08dde60642f GIT binary patch literal 2140 zcmV-i2&4CjP)=D+Wys1fe}G$Q#Z2832St25n<}h#$%L7sUBHn zgVlR~4gtNOs+KA#@5q|?_&of{fCW3h;+eI-@is^))^C>Ap=O06Yq-$?c7APo?&VKv z))(zizAhAwtYInZ&irDhM>SGBFM>?d${LzoxNVMo=er+dj|dVX82(itvPy&nJI7R} zxal|{b!VXeY~=?NW24HG!g#W&q%^mz9C_k)O~vB$l!nR>c7Azkc41B0?h`G%re>$6 zR3XK_wP$L$`wA`+vfQ*It2kJ&bC8N#=Y*z`?T#poH4<6rMKBSth@G$Anh#P6geeX3 z66#s7^ZuFn%%U9v!&L5`a;i`|jy4C6tV1;wvTsBRf(1LrR7N-{7FL;Ru=vP|@loCg zW(jHMC_PwJ+DqF+1@u$zm8o8m$Y1m0V>0T?5;C37EIq_^W|6qn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kM2p`;8cbRHVRCk`&s%0t^5+Kg1eL SSUIi$0000 Date: Sun, 27 Sep 2015 10:20:30 +0500 Subject: [PATCH 08/14] [DOC] add IT-Projects LLC to authors --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index a0b06ea..975dcd3 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -1,7 +1,7 @@ { 'name' : 'Use partner language in mail', 'version' : '1.0.0', - 'author' : 'Ivan Yelizariev', + 'author' : 'IT-Projects LLC, Ivan Yelizariev', 'category' : 'Mail', 'website' : 'https://yelizariev.github.io', From 84c08036aacd9fe903ea367d5d4c45b321eb66e0 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Sun, 27 Sep 2015 10:22:56 +0500 Subject: [PATCH 09/14] [DOC] add IT-Projects LLC to authors --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index a0b06ea..975dcd3 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -1,7 +1,7 @@ { 'name' : 'Use partner language in mail', 'version' : '1.0.0', - 'author' : 'Ivan Yelizariev', + 'author' : 'IT-Projects LLC, Ivan Yelizariev', 'category' : 'Mail', 'website' : 'https://yelizariev.github.io', From 736bba2624f446b5f0dc56878909eaee85107973 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 16 Oct 2015 13:07:01 +0500 Subject: [PATCH 10/14] mark unported modules as non-installable --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 975dcd3..777417b 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -7,5 +7,5 @@ 'depends' : ['mail'], 'data':[], - 'installable': True, + 'installable': False, } From 4350d248d834e2d33e5c41ee9b4479806006e4b2 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Tue, 3 Nov 2015 10:22:20 +0500 Subject: [PATCH 11/14] [DOC] add license tag --- __openerp__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/__openerp__.py b/__openerp__.py index 975dcd3..958ad69 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -2,6 +2,7 @@ 'name' : 'Use partner language in mail', 'version' : '1.0.0', 'author' : 'IT-Projects LLC, Ivan Yelizariev', + 'license': 'LGPL-3', 'category' : 'Mail', 'website' : 'https://yelizariev.github.io', From 22c496c3de23522a215b90630542060b1e3178a6 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 9 Nov 2015 11:26:31 +0500 Subject: [PATCH 12/14] update license to GPL-3 --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 958ad69..7c65ca4 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -2,7 +2,7 @@ 'name' : 'Use partner language in mail', 'version' : '1.0.0', 'author' : 'IT-Projects LLC, Ivan Yelizariev', - 'license': 'LGPL-3', + 'license': 'GPL-3', 'category' : 'Mail', 'website' : 'https://yelizariev.github.io', From 4ac363e4e807b0db2d012def90b8663234544c75 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 9 Nov 2015 11:36:05 +0500 Subject: [PATCH 13/14] Revert "update license to GPL-3" This reverts commit 6157ee932163b56a3a0ad3a64cefb93e190c5c1d. Conflicts: _web_last_viewed_records/__openerp__.py itprojects_sale/__openerp__.py itprojects_website/__openerp__.py mail_delete_access_link/__openerp__.py mail_delete_sent_by_footer/__openerp__.py money_for/__openerp__.py --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 1cd112a..56d3240 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -2,7 +2,7 @@ 'name' : 'Use partner language in mail', 'version' : '1.0.0', 'author' : 'IT-Projects LLC, Ivan Yelizariev', - 'license': 'GPL-3', + 'license': 'LGPL-3', 'category' : 'Mail', 'website' : 'https://yelizariev.github.io', From 6e63cb9747dc9ea5e0dc3a66ad628b320e774bce Mon Sep 17 00:00:00 2001 From: Ildar Nasyrov Date: Sun, 27 Mar 2016 16:27:46 +0500 Subject: [PATCH 14/14] [MOV] module -- mail_partner_lang --- README.rst => mail_partner_lang/README.rst | 0 __init__.py => mail_partner_lang/__init__.py | 0 __openerp__.py => mail_partner_lang/__openerp__.py | 0 models.py => mail_partner_lang/models.py | 0 .../static}/description/icon.png | Bin 5 files changed, 0 insertions(+), 0 deletions(-) rename README.rst => mail_partner_lang/README.rst (100%) rename __init__.py => mail_partner_lang/__init__.py (100%) rename __openerp__.py => mail_partner_lang/__openerp__.py (100%) rename models.py => mail_partner_lang/models.py (100%) rename {static => mail_partner_lang/static}/description/icon.png (100%) diff --git a/README.rst b/mail_partner_lang/README.rst similarity index 100% rename from README.rst rename to mail_partner_lang/README.rst diff --git a/__init__.py b/mail_partner_lang/__init__.py similarity index 100% rename from __init__.py rename to mail_partner_lang/__init__.py diff --git a/__openerp__.py b/mail_partner_lang/__openerp__.py similarity index 100% rename from __openerp__.py rename to mail_partner_lang/__openerp__.py diff --git a/models.py b/mail_partner_lang/models.py similarity index 100% rename from models.py rename to mail_partner_lang/models.py diff --git a/static/description/icon.png b/mail_partner_lang/static/description/icon.png similarity index 100% rename from static/description/icon.png rename to mail_partner_lang/static/description/icon.png