Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1990 Переглядів
  1. Base env : odoo17, windows 10
  2. I'm coding a new module, a new model , trying to diplay page fields changed history by inheriting the [mail] models:
     _inherit = ['mail.thread', 'mail.activity.mixin']
  3. the attachment field is defined as :
    op_contract_attachment_ids = fields.Many2many('ir.attachment', string="attach files", copy=False, tracking=False)
  4. "Access Denied by record rules for operation:...." pops up when an other user tries to open a newly created record with an attachment file, even though I added the user to the "Followers".
  5. In the create user's page, the attachment file isn't added to the message history column in the right part of the page when the record is newly created, and it is ok as expected.
  6. But, when the record is updated (delete the old attachment file and add a new one),the page can be opened by an other user without error message disregarding the login user is in the followers or not.
  7. If a new file is added without removing the old attachment file, the page is still can NOT be opened by an other user.
  8. After the page was edited and commited, the attachment files updated will be displayed in the message history column in the right part of the page. It seems like that the "tracking=False" in the field definition was disregarded.
  9. The newly created record CAN be opened without displaying the attachment filed in the page by an user who has NO access right to the field. I think this is because that I defined the attachment filed with groups specified in the XML file as:
  10. For the user who has no right to access to the attachment field:
    1. if a new file is added without removing the old one, he CAN NOT open the page
    2. if a new file is added with removing the old one, he can open the page, even though he is not a follower.
  11. In the "10.b" above, the attachment file field is not displayed in the page main body according to the "groups" specified. BUT the attachment file is displayed in the message history column in the right part of the page. And this is not  appreciated, because that user is NOT expected to see the attachment file.
  12. My ultimate objective is :
    1. Users in special groups(specified in secrurity.xml or in setting page) can open the newly created record.
    2. In the message history column, I need to control the attachment file displaying or not according to the login user's rights through system security settings or python code/xml  based logic control.
    3. In the message history column, the user who has no access rights to the attachment file, he can read other messages yet.
    4. If the attachment file update info is included in one message record, the user who has no access right to the attachment file can also read the rest part of the message record except the info about the attachment file field.

How should I do ?

Thanks a lot!


31 July, 2024



Аватар
Відмінити
Найкраща відповідь

If you still want to use the widget try to add _mail_post_access = 'read' to model like this


I test in holiday module it like this

Аватар
Відмінити
Автор Найкраща відповідь

hi,every one,It seems like that the problem comes from the widget many2many_binary.

when I use the default view of ir.attachment without the widget=many2many_binary, everything is going well, the display, the rights, etc, except the view looks like a bit some kind of not so odoo... anyway logic is NO1.

I have been suffered from this problem for more than 24*3 hours. Fortunately,the answer came out after I posted this problem here.

Hope this info could help those who has the similar problems.

Thank you!!!

Аватар
Відмінити
Автор

to:Dương Nguyễn
Thanks you very much for your reply.
I tried _mail_post_access = 'read',page openning error fixed, but the attachment file is still displayed in the message history column although the field property is set as "tracking=False".

Автор

to:Dương Nguyễn
Thanks you very much for your reply.
I can't reply to your comment, I do not know why. Maybe because I have not enough karma.
I tried _mail_post_access = 'read',page openning error fixed, but the attachment file is still displayed in the message history column although the field property is set as "tracking=False".

You 're welcome
By default many2many field has tracking = False already

Автор

Thank you !
I have checked many2many_binay widget in more than 3 modules,setting tracking = False, and the attached files are all sent to the msg tracker. I do not know why.

Check my edited answer , i have tested in hr_holiday module and it only has attached file in the icon not in the chatter

Related Posts Відповіді Переглядів Дія
0
черв. 20
5779
0
жовт. 20
5147
0
черв. 25
305
0
січ. 25
1408
0
січ. 25
1429