Skip to content

Commit

Permalink
[IMP] sign_oca: preview requests
Browse files Browse the repository at this point in the history
  • Loading branch information
PauBForgeFlow committed Feb 23, 2024
1 parent 8272680 commit 06e16d2
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sign_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check warning on line 81 in sign_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_oca/models/sign_oca_request.py#L80-L81

Added lines #L80 - L81 were not covered by tests
"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 {
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sign Oca</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3ff934be62e6f7ee4854d30f51887bbbffb993780a9785c706a2bdd6d0a93005
!! source digest: sha256:ad1ece32b73563316fb676d70390fd6aaff9ab6503019c8b20a42807b3f78b82
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/14.0/sign_oca"><img alt="OCA/sign" src="https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sign-14-0/sign-14-0-sign_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sign&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create documents for signature inside Odoo using OWL.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
};
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t
t-name="sign_oca.SignOcaPreview"
t-inherit="sign_oca.SignOcaPdfCommon"
t-inherit-mode="primary"
owl="1"
/>
</templates>
4 changes: 4 additions & 0 deletions sign_oca/templates/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
type="text/javascript"
src="/sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.js"
/>
<script
type="text/javascript"
src="/sign_oca/static/src/components/sign_oca_preview/sign_oca_preview.js"
/>
</xpath>
</template>
<template
Expand Down
2 changes: 2 additions & 0 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="preview"
type="object"
class="oe_stat_button"
icon="fa-pencil"
states="sent,signed"
Expand Down

0 comments on commit 06e16d2

Please sign in to comment.