Skip to content

Commit

Permalink
[MIG] dms_attachment_link: Migration to 17.0
Browse files Browse the repository at this point in the history
TT50055
  • Loading branch information
victoralmau committed Oct 9, 2024
1 parent 5bb5f5c commit 883243c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 40 deletions.
2 changes: 1 addition & 1 deletion dms/views/dms_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
<field name="arch" type="xml">
<kanban position="attributes">
<attribute name="banner_route" />
<attribute name="class">o_kanban_mobile</attribute>
<attribute name="class">o_kanban_mobile mk_file_kanban_view</attribute>
</kanban>
<xpath expr="//div[hasclass('oe_kanban_bottom_right')]" position="replace">
<div class="oe_kanban_bottom_right" />
Expand Down
2 changes: 1 addition & 1 deletion dms_attachment_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Dms Attachment Link",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Document Management",
"website": "https://github.com/OCA/dms",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
52 changes: 21 additions & 31 deletions dms_attachment_link/static/src/js/dms_attachment_link.esm.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
/** @odoo-module **/

import {registerPatch} from "@mail/model/model_core";
import {Chatter} from "@mail/core/web/chatter";
import {patch} from "@web/core/utils/patch";

registerPatch({
name: "AttachmentBoxView",
recordMethods: {
_onAddDmsFile() {
this.env.services.action.doAction(
"dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
{
additionalContext: {
active_id: this.chatter.thread.id,
active_ids: [this.chatter.thread.id],
active_model: this.chatter.threadModel,
},
onClose: this._onAddedDmsFile.bind(this),
}
);
},
_onAddedDmsFile() {
this.chatter.refresh();
},
patch(Chatter.prototype, {
_onAddDmsFile(event) {
event.preventDefault();
event.stopPropagation();
this.action.doAction(
"dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
{
additionalContext: {
active_id: this.state.thread.id,
active_ids: [this.state.thread.id],
active_model: this.state.thread.model,
},
onClose: async () => {
await this._onAddedDmsFile();
},
}
);
},
});

registerPatch({
name: "Chatter",
recordMethods: {
/**
* Handles click on the attach button.
*/
async onClickButtonAddAttachments() {
await this.onClickButtonToggleAttachments();
},
async _onAddedDmsFile() {
this.reloadParentView();
},
});
11 changes: 4 additions & 7 deletions dms_attachment_link/static/src/xml/chatter.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2023 Tecnativa - Víctor Martínez
<!-- Copyright 2023-2024 Tecnativa - Víctor Martínez
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates id="template" xml:space="preserve">
<t t-inherit="mail.AttachmentBox" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_AttachmentBox_content')]" position="attributes">
<attribute name="class" add="d-block text-center" separator=" " />
</xpath>
<xpath expr="//button[hasclass('o_AttachmentBox_buttonAdd')]" position="after">
<t t-inherit="mail.Chatter" t-inherit-mode="extension">
<xpath expr="//FileUploader//button" position="after">
<button
class="o_add_dms_file_button btn btn-link"
type="button"
t-on-click.stop.prevent="attachmentBoxView._onAddDmsFile"
t-on-click="_onAddDmsFile"
>
<i class="fa fa-plus-square" />
Add DMS File
Expand Down

0 comments on commit 883243c

Please sign in to comment.