Skip to content

Commit

Permalink
[MIG] sign_oca: Finish migration
Browse files Browse the repository at this point in the history
TT51500
  • Loading branch information
victoralmau committed Oct 31, 2024
1 parent 9449701 commit 802230a
Show file tree
Hide file tree
Showing 24 changed files with 264 additions and 570 deletions.
10 changes: 5 additions & 5 deletions sign_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Sign Oca
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github
:target: https://github.com/OCA/sign/tree/16.0/sign_oca
:target: https://github.com/OCA/sign/tree/17.0/sign_oca
:alt: OCA/sign
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-sign_oca
:target: https://translation.odoo-community.org/projects/sign-17-0/sign-17-0-sign_oca
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -128,7 +128,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -169,6 +169,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella|

This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/16.0/sign_oca>`_ project on GitHub.
This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/17.0/sign_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
22 changes: 5 additions & 17 deletions sign_oca/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,9 @@
from odoo.exceptions import AccessError, MissingError
from odoo.http import request

from odoo.addons.base.models.assetsbundle import AssetsBundle
from odoo.addons.portal.controllers.portal import CustomerPortal


class SignController(http.Controller):
@http.route("/sign_oca/get_assets.<any(css,js):ext>", type="http", auth="public")
def get_sign_resources(self, ext):
bundle = "sign_oca.sign_assets"
files, _ = request.env["ir.qweb"]._get_asset_content(bundle)
asset = AssetsBundle(bundle, files)
mock_attachment = getattr(asset, ext)()
if isinstance(
mock_attachment, list
): # suppose that CSS asset will not required to be split in pages
mock_attachment = mock_attachment[0]
stream = request.env["ir.binary"]._get_stream_from(mock_attachment)
response = stream.get_response()
return response


class PortalSign(CustomerPortal):
@http.route(
["/sign_oca/document/<int:signer_id>/<string:access_token>"],
Expand Down Expand Up @@ -51,6 +34,11 @@ def get_sign_oca_access(self, signer_id, access_token, **kwargs):
"partner": signer_sudo.partner_id,
"signer": signer_sudo,
"access_token": access_token,
"sign_oca_backend_info": {
"access_token": access_token,
"signer_id": signer_sudo.id,
"lang": signer_sudo.partner_id.lang,
},
},
)

Expand Down
3 changes: 0 additions & 3 deletions sign_oca/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,3 @@ msgstr "Verrà cancellata la richiesta e tutti gli accessi. Si è sicuri?"
#: model_terms:ir.ui.view,arch_db:sign_oca.portal_sign_document_signed
msgid "has already been signed"
msgstr "è già stato firmato"

#~ msgid "sign.oca.request.log"
#~ msgstr "sign.oca.request.log"
11 changes: 4 additions & 7 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class SignOcaRequest(models.Model):
inverse_name="request_id",
auto_join=True,
copy=True,
readonly=True,
states={"draft": [("readonly", False)]},
string="Signers",
)
signer_id = fields.Many2one(
Expand Down Expand Up @@ -384,10 +382,7 @@ def _compute_is_allow_signature(self):
def _compute_access_url(self):
result = super()._compute_access_url()
for record in self:
record.access_url = "/sign_oca/document/%s/%s" % (
record.id,
record.access_token,
)
record.access_url = f"/sign_oca/document/{record.id}/{record.access_token}"
return result

@api.onchange("role_id")
Expand Down Expand Up @@ -612,7 +607,9 @@ def _get_new_hash(self, secure_seq_number):

def _compute_hash(self, previous_hash):
"""Computes the hash of the browse_record given as self, based on the hash
of the previous record in the company's securisation sequence given as parameter"""
of the previous record in the company's securisation sequence given as
parameter
"""
self.ensure_one()
hash_string = sha256((previous_hash + self._string_to_hash()).encode("utf-8"))
return hash_string.hexdigest()
Expand Down
3 changes: 2 additions & 1 deletion sign_oca/models/sign_oca_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class SignOcaRole(models.Model):
default="empty",
help="This field is used to define how the partner"
" will be calculated in the different roles of "
"a request. This field will be used when the 'Sign from Template' action is triggered.",
"a request. This field will be used when the 'Sign from Template' "
"action is triggered.",
)
default_partner_id = fields.Many2one(
comodel_name="res.partner", string="Default partner"
Expand Down
6 changes: 4 additions & 2 deletions sign_oca/models/sign_oca_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class SignOcaTemplate(models.Model):
string="Model",
domain=[("transient", "=", False), ("model", "not like", "sign.oca")],
)
model = fields.Char(compute="_compute_model", compute_sudo=True, store=True)
model = fields.Char(
compute="_compute_model", string="Model name", compute_sudo=True, store=True
)
active = fields.Boolean(default=True)
request_ids = fields.One2many("sign.oca.request", inverse_name="template_id")

Expand Down Expand Up @@ -112,7 +114,7 @@ def _prepare_sign_oca_request_vals_from_record(self, record):
return {
"name": self.name,
"template_id": self.id,
"record_ref": "%s,%s" % (record._name, record.id),
"record_ref": f"{record._name},{record.id}",
"signatory_data": self._get_signatory_data(),
"data": self.data,
"signer_ids": [
Expand Down
13 changes: 13 additions & 0 deletions sign_oca/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
<field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0" />
</record>
<!-- Company Record Rules -->
<record id="sign_oca_request_rule_company" model="ir.rule">
<field name="name">Sign Request Company</field>
<field name="model_id" ref="model_sign_oca_request" />
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<record id="sign_oca_request_signer_rule_company" model="ir.rule">
<field name="name">Sign Request Signer Company</field>
<field name="model_id" ref="model_sign_oca_request_signer" />
<field
name="domain_force"
>[('request_id.company_id', 'in', company_ids)]</field>
</record>
<!-- User Record Rules -->
<record id="sign_oca_request_rule_user_read" model="ir.rule">
<field name="name">Sign Request user: read</field>
Expand Down
17 changes: 7 additions & 10 deletions sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">Sign Oca</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4cd44f4785da01198064822b367bcbe928fe915080976d5b1f5f2d8671812e51
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/16.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-16-0/sign-16-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=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/17.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-17-0/sign-17-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=17.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>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -493,7 +492,7 @@ <h1><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sign/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -517,15 +516,13 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/etobella"><img alt="etobella" src="https://github.com/etobella.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sign/tree/16.0/sign_oca">OCA/sign</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sign/tree/17.0/sign_oca">OCA/sign</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/** @odoo-module **/

const {App, mount, useRef} = owl;
const {App, whenReady, useRef} = owl;
import SignOcaPdf from "../sign_oca_pdf/sign_oca_pdf.esm.js";
import {makeEnv} from "@web/env";
import {renderToString} from "@web/core/utils/render";
import {session} from "@web/session";
import {makeEnv, startServices} from "@web/env";
import {templates} from "@web/core/assets";
import {_t} from "@web/core/l10n/translation";

export class SignOcaPdfPortal extends SignOcaPdf {
setup() {
Expand Down Expand Up @@ -67,23 +66,22 @@ export class SignOcaPdfPortal extends SignOcaPdf {
}
}
SignOcaPdfPortal.template = "sign_oca.SignOcaPdfPortal";
SignOcaPdfPortal.props = {
access_token: {type: String},
signer_id: {type: Number},
};
export function initDocumentToSign(properties) {
return session.session_bind(session.origin).then(function () {
return Promise.all([
session.load_translations(["web", "portal", "sign_oca"]),
]).then(async function () {
var app = new App(null, {templates, test: true});
renderToString.app = app;
const env = makeEnv();
mount(SignOcaPdfPortal, document.body, {
env,
props: properties,
templates: templates,
});
});

export async function initDocumentToSign(document, sign_oca_backend_info) {
await whenReady();
const env = makeEnv();
await startServices(env);
const app = new App(SignOcaPdfPortal, {
templates,
env: env,
dev: env.debug,
props: {
access_token: sign_oca_backend_info.access_token,
signer_id: sign_oca_backend_info.signer_id,
},
translateFn: _t,
translatableAttributes: ["data-tooltip"],
});
return app.mount(document.body);
}
export default {SignOcaPdfPortal, initDocumentToSign};
21 changes: 0 additions & 21 deletions sign_oca/static/src/js/ir_model.esm.js

This file was deleted.

48 changes: 0 additions & 48 deletions sign_oca/static/src/js/request_group_view.esm.js

This file was deleted.

30 changes: 0 additions & 30 deletions sign_oca/static/src/js/request_groups.esm.js

This file was deleted.

Loading

0 comments on commit 802230a

Please sign in to comment.