Commit Graph
5 Commits
Author SHA1 Message Date
Alexandre Kühn 22ed4ec268 [REF] mail: rename commands in discuss model data
Relational data in server formatter are:
- for one relation: None/false or object
- for many relations: list of objects or list of commands

The commands were:
- 'insert': to add a new item in a relational field
- 'unlink': to remove an item from a relational field
- 'insert-and-unlink': to remove an item from a relational field
- 'clear': to remove all items from relational field

There was a slight nuance between 'unlink' and 'insert-and-unlink'
at some point, but it becomes irrelevant with current code of model.
The name of the commands were hard to grasp what they actually mean
for the many relations.

This commit improves it by renaming 'insert' by 'ADD' and the 2
'unlink' commands by 'DELETE'. This makes it more apparent that
the data in 'ADD' refers to data of record to add in the relation,
while 'DELETE' refers to data of record to delete from the relation.
The 'clear' has been replaced by `False` value instead of a command.

Part-of: odoo/odoo#136308
2023-09-27 13:11:58 +00:00
Yolann Sabaux 71ed187223 [FIX] account: display pdf attachment
Steps to reproduce:
- Install l10n_mx modules
- Switch to MX company
- Create invoice and confirm it
- Send it to PAC in test environment (Process Now button)
- Click Send & Print button

Issue:
- XML Preview does not display, only shows the file name in the top right corner of the chatter.

Cause:
In l10n_mx_edi, when posting the invoice, the only attachment available is the xml sent to the government in `_message_set_main_attachment_id`.
Therefore the xml is set as the main attachment.
When clicking on "Send and Print", the pdf is generated but the main attachment is still the xml

Solution:
Redefine the main attachment everytime the the main attachment is an xml

Note:
- octet-stream have also been filtered out

opw-3085934

closes odoo/odoo#116784

X-original-commit: 48e6e81a47f5371f5985d135e56f39f445eb2854
Related: odoo/enterprise#38861
Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-28 13:43:57 +02:00
Thibault Delavallée 452ca009e3 [FIX] mail: allow to update main attachment
When replying on a document they cannot read (notably when being notified)
ACLs raise when trying to check if 'main_attachment_id' is already set before
updating it. This is fixed in this commit. This fixes the recently introduced
'test_post_wo_access' test that does not pass without this fix.

Note that the update of 'main_attachment_id' was already done in sudo. As all
read or update access is now done in sudo, better call the whole method as
sudo in 'message_post' and let '_message_set_main_attachment_id' works on
the given record set environment.

Task-3213982 (Mail: fix 'multi-company' post support)

X-original-commit: odoo/odoo@0375bb227a
Part-of: odoo/odoo#114511
2023-03-07 18:03:03 +01:00
Pierre-Yves Dufays ffd976cc69 [IMP] {test_}mail: make some improvements to the code, no functional changes
Some code cleanup done when moving the main attachment into its own mixin:
- improved docstring
- early returns
- code simplification
No functional changes should occur with this commit.

Task-2648976

Part-of: odoo/odoo#110734
2023-03-02 12:32:11 +01:00
Pierre-Yves Dufays f8c7f2e5bb [MOV] mail: move main attachment feature to mixin
Main attachment is quite costly and as it is implemented in mail.thread, is
present in most model. In order to improve performance, we remove it here from
mail.thread and add it, through a new mixin, only on models that actually use
that feature.

Technical note: with the current implementation, even if the font-end view
expect the model to implement the main attachment feature and the model
doesn't, it doesn't crash. Indeed, the main attachment on the front-end is only
used to know the first image to display in the image 'carousel' on the right
(widget rendered through the presence of the class o_attachment_preview). And
as 'register_as_main_attachment' of ir.attachment doesn't crash even if the
model doesn't support main attachment feature, the only consequence is that the
first image to display is not persisted (if you refresh after changing the main
attachment, it will get back to the previous one).

Task-2648976

Part-of: odoo/odoo#110734
2023-03-02 12:32:10 +01:00