Skip to content

Commit

Permalink
[MIG] sign_oca: Migration to 17.0
Browse files Browse the repository at this point in the history
>
>
Co-authored-by: Bernat Puig <[email protected]>
  • Loading branch information
peluko00 authored and victoralmau committed Oct 31, 2024
1 parent f3339ba commit 9449701
Show file tree
Hide file tree
Showing 36 changed files with 344 additions and 364 deletions.
3 changes: 1 addition & 2 deletions sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Sign Oca",
"summary": """
Allow to sign documents inside Odoo CE""",
"version": "16.0.4.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
Expand Down Expand Up @@ -63,7 +63,6 @@
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.esm.js",
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
"sign_oca/static/src/scss/portal.scss",
"sign_oca/static/src/js/*.js",
"sign_oca/static/src/xml/*.xml",
],
"sign_oca.sign_assets": [
Expand Down
25 changes: 0 additions & 25 deletions sign_oca/migrations/16.0.1.1.1/pre-migration.py

This file was deleted.

36 changes: 11 additions & 25 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ class SignOcaRequest(models.Model):

name = fields.Char(required=True)
active = fields.Boolean(default=True)
template_id = fields.Many2one("sign.oca.template", readonly=True)
data = fields.Binary(
required=True, readonly=True, states={"draft": [("readonly", False)]}
)
template_id = fields.Many2one("sign.oca.template")
data = fields.Binary(required=True)
filename = fields.Char()
user_id = fields.Many2one(
comodel_name="res.users",
string="Responsible",
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self.env.user,
required=True,
)
Expand All @@ -48,8 +44,6 @@ class SignOcaRequest(models.Model):
.search([("transient", "=", False), ("model", "not like", "sign.oca")])
],
string="Object",
readonly=True,
states={"draft": [("readonly", False)]},
)
signed = fields.Boolean(copy=False)
signer_ids = fields.One2many(
Expand All @@ -75,7 +69,6 @@ class SignOcaRequest(models.Model):
("cancel", "Cancelled"),
],
default="draft",
readonly=True,
required=True,
copy=False,
tracking=True,
Expand All @@ -85,16 +78,13 @@ class SignOcaRequest(models.Model):
to_sign = fields.Boolean(compute="_compute_to_sign")
signatory_data = fields.Serialized(
default=lambda r: {},
readonly=True,
copy=False,
)
current_hash = fields.Char(readonly=True, copy=False)
current_hash = fields.Char(copy=False)
company_id = fields.Many2one(
"res.company",
default=lambda r: r.env.company.id,
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
next_item_id = fields.Integer(compute="_compute_next_item_id")
ask_location = fields.Boolean()
Expand Down Expand Up @@ -351,8 +341,8 @@ class SignOcaRequestSigner(models.Model):
partner_name = fields.Char(related="partner_id.name")
partner_id = fields.Many2one("res.partner", required=True, ondelete="restrict")
role_id = fields.Many2one("sign.oca.role", required=True, ondelete="restrict")
signed_on = fields.Datetime(readonly=True)
signature_hash = fields.Char(readonly=True)
signed_on = fields.Datetime()
signature_hash = fields.Char()
model = fields.Char(compute="_compute_model", store=True)
res_id = fields.Integer(compute="_compute_res_id", store=True)
is_allow_signature = fields.Boolean(compute="_compute_is_allow_signature")
Expand Down Expand Up @@ -584,9 +574,9 @@ def _set_action_log(self, action, **kwargs):
self.ensure_one()
return self.request_id._set_action_log(action, signer_id=self.id, **kwargs)

def name_get(self):
result = [(signer.id, (signer.partner_id.display_name)) for signer in self]
return result
def _compute_display_name(self):
for signer in self:
signer.display_name = signer.partner_id.display_name

def _get_sequence(self):
return self.env.ref("sign_oca.sign_inalterability_sequence")
Expand Down Expand Up @@ -663,13 +653,10 @@ class SignRequestLog(models.Model):
uid = fields.Many2one(
"res.users",
required=True,
readonly=True,
ondelete="cascade",
default=lambda r: r.env.user.id,
)
date = fields.Datetime(
required=True, readonly=True, default=lambda r: fields.Datetime.now()
)
date = fields.Datetime(required=True, default=lambda r: fields.Datetime.now())
partner_id = fields.Many2one(
"res.partner", required=True, default=lambda r: r.env.user.partner_id.id
)
Expand All @@ -688,7 +675,6 @@ class SignRequestLog(models.Model):
("configure", "Configure"),
],
required=True,
readonly=True,
)
access_token = fields.Char(readonly=True)
ip = fields.Char(readonly=True)
access_token = fields.Char()
ip = fields.Char()
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/** @odoo-module **/
/** @odoo-module QWeb **/

import {ComponentWrapper} from "web.OwlCompatibility";
import AbstractAction from "web.AbstractAction";
import Dialog from "web.Dialog";
import core from "web.core";
import ControlPanel from "web.ControlPanel";
import {Component} from "@odoo/owl";
import {ControlPanel} from "@web/search/control_panel/control_panel";
import {Dialog} from "@web/core/dialog/dialog";
import {FormRenderer} from "@web/views/form/form_renderer";
import SignOcaPdfCommon from "../sign_oca_pdf_common/sign_oca_pdf_common.esm.js";
const _t = core._t;
import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
import {renderToString} from "@web/core/utils/render";

