Monday, June 17, 2024
2 changes
Code cleanup and technical improvements
This update streamlines how chat, WhatsApp, VoIP, documents, and helpdesk live chat data is prepared before being sent to the browser. It reduces repeated information, which can improve responsiveness and make future performance improvements easier.
Original PR description
This will reduce data transferred to the client and processed in JS when the same member was appearing multiple times. This also makes more clear what is transferred by avoiding nested values. Note: this is a first step, many format methods still have to be converted, in particular the one from member, which will then allow converting the one from partner, which will significantly reduce duplicate data send for the current partner (one duplicate per open channel). Formatting code eventually becomes simpler too, by always adding data to the store rather than updating pre-existing dict manually. Part of task-3605717 https://github.com/odoo/odoo/pull/169484
This update reorganizes how Odoo marks records' main attachments, moving model-specific logic to the relevant business records instead of the attachment layer. It improves code separation and batch processing, helping modules like invoice extraction, expenses, recruitment, documents, and localization behave more consistently.
Original PR description
Currently updating main attachment is done a bit through two methods * one model-based "_message_set_main_attachment_id"; * one attachment-based "register_as_main_attachment"; Attachment-based method is overridden in various addons to implement model specific behavior. This makes no sense: model-specific behaviors should be implemented on the right model. With this commit, "register_as_main_attachment" now correctly calls "_message_set_main_attachment_id", which is the method to override when adding model-specific behaviors. "register_as_main_attachment" still exists notably due to attachment viewer that takes an attachment as main record. It now delegates the model update to the model itself, leading to clearer code separation. Various calls and main attachment update are updated accordingly. Finally we also make 'register_at_main_attachment' batch-enabled. It groups attachments per model, allowing to benefit from cache. Task-3599245