diff --git a/document_definition/README.rst b/document_definition/README.rst new file mode 100644 index 00000000..18276b6c --- /dev/null +++ b/document_definition/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +===================== +Terms and definitions +===================== + +Installs a new document_definition model for dictionary-style word archive and +definition. Adds Searchable view for terms and definitions in the Knowledge menu. +Has a search view per term and per definition and a dictionary Style Alphabetical grouping view. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Giovanni Francesco Capalbo + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/document_definition/__init__.py b/document_definition/__init__.py new file mode 100644 index 00000000..86cb334c --- /dev/null +++ b/document_definition/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/document_definition/__openerp__.py b/document_definition/__openerp__.py new file mode 100644 index 00000000..f74e1c5f --- /dev/null +++ b/document_definition/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Terms and Definitions", + "version": "8.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Knowledge", + "depends": [ + 'knowledge', + ], + "data": [ + 'views/templates.xml', + 'security/ir.model.access.csv', + ], + "installable": True, +} diff --git a/document_definition/models/__init__.py b/document_definition/models/__init__.py new file mode 100644 index 00000000..57a405fb --- /dev/null +++ b/document_definition/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import document_definition diff --git a/document_definition/models/document_definition.py b/document_definition/models/document_definition.py new file mode 100644 index 00000000..bb498101 --- /dev/null +++ b/document_definition/models/document_definition.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import api, fields, models + + +class DocumentDefinition(models.Model): + _name = 'document.definition' + + term = fields.Char(help='Term', required=True) + definition = fields.Text(help='Definition of term', required=True) + + # stored compute field used for making the letter grouping + # need to be stored in order to use grouping + first_letter = fields.Char() + + def _get_first_letter(self, text): + # if somehow the user starts with one or more whitespaces we trim + return text.lstrip()[:1].upper() or 'Blank Term' + + @api.model + def create(self, vals): + vals['first_letter'] = self._get_first_letter(vals['term']) + res = super(DocumentDefinition, self).create(vals=vals) + return res + + @api.multi + def write(self, vals): + for this in self: + if vals.get('term'): + vals['first_letter'] = this._get_first_letter(vals['term']) + res = super(DocumentDefinition, this).write(vals=vals) + return res + + # constraint of uniqueness on term, two terms can't have different + # definitions + + _sql_constraints = [('term_uniq', 'UNIQUE(term)', + 'Every term must be unique')] diff --git a/document_definition/security/ir.model.access.csv b/document_definition/security/ir.model.access.csv new file mode 100644 index 00000000..018f7c8a --- /dev/null +++ b/document_definition/security/ir.model.access.csv @@ -0,0 +1,2 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +document_definition_all,document.definition,model_document_definition,,1,1,1,1 diff --git a/document_definition/views/templates.xml b/document_definition/views/templates.xml new file mode 100644 index 00000000..27f521d5 --- /dev/null +++ b/document_definition/views/templates.xml @@ -0,0 +1,74 @@ + + + + + document.definition.tree + document.definition + 100 + + + + + + + + + + document.definition.form + document.definition + 100 + +
+ +

+ +

+ +
+
+
+
+ + + + + document.definition.search + document.definition + + + + + + + + + + + + + + + + Terms and definitions + document.definition + form + tree,form + + + + + + + +
+