Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Suggestion/contribution: Add document template modules for Odoo - ONLYOFFICE #36

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions onlyoffice_templates/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
=====================
Templates Only Office
=====================

Options and data for adding templates OnlyOffice


1. First add one or more templates. Goto Settings -> Onlyoffice
2. Click on the link to view and add a template
3. When this is done goto Partners (maybe first install module contacts)
4. Open a Contact (res.partner) in detail view
5. Under the action menu there is a function to add a new doc based on a template

This is a base module with option for partners. Another module will add this option for other models.\

for example onlyoffice_templates_project


This module is maintained by Open2bizz.

.. image:: https://www.open2bizz.tech/logo.png
:alt: Open2Bizz
:target: https://www.open2bizz.tech
\

**Bugs? Suggestions?:**
support@open2bizz.nl
5 changes: 5 additions & 0 deletions onlyoffice_templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2013-2020 Open2Bizz <info@open2bizz.nl>
# License LGPL-3

from . import models
from . import wizard
23 changes: 23 additions & 0 deletions onlyoffice_templates/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Open2Bizz <info@open2bizz.nl>
# License LGPL-3

{
'name': 'OnlyOffice Templates',
'summary': 'OnlyOffice Templates',
'version': '1.0.1',
'category': 'Productivity',
'website': 'https://www.open2bizz.nl/',
'author': 'Open2Bizz',
'license': 'LGPL-3',
'installable': True,
'depends': [
'base',
'onlyoffice_odoo',
],
'data': [
'security/ir_model_access.xml',
'views/actions.xml',
'views/ir_attachment.xml',
'wizard/attachment_from_template.xml'
]
}
Binary file added onlyoffice_templates/i18n/nl.mo
Binary file not shown.
145 changes: 145 additions & 0 deletions onlyoffice_templates/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * onlyoffice_templates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-12 18:05+0000\n"
"PO-Revision-Date: 2024-04-12 20:07+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"

#. module: onlyoffice_templates
#: model:ir.model,name:onlyoffice_templates.model_ir_attachment
msgid "Attachment"
msgstr "Bijlage"

#. module: onlyoffice_templates
#: model:ir.actions.act_window,name:onlyoffice_templates.action_attachment_templates
#: model:ir.ui.menu,name:onlyoffice_templates.menu_action_attachment_templates
msgid "Attachment Templates"
msgstr "Bijlage Sjablonen"

#. module: onlyoffice_templates
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.attachment_copy_form
msgid "Cancel"
msgstr "Annuleren"

#. module: onlyoffice_templates
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.attachment_copy_form
msgid "Choose template"
msgstr "Kies sjabloon"

#. module: onlyoffice_templates
#: model:ir.model,name:onlyoffice_templates.model_res_partner
msgid "Contact"
msgstr "Relatie"

#. module: onlyoffice_templates
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.attachment_copy_form
msgid "Create"
msgstr "Aanmaken"

#. module: onlyoffice_templates
#. odoo-python
#: code:addons/onlyoffice_templates/models/res_partner.py:0
#, python-format
msgid "Create Attachment"
msgstr "Bijlage maken"

#. module: onlyoffice_templates
#: model_terms:ir.actions.act_window,help:onlyoffice_templates.action_attachment_templates
msgid "Create a new template"
msgstr "Nieuw sjabloon aanmaken"

#. module: onlyoffice_templates
#: model:ir.actions.server,name:onlyoffice_templates.action_account_invoice_from_list
msgid "Create doc from template"
msgstr "Documenten maken van sjabloon"

#. module: onlyoffice_templates
#: model:ir.model,name:onlyoffice_templates.model_ir_attachment_create_templ
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.attachment_copy_form
msgid "Create from template"
msgstr "Creëer met sjabloon"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__create_uid
msgid "Created by"
msgstr "Aangemaakt door"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__create_date
msgid "Created on"
msgstr "Aangemaakt op"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__display_name
msgid "Display Name"
msgstr "Weergavenaam"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__id
msgid "ID"
msgstr "ID"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment__is_template
#: model:ir.model.fields,field_description:onlyoffice_templates.field_product_document__is_template
msgid "Is a template"
msgstr "Is een sjabloon"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__write_uid
msgid "Last Updated by"
msgstr "Laatst bijgewerkt door"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__write_date
msgid "Last Updated on"
msgstr "Laatst bijgewerkt op"

#. module: onlyoffice_templates
#. odoo-python
#: code:addons/onlyoffice_templates/wizard/attachment_from_template.py:0
#, python-format
msgid "No record selected to add the document!"
msgstr "Geen record geselecteerd om het document toe te voegen!"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment__icon_image
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__icon_image
#: model:ir.model.fields,field_description:onlyoffice_templates.field_product_document__icon_image
msgid "Preview"
msgstr "Voorbeeld"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__res_id
msgid "Resource ID"
msgstr "Resource-ID"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__res_model
msgid "Resource Model"
msgstr "Model in Odoo"