export class SignOcaConfigureControlPanel extends ControlPanel {}
SignOcaConfigureControlPanel.template = "sign_oca.SignOcaConfigureControlPanel";
export class SignOcaConfigure extends SignOcaPdfCommon {
Expand Down Expand Up @@ -35,7 +37,7 @@ export class SignOcaConfigure extends SignOcaPdfCommon {
}
var position = page.getBoundingClientRect();
this.contextMenu = $(
core.qweb.render("sign_oca.sign_iframe_contextmenu", {
renderToString("sign_oca.sign_iframe_contextmenu", {
page,
e,
left: ((e.pageX - position.x) * 100) / position.width + "%",
Expand Down Expand Up @@ -111,7 +113,7 @@ export class SignOcaConfigure extends SignOcaPdfCommon {
var dialog = new Dialog(this, {
title: _t("Edit field"),
$content: $(
core.qweb.render("sign_oca.sign_oca_field_edition", {
renderToString("sign_oca.sign_oca_field_edition", {
item,
info: this.info,
})
Expand Down Expand Up @@ -367,34 +369,33 @@ export class SignOcaConfigure extends SignOcaPdfCommon {
}
}

export const SignOcaConfigureAction = AbstractAction.extend({
hasControlPanel: true,
init: function (parent, action) {
export class SignOcaConfigureAction extends Component {
init(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, SignOcaConfigure, {
this.component = new FormRenderer(this, SignOcaConfigure, {
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 () {
}
getState() {
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_configure", SignOcaConfigureAction);
}
}
SignOcaConfigure.template = "sign_oca.SignOcaConfigure";
registry.category("actions").add("sign_oca_configure", SignOcaConfigureAction);
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
t-name="sign_oca.SignOcaConfigure"
t-inherit="sign_oca.SignOcaPdfCommon"
t-inherit-mode="primary"
owl="1"
>
<xpath expr="//iframe" position="before">
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/** @odoo-module **/
/** @odoo-module Qweb **/

import SignOcaPdfCommon from "../sign_oca_pdf_common/sign_oca_pdf_common.esm.js";
import core from "web.core";
import {registry} from "@web/core/registry";
const SignRegistry = registry.category("sign_oca");
import {renderToString} from "@web/core/utils/render";

export default class SignOcaPdf extends SignOcaPdfCommon {
setup() {
super.setup(...arguments);
Expand All @@ -23,7 +24,7 @@ export default class SignOcaPdf extends SignOcaPdfCommon {
}
renderButtons(to_sign) {
var $buttons = $(
core.qweb.render("oca_sign_oca.SignatureButtons", {
renderToString("oca_sign_oca.SignatureButtons", {
to_sign: to_sign,
})
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
/** @odoo-module **/

import AbstractAction from "web.AbstractAction";
import {ComponentWrapper} from "web.OwlCompatibility";
import {Component} from "@odoo/owl";
import {FormRenderer} from "@web/views/form/form_renderer";
import SignOcaPdf from "./sign_oca_pdf.esm.js";
import core from "web.core";
import {registry} from "@web/core/registry";

const SignOcaPdfAction = AbstractAction.extend({
className: "o_sign_oca_content",
hasControlPanel: true,
init: function (parent, action) {
export class SignOcaPdfAction extends Component {
init(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, SignOcaPdf, {
this.component = new FormRenderer(this, SignOcaPdf, {
model: this.model,
res_id: this.res_id,
updateControlPanel: this.updateControlPanel.bind(this),
trigger: this.trigger_up.bind(this),
});
return this.component.mount(this.$(".o_content")[0]);
},
getState: function () {
}
getState() {
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", SignOcaPdfAction);
export default SignOcaPdfAction;
}
}
registry.category("actions").add("sign_oca", SignOcaPdfAction);
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/** @odoo-module **/
const {Component, onMounted, onWillStart, onWillUnmount, useRef} = owl;
import Dialog from "web.Dialog";
import core from "web.core";
const _t = core._t;
/** @odoo-module QWeb **/
import {Component, onMounted, onWillStart, onWillUnmount, useRef} from "@odoo/owl";
import {Dialog} from "@web/core/dialog/dialog";
import {_t} from "@web/core/l10n/translation";
import {renderToString} from "@web/core/utils/render";

export default class SignOcaPdfCommon extends Component {
setup() {
super.setup(...arguments);
Expand All @@ -11,8 +12,8 @@ export default class SignOcaPdfCommon extends Component {
this.pdf_url = this.getPdfUrl();
this.viewer_url = "/web/static/lib/pdfjs/web/viewer.html?file=" + this.pdf_url;
this.iframe = useRef("sign_oca_iframe");
var iframeResolve = undefined;
var iframeReject = undefined;
var iframeResolve = "";
var iframeReject = "";
this.iframeLoaded = new Promise(function (resolve, reject) {
iframeResolve = resolve;
iframeReject = reject;
Expand Down Expand Up @@ -112,7 +113,7 @@ export default class SignOcaPdfCommon extends Component {
item.page - 1
];
var signatureItem = $(
core.qweb.render(this.field_template, {
renderToString(this.field_template, {
...item,
})
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="sign_oca.SignOcaPdfCommon" owl="1">
<t t-name="sign_oca.SignOcaPdfCommon">
<div class="o_sign_oca_content">
<iframe
class="o_sign_oca_iframe"
Expand Down
Loading

0 comments on commit 9449701

Please sign in to comment.