Skip to content

Commit

Permalink
[MIG] sign_oca: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peluko00 committed May 17, 2024
1 parent ef43b4d commit a33d59b
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 94 deletions.
2 changes: 1 addition & 1 deletion 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.2.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
15 changes: 0 additions & 15 deletions sign_oca/migrations/16.0.1.1.1/pre-migration.py

This file was deleted.

38 changes: 11 additions & 27 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,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 @@ -45,17 +41,13 @@ class SignOcaRequest(models.Model):
)
],
string="Object",
readonly=True,
states={"draft": [("readonly", False)]},
)
signed = fields.Boolean(copy=False)
signer_ids = fields.One2many(
"sign.oca.request.signer",
inverse_name="request_id",
auto_join=True,
copy=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
signer_id = fields.Many2one(
comodel_name="sign.oca.request.signer",
Expand All @@ -70,7 +62,6 @@ class SignOcaRequest(models.Model):
("cancel", "Cancelled"),
],
default="draft",
readonly=True,
required=True,
copy=False,
tracking=True,
Expand All @@ -80,16 +71,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")

Expand Down Expand Up @@ -310,8 +298,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 @@ -510,9 +498,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

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

View check run for this annotation

Codecov / codecov/patch

sign_oca/models/sign_oca_request.py#L503

Added line #L503 was not covered by tests


class SignRequestLog(models.Model):
Expand All @@ -524,13 +512,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 @@ -549,7 +534,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
Expand Up @@ -2,7 +2,7 @@

import {ComponentWrapper} from "web.OwlCompatibility";
import AbstractAction from "web.AbstractAction";
import Dialog from "web.Dialog";
import {Dialog} from "@web/core/dialog/dialog";
import core from "web.core";
import ControlPanel from "web.ControlPanel";
import SignOcaPdfCommon from "../sign_oca_pdf_common/sign_oca_pdf_common.esm.js";
Expand Down
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,6 +1,6 @@
/** @odoo-module **/
const {Component, onMounted, onWillStart, onWillUnmount, useRef} = owl;
import Dialog from "web.Dialog";
import {Dialog} from "@web/core/dialog/dialog";
import core from "web.core";
const _t = core._t;
export default class SignOcaPdfCommon extends Component {
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SignOcaPdf from "../sign_oca_pdf/sign_oca_pdf.esm.js";

import env from "web.public_env";
import {renderToString} from "@web/core/utils/render";
import session from "web.session";
import {session} from "@web/session";
import {templates} from "@web/core/assets";
export class SignOcaPdfPortal extends SignOcaPdf {
setup() {
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">
<div t-name="sign_oca.SignOcaPdfPortal" owl="1" class="o_sign_oca_content">
<div t-name="sign_oca.SignOcaPdfPortal" class="o_sign_oca_content">
<header>
<div class="container-fluid">
<div class="d-flex justify-content-between flex-fill">
Expand Down
3 changes: 1 addition & 2 deletions sign_oca/static/src/js/systray.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import {attr, many} from "@mail/model/model_field";
import {registerModel} from "@mail/model/model_core";

import session from "web.session";
import {session} from "@web/session";

registerModel({
name: "SignerMenuView",
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/static/src/xml/signer_menu_container.xml
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.SignerMenuContainer" owl="1">
<t t-name="sign_oca.SignerMenuContainer">
<t t-if="signerMenuView">
<SignerMenuView record="signerMenuView" />
</t>
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/static/src/xml/systray.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="sign_oca.SignerMenuView" owl="1">
<t t-name="sign_oca.SignerMenuView">
<div class="o_ActivityMenuView dropdown" t-ref="root">
<a
class="o_ActivityMenuView_dropdownToggle dropdown-toggle o-no-caret o-dropdown--narrow"
Expand Down
8 changes: 8 additions & 0 deletions sign_oca/tests/test_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

import base64

import requests

from odoo.modules.module import get_module_resource
from odoo.tests.common import Form, TransactionCase


class TestSign(TransactionCase):
@classmethod
def setUpClass(cls):
cls._super_send = requests.Session.send
super().setUpClass()
cls.data = base64.b64encode(
open(
Expand Down Expand Up @@ -83,6 +86,11 @@ def configure_request(self):
}
)

@classmethod
def _request_handler(cls, s, r, /, **kw):
"""Don't block external requests."""
return cls._super_send(s, r, **kw)

Check warning on line 92 in sign_oca/tests/test_sign.py

View check run for this annotation

Codecov / codecov/patch

sign_oca/tests/test_sign.py#L92

Added line #L92 was not covered by tests

def test_template_configuration(self):
self.assertFalse(self.template.get_info()["items"])
self.configure_template()
Expand Down
31 changes: 20 additions & 11 deletions sign_oca/tests/test_sign_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,45 @@

import base64

import requests

from odoo.modules.module import get_module_resource
from odoo.tests.common import HttpCase, tagged


@tagged("post_install", "-at_install")
class TestSign(HttpCase):
def setUp(self):
super().setUp()
self.data = base64.b64encode(
@classmethod
def setUpClass(cls):
cls._super_send = requests.Session.send
super().setUpClass()
cls.data = base64.b64encode(
open(
get_module_resource("sign_oca", "tests", "empty.pdf"),
"rb",
).read()
)
self.signer = self.env["res.partner"].create({"name": "Signer"})
self.request = self.env["sign.oca.request"].create(
cls.signer = cls.env["res.partner"].create({"name": "Signer"})
cls.request = cls.env["sign.oca.request"].create(
{
"data": self.data,
"data": cls.data,
"name": "Demo template",
"signer_ids": [
(
0,
0,
{
"partner_id": self.signer.id,
"role_id": self.env.ref("sign_oca.sign_role_customer").id,
"partner_id": cls.signer.id,
"role_id": cls.env.ref("sign_oca.sign_role_customer").id,
},
)
],
}
)
self.item = self.request.add_item(
cls.item = cls.request.add_item(
{
"role_id": self.env.ref("sign_oca.sign_role_customer").id,
"field_id": self.env.ref("sign_oca.sign_field_name").id,
"role_id": cls.env.ref("sign_oca.sign_role_customer").id,
"field_id": cls.env.ref("sign_oca.sign_field_name").id,
"page": 1,
"position_x": 10,
"position_y": 10,
Expand All @@ -46,6 +50,11 @@ def setUp(self):
}
)

@classmethod
def _request_handler(cls, s, r, /, **kw):
"""Don't block external requests."""
return cls._super_send(s, r, **kw)

def test_portal(self):
self.authenticate("portal", "portal")
self.request.action_send()
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/views/res_partner_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class="oe_stat_button"
type="object"
name="action_show_signer_ids"
attrs="{'invisible': [('signer_count', '=', 0)]}"
invisible="signer_count == 0"
icon="fa-pencil"
groups="sign_oca.sign_oca_group_user"
>
Expand Down
Loading

0 comments on commit a33d59b

Please sign in to comment.