#. module: onlyoffice_templates
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment__template_id
#: model:ir.model.fields,field_description:onlyoffice_templates.field_ir_attachment_create_templ__template_id
#: model:ir.model.fields,field_description:onlyoffice_templates.field_product_document__template_id
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.view_attachment_form
msgid "Template"
msgstr "Sjabloon"

#. module: onlyoffice_templates
#: model_terms:ir.ui.view,arch_db:onlyoffice_templates.res_config_settings_view_form
msgid "Templates"
msgstr "Sjablonen"
5 changes: 5 additions & 0 deletions onlyoffice_templates/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2013-2020 Open2Bizz <info@open2bizz.nl>
# License LGPL-3

from . import ir_attachments
from . import res_partner
47 changes: 47 additions & 0 deletions onlyoffice_templates/models/ir_attachments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2013-2020 Open2Bizz <info@open2bizz.nl>
# License LGPL-3
import base64
import odoo

from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError
from odoo.modules import get_module_path

class IrAttachment(models.Model):
_inherit = "ir.attachment"

is_template = fields.Boolean("Is a template", default=False, copy=False)
template_id = fields.Many2one("ir.attachment",string="Template")
template_model_id = fields.Many2one("ir.model",string="Template for Model")
template_model = fields.Char("Templ Model Name", related="template_model_id.model")
icon_image = fields.Binary(string='Preview')

# TODO: add static preview image on form just like:
# https://github.com/odoo/odoo/blob/b95edd874ce904ef231c295790a003992db002e3/addons/web/static/src/scss/mimetypes.scss#L32

def set_icon_image(self):
self.ensure_one()
if not self.icon_image:
mimetype = self.mimetype
mod_path = get_module_path("onlyoffice_templates")
base_path = mod_path + "/static/img/"
if 'wordprocess' in mimetype:
path = base_path + 'document.svg'
elif 'spreadsheet' in mimetype:
path = base_path + 'spreadsheet.svg'
elif 'presentation' in mimetype:
path = base_path + 'presentation.svg'
else:
path = base_path + 'unknown.svg'
with tools.file_open(path, 'rb') as image_file:
icon_image = base64.b64encode(image_file.read())
if icon_image:
self.write({'icon_image': icon_image})

@api.model_create_multi
def create(self, vals_list):
attachment = super(IrAttachment, self).create(vals_list)
if attachment.is_template and not attachment.icon_image:
attachment.set_icon_image()
attachment.type = 'binary'
return attachment
21 changes: 21 additions & 0 deletions onlyoffice_templates/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Open2Bizz <info@open2bizz.nl>
# License LGPL-3

from odoo import api, fields, models, _
from odoo.exceptions import UserError


class ResPartner(models.Model):
_inherit = "res.partner"

def action_create_doc_template(self):
self.ensure_one()
model_name = 'res.partner'
return {
'name': _('Create Attachment'),
'type': 'ir.actions.act_window',
'res_model': 'ir.attachment.create_templ',
'view_mode': 'form',
'target': 'new',
'context': {'default_res_model': model_name, 'default_res_id': self.id}
}
17 changes: 17 additions & 0 deletions onlyoffice_templates/security/ir_model_access.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<!-- Rules -->
<record id="default_data_model_access_admin" model="ir.model.access">
<field name="name">create from template</field>
<field name="model_id" ref="onlyoffice_templates.model_ir_attachment_create_templ"/>
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="True" />
<field name="perm_write" eval="True" />
<field name="perm_create" eval="True" />
<field name="perm_unlink" eval="True" />
</record>

</data>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions onlyoffice_templates/static/description/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<style>
body {
font-family: 'Trebuchet MS', sans-serif;
}
</style>
<body>
<div class="document" id="module-name">
<h1 class="title">BASE module Templates ONLYOFFICE</h1>
<p>
Options and data for adding templates OnlyOffice, and using them for partners
</p>
<ul>
<li>
First add one or more templates. Goto Settings -> Onlyoffice
</li>
<li>
Click on the link "Templates" to view and add a template
</li>
<li>
Add ad template and select Model "Contact (res.partner)". As specified in default Onlyoffice editor for ONLINE select file type .DOCX, .XLSX or .PPTX. Optional you can add a different preview image to be shown when selected later.
</li>
<li>
When this is done goto Partners (maybe first install module contacts)
</li>
<li>
Open a Contact (res.partner) in detail view
</li>
<li>
Under the action menu there is a function to add a new doc based on a template
</li>
</ul>
<hr/>
<table>
<tr>
<td>
<img class="oe_picture oe_screenshot" src="Selectie_118.png" width="600"/>
</td>
<td>
<img class="oe_picture oe_screenshot" src="Selectie_119.png" width="600"/>
</td>
</tr>
</table>
<div>

</div>
<div>

</div>
<p>
Module is developed by Open2Bizz. Bug reports: support@open2bizz.eu
</p>
<p>
<img src="https://www.open2bizz.tech/logo.png" style="max-height: 100px;">
</p>

</div>
</body>
</html>
20 changes: 20 additions & 0 deletions onlyoffice_templates/static/img/document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions onlyoffice_templates/static/img/presentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading