[MERGE] forward port branch 8.0 up to 8f1c2bfc91
This commit is contained in:
@@ -136,16 +136,6 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
|
||||
data_of_file = """<?xml version="1.0"?>
|
||||
<ns2:VATConsignment xmlns="http://www.minfin.fgov.be/InputCommon" xmlns:ns2="http://www.minfin.fgov.be/VATConsignment" VATDeclarationsNbr="1">
|
||||
<ns2:Representative>
|
||||
<RepresentativeID identificationType="NVAT" issuedBy="%(issued_by)s">%(only_vat)s</RepresentativeID>
|
||||
<Name>%(cmpny_name)s</Name>
|
||||
<Street>%(address)s</Street>
|
||||
<PostCode>%(post_code)s</PostCode>
|
||||
<City>%(city)s</City>
|
||||
<CountryCode>%(country_code)s</CountryCode>
|
||||
<EmailAddress>%(email)s</EmailAddress>
|
||||
<Phone>%(phone)s</Phone>
|
||||
</ns2:Representative>
|
||||
<ns2:VATDeclaration SequenceNumber="1" DeclarantReference="%(send_ref)s">
|
||||
<ns2:Declarant>
|
||||
<VATNumber xmlns="http://www.minfin.fgov.be/InputCommon">%(only_vat)s</VATNumber>
|
||||
|
||||
@@ -802,6 +802,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)
|
||||
@@ -816,6 +823,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),
|
||||
@@ -837,6 +845,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).
|
||||
@@ -848,6 +864,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)
|
||||
|
||||
#------------------------------------------------------
|
||||
|
||||
@@ -444,3 +444,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)
|
||||
|
||||
Reference in New Issue
Block a user