Skip to content

Commit

Permalink
Merge pull request #232 from Q-Niranjan/17.0-1.4-remove-doc-encryption
Browse files Browse the repository at this point in the history
Remove(documents): Encryption feature
  • Loading branch information
shibu-narayanan authored Dec 27, 2024
2 parents 292e42e + 5212eb5 commit 1aeaef9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 55 deletions.
5 changes: 1 addition & 4 deletions g2p_documents/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"author": "OpenG2P",
"website": "https://openg2p.org",
"license": "LGPL-3",
"depends": [
"storage_backend_s3",
"storage_file",
],
"depends": ["storage_backend_s3", "storage_file", "web"],
"data": [
"security/groups.xml",
"security/ir.model.access.csv",
Expand Down
37 changes: 2 additions & 35 deletions g2p_documents/static/src/js/preview_document.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,17 @@
/** @odoo-module **/
import {Component, onWillStart, xml} from "@odoo/owl";
import {Component, xml} from "@odoo/owl";
import {registry} from "@web/core/registry";
import {useFileViewer} from "@web/core/file_viewer/file_viewer_hook";
import {useService} from "@web/core/utils/hooks";

class Widgetpreview extends Component {
static template = xml`
<t>
<button
class="btn btn-primary"
icon="fa-file-text-o"
t-on-click="clickPreview"
t-if="canPreview"
>
Preview
</button>
<span t-else="">Encrypted</span>
</t>
`;
static template = xml`<button class="btn btn-primary" icon="fa-file-text-o" t-on-click="clickPreview">Preview</button>`;

setup() {
super.setup();
this.fileViewer = useFileViewer();
this.store = useService("mail.store");
this.rpc = useService("rpc");

onWillStart(async () => {
this.decryptRegistry = await this._getDecryptRegistryValue();
this.canPreview = this._checkPreviewConditions();
});
}

async _getDecryptRegistryValue() {
const result = await this.rpc("/web/dataset/call_kw/ir.config_parameter/get_param", {
model: "ir.config_parameter",
method: "get_param",
args: ["g2p_registry_encryption.decrypt_registry"],
kwargs: {},
});
return result === "True";
}

_checkPreviewConditions() {
const is_encrypted = this.props.record.data.is_encrypted;
const decrypt_registry = this.decryptRegistry;
return !is_encrypted || (is_encrypted && decrypt_registry);
}

clickPreview(ev) {
Expand Down
15 changes: 1 addition & 14 deletions g2p_registry_documents/models/document_file.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
from odoo import api, fields, models
from odoo import fields, models


class G2PDocumentRegistry(models.Model):
_inherit = "storage.file"

registrant_id = fields.Many2one("res.partner")

is_encrypted = fields.Boolean(string="Encrypted", default=False)

@api.model
def create(self, vals):
is_encrypt_fields = (
self.env["ir.config_parameter"]
.sudo()
.get_param("g2p_registry_encryption.encrypt_registry", default=False)
)
if is_encrypt_fields:
vals["is_encrypted"] = True
return super().create(vals)

def get_record(self):
for record in self:
return {
Expand Down
2 changes: 0 additions & 2 deletions g2p_registry_documents/views/registrant_document_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<field name="file_size" />
<field name="file_type" />
<!-- Widget provided by g2p_documents module for document preview and viewing -->
<field name="is_encrypted" column_invisible="True" />
<widget name="action_preview" />
</tree>
</field>
Expand All @@ -37,7 +36,6 @@
<field name="file_size" />
<field name="file_type" />
<!-- Widget provided by g2p_documents module for document preview and viewing -->
<field name="is_encrypted" column_invisible="True" />
<widget name="action_preview" />
</tree>
</field>
Expand Down

0 comments on commit 1aeaef9

Please sign in to comment.