From ea1eca22d3aae003cffeb985db32057070660809 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 31 Dec 2016 14:07:56 +0100 Subject: [PATCH 1/4] [FIX] account: Don't trigger twice the reconcile_ref compute method. Was PR #14892 Both store triggers on reconcile_ref are triggered by the same condition, but seen on 2 tables different, but they always happen together, so no need for both. On regular Odoo, the only problem is the performance: the write operation is performed twice, but on a system with connector or other parallelization technology, this provokes lot of concurrency problems. --- addons/account/account_move_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 982b1d8c23b..796496e97f5 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -479,7 +479,7 @@ class account_move_line(osv.osv): 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2, copy=False), 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2, copy=False), 'reconcile_ref': fields.function(_get_reconcile, type='char', string='Reconcile Ref', oldname='reconcile', store={ - 'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['reconcile_id','reconcile_partial_id'], 50),'account.move.reconcile': (_get_move_from_reconcile, None, 50)}), + 'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['reconcile_id','reconcile_partial_id'], 50)}), 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')), 'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount in Currency', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."), 'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."), From 1e8d9e1c64791da12a26a554564e7cd6031a62f4 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 17 Jan 2017 11:21:17 +0100 Subject: [PATCH 2/4] [REV] account: revert fix made on ea1eca2. When an account.move.reconcile was unlinked, the reconcile_ref on the related move lines was no longer cleared. --- addons/account/account_move_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 796496e97f5..982b1d8c23b 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -479,7 +479,7 @@ class account_move_line(osv.osv): 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2, copy=False), 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2, copy=False), 'reconcile_ref': fields.function(_get_reconcile, type='char', string='Reconcile Ref', oldname='reconcile', store={ - 'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['reconcile_id','reconcile_partial_id'], 50)}), + 'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['reconcile_id','reconcile_partial_id'], 50),'account.move.reconcile': (_get_move_from_reconcile, None, 50)}), 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')), 'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount in Currency', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."), 'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."), From bbbf317fd38c367c71df1ab2469277573df801c9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 17 Jan 2017 11:47:48 +0100 Subject: [PATCH 3/4] [FIX] l10n_be: VAT Declaration The VAT declaration produces an error when uploaded to the official website. Although the structure is correct, the "Representative" and the "Declarant" contain the same information, which is not consistent. opw-702066 --- .../l10n_be/wizard/l10n_be_account_vat_declaration.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py index 0583d6787f0..191d7fe9320 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py @@ -135,16 +135,6 @@ class l10n_be_vat_declaration(osv.osv_memory): data_of_file = """ - - %(only_vat)s - %(cmpny_name)s - %(address)s - %(post_code)s - %(city)s - %(country_code)s - %(email)s - %(phone)s - %(only_vat)s From 8f1c2bfc9183d73549d3cf3a771edf2232eeeb12 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 17 Jan 2017 14:14:16 +0100 Subject: [PATCH 4/4] [FIX] mail: force mail.message linked record invalidation --- addons/mail/mail_message.py | 17 +++++++++++++++++ addons/mail/tests/test_mail_message.py | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 7e09fa4eb81..ac68a4bfd7f 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -791,6 +791,13 @@ class mail_message(osv.Model): message_id = tools.generate_tracking_message_id('private') return message_id + @api.multi + def _invalidate_documents(self): + """ Invalidate the cache of the documents followed by ``self``. """ + for record in self: + if record.res_id: + self.env[record.model].invalidate_cache(ids=[record.res_id]) + def create(self, cr, uid, values, context=None): context = dict(context or {}) default_starred = context.pop('default_starred', False) @@ -805,6 +812,7 @@ class mail_message(osv.Model): values['record_name'] = self._get_record_name(cr, uid, values, context=context) newid = super(mail_message, self).create(cr, uid, values, context) + self.browse(cr, uid, newid, context)._invalidate_documents() self._notify(cr, uid, newid, context=context, force_send=context.get('mail_notify_force_send', True), @@ -826,6 +834,14 @@ class mail_message(osv.Model): res = super(mail_message, self).read(cr, uid, ids, fields=fields, context=context, load=load) return res + @api.multi + def write(self, vals): + if 'model' in vals or 'res_id' in vals: + self._invalidate_documents() + res = super(mail_message, self).write(vals) + self._invalidate_documents() + return res + def unlink(self, cr, uid, ids, context=None): # cascade-delete attachments that are directly attached to the message (should only happen # for mail.messages that act as parent for a standalone mail.mail record). @@ -837,6 +853,7 @@ class mail_message(osv.Model): attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) + self.browse(cr, uid, ids, context)._invalidate_documents() return super(mail_message, self).unlink(cr, uid, ids, context=context) #------------------------------------------------------ diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py index e6e78fe9254..8cad520ce8b 100644 --- a/addons/mail/tests/test_mail_message.py +++ b/addons/mail/tests/test_mail_message.py @@ -445,3 +445,8 @@ class TestMailMessage(TestMail): {'subject': 'Subject', 'body': 'Body text'}, {'default_composition_mode': 'comment', 'default_parent_id': pigs_msg_id}) mail_compose.send_mail(cr, user_raoul_id, [compose_id]) + + def test_60_cache_invalidation(self): + msg_cnt = len(self.group_pigs.message_ids) + self.group_pigs.message_post(body='Hi!', subject='test') + self.assertEqual(len(self.group_pigs.message_ids), msg_cnt + 1)