From 06e16d2b23bed0704f4c42718485c37d5e76e5cc Mon Sep 17 00:00:00 2001 From: PauBForgeFlow Date: Fri, 23 Feb 2024 12:02:35 +0100 Subject: [PATCH] [IMP] sign_oca: preview requests --- sign_oca/README.rst | 2 +- sign_oca/__manifest__.py | 1 + sign_oca/models/sign_oca_request.py | 12 +++++ sign_oca/static/description/index.html | 2 +- .../sign_oca_preview/sign_oca_preview.js | 51 +++++++++++++++++++ .../sign_oca_preview/sign_oca_preview.xml | 9 ++++ sign_oca/templates/assets.xml | 4 ++ sign_oca/views/sign_oca_request.xml | 2 + 8 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js create mode 100644 sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.xml diff --git a/sign_oca/README.rst b/sign_oca/README.rst index 65dd8de9..ebd1b1d4 100644 --- a/sign_oca/README.rst +++ b/sign_oca/README.rst @@ -7,7 +7,7 @@ Sign Oca !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:3ff934be62e6f7ee4854d30f51887bbbffb993780a9785c706a2bdd6d0a93005 + !! source digest: sha256:ad1ece32b73563316fb676d70390fd6aaff9ab6503019c8b20a42807b3f78b82 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/sign_oca/__manifest__.py b/sign_oca/__manifest__.py index 6137b980..0dea830f 100644 --- a/sign_oca/__manifest__.py +++ b/sign_oca/__manifest__.py @@ -29,6 +29,7 @@ "qweb": [ "static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml", "static/src/components/sign_oca_configure/sign_oca_configure.xml", + "static/src/components/sign_oca_preview/sign_oca_preview.xml", "static/src/components/sign_oca_pdf/sign_oca_pdf.xml", "static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml", "static/src/elements/elements.xml", diff --git a/sign_oca/models/sign_oca_request.py b/sign_oca/models/sign_oca_request.py index cf7bc16b..02e10b41 100644 --- a/sign_oca/models/sign_oca_request.py +++ b/sign_oca/models/sign_oca_request.py @@ -76,6 +76,18 @@ def _compute_next_item_id(self): record.signatory_data and max(record.signatory_data.keys()) or 0 ) + 1 + def preview(self): + self.ensure_one() + return { + "type": "ir.actions.client", + "tag": "sign_oca_preview", + "name": self.name, + "params": { + "res_model": self._name, + "res_id": self.id, + }, + } + def get_info(self): self.ensure_one() return { diff --git a/sign_oca/static/description/index.html b/sign_oca/static/description/index.html index cc6937de..2fd2bf5f 100644 --- a/sign_oca/static/description/index.html +++ b/sign_oca/static/description/index.html @@ -367,7 +367,7 @@

Sign Oca

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:3ff934be62e6f7ee4854d30f51887bbbffb993780a9785c706a2bdd6d0a93005 +!! source digest: sha256:ad1ece32b73563316fb676d70390fd6aaff9ab6503019c8b20a42807b3f78b82 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/sign Translate me on Weblate Try me on Runboat

This module allows to create documents for signature inside Odoo using OWL.

diff --git a/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js b/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js new file mode 100644 index 00000000..b37951d4 --- /dev/null +++ b/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js @@ -0,0 +1,51 @@ +odoo.define( + "sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js", + function (require) { + "use strict"; + + const {ComponentWrapper} = require("web.OwlCompatibility"); + const AbstractAction = require("web.AbstractAction"); + const Dialog = require("web.Dialog"); + const core = require("web.core"); + var ControlPanel = require("web.ControlPanel"); + const SignOcaPdfCommon = require("sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.js"); + const _t = core._t; + + const SignOcaPreviewAction = AbstractAction.extend({ + hasControlPanel: true, + init: function (parent, action) { + this._super.apply(this, arguments); + this.model = + (action.params.res_model !== undefined && + action.params.res_model) || + action.context.params.res_model; + this.res_id = + (action.params.res_id !== undefined && action.params.res_id) || + action.context.params.id; + }, + async start() { + await this._super(...arguments); + this.component = new ComponentWrapper(this, SignOcaPdfCommon, { + model: this.model, + res_id: this.res_id, + }); + this.$el.addClass("o_sign_oca_action"); + return this.component.mount(this.$(".o_content")[0]); + }, + getState: function () { + var result = this._super(...arguments); + result = _.extend({}, result, { + res_model: this.model, + res_id: this.res_id, + }); + return result; + }, + }); + + core.action_registry.add("sign_oca_preview", SignOcaPreviewAction); + + return { + SignOcaPreviewAction, + }; + } +); diff --git a/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.xml b/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.xml new file mode 100644 index 00000000..5d7e3752 --- /dev/null +++ b/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.xml @@ -0,0 +1,9 @@ + + + + diff --git a/sign_oca/templates/assets.xml b/sign_oca/templates/assets.xml index d1d7f41d..0ab8791d 100644 --- a/sign_oca/templates/assets.xml +++ b/sign_oca/templates/assets.xml @@ -39,6 +39,10 @@ type="text/javascript" src="/sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.js" /> +