diff options
| author | Yannick Tivisse <yti@odoo.com> | 2019-03-26 12:51:22 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2019-03-29 12:00:25 +0000 |
| commit | 62c9dedafda0cbdc618641eaa80c49535ab0b5f6 (patch) | |
| tree | f1e8836bd62c4337b3c8ee30bcdf84ffd005b6ee /addons | |
| parent | 97315af9467fba4312bf15cf995be519759655d3 (diff) | |
[IMP] base: Remove useless ACL rules
Now that portal users don't have access to the backend, it doesn't make
sense to give the read access on attachments, as this is the role of
the specific controllers to provide this access according to the business
logic.
For the record, these rules have been introduced at:
https://github.com/odoo/odoo/commit/61065b6d04248aa496765e1035c4c90cbdc38de7
https://github.com/odoo/odoo/commit/f3fa266d115ac9d4723164af10f8dee40821b290
closes odoo/odoo#32134
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/mail/models/ir_attachment.py | 2 | ||||
| -rw-r--r-- | addons/mail/models/mail_thread.py | 2 | ||||
| -rw-r--r-- | addons/test_mail/tests/test_odoobot.py | 7 | ||||
| -rw-r--r-- | addons/website_sale_digital/models/product.py | 8 |
4 files changed, 12 insertions, 7 deletions
diff --git a/addons/mail/models/ir_attachment.py b/addons/mail/models/ir_attachment.py index 4330059c495..31e59d680c9 100644 --- a/addons/mail/models/ir_attachment.py +++ b/addons/mail/models/ir_attachment.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import api, models class IrAttachment(models.Model): diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 79cfb230a6b..766d0a05d55 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -109,7 +109,7 @@ class MailThread(models.AbstractModel): message_has_error_counter = fields.Integer( 'Number of error', compute='_compute_message_has_error', help="Number of messages with delivery error") - message_attachment_count = fields.Integer('Attachment Count', compute='_compute_message_attachment_count') + message_attachment_count = fields.Integer('Attachment Count', compute='_compute_message_attachment_count', groups="base.group_user") message_main_attachment_id = fields.Many2one(string="Main Attachment", comodel_name='ir.attachment', index=True, copy=False) @api.one diff --git a/addons/test_mail/tests/test_odoobot.py b/addons/test_mail/tests/test_odoobot.py index 07cdfaa0d3a..900e7b62689 100644 --- a/addons/test_mail/tests/test_odoobot.py +++ b/addons/test_mail/tests/test_odoobot.py @@ -61,7 +61,12 @@ class TestOdoobot(BaseFunctionalTest, MockEmails, TestRecipients): answer=("attachment",) ) kwargs['body'] = '' - kwargs['attachment_ids'] = [1] + attachment = self.env['ir.attachment'].sudo(self.user_employee).create({ + 'datas': 'bWlncmF0aW9uIHRlc3Q=', + 'datas_fname': 'catalog.doc', + 'name': 'picture_of_your_dog.doc', + }) + kwargs['attachment_ids'] = [attachment.id] last_message = self.assertNextMessage( channel.message_post(**kwargs), sender=self.odoobot, diff --git a/addons/website_sale_digital/models/product.py b/addons/website_sale_digital/models/product.py index cfbd3c33918..23a2004ea22 100644 --- a/addons/website_sale_digital/models/product.py +++ b/addons/website_sale_digital/models/product.py @@ -41,11 +41,11 @@ class Product(models.Model): @api.multi def _compute_attachment_count(self): - IrAttachment = self.env['ir.attachment'] for product in self: - prod_tmpl_attach_count = IrAttachment.search_count([('res_model', '=', 'product.template'), ('res_id', 'in', product.product_tmpl_id.ids), ('product_downloadable', '=', True)]) - prod_attach_count = IrAttachment.search_count([('res_model', '=', 'product.product'), ('res_id', 'in', product.ids), ('product_downloadable', '=', True)]) - product.attachment_count = prod_tmpl_attach_count + prod_attach_count + product.attachment_count = self.env['ir.attachment'].search_count([ + '|', + ('res_model', '=', 'product.template'), ('res_id', '=', product.product_tmpl_id.id), ('product_downloadable', '=', True), + ('res_model', '=', 'product.product'), ('res_id', '=', product.id), ('product_downloadable', '=', True)]) @api.multi def action_open_attachments(self): |
