mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 10:28:40 -06:00
first version
This commit is contained in:
parent
a5a01ecfcd
commit
1b56ee20bd
@ -2,5 +2,3 @@
|
||||
# © 2017 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from . import models
|
||||
from . import wizards
|
||||
from . import controllers
|
||||
|
@ -2,31 +2,17 @@
|
||||
# © 2017 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Term",
|
||||
"name": "Terms and Definitions",
|
||||
"version": "8.0.1.0.0",
|
||||
"author": "Therp BV,Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "",
|
||||
"summary": "",
|
||||
"category": "Knowledge",
|
||||
"depends": [
|
||||
'knowledge',
|
||||
],
|
||||
"data": [
|
||||
'views/templates.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
"qweb": [
|
||||
],
|
||||
"test": [
|
||||
],
|
||||
"images": [
|
||||
],
|
||||
"pre_init_hook": False,
|
||||
"post_init_hook": False,
|
||||
"uninstall_hook": False,
|
||||
"auto_install": False,
|
||||
"installable": True,
|
||||
"application": False,
|
||||
"external_dependencies": {
|
||||
'python': [],
|
||||
},
|
||||
}
|
||||
|
@ -4,8 +4,36 @@
|
||||
from openerp import api, fields, models
|
||||
|
||||
|
||||
class document_definition(models.Model):
|
||||
_inherit = 'document_definition'
|
||||
_name = 'document_definition'
|
||||
_description = ''
|
||||
class DocumentDefinition(models.Model):
|
||||
_name = 'document.definition'
|
||||
|
||||
term = fields.Char(help='Term to define', 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 a blank space we trim it
|
||||
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')]
|
||||
|
@ -1 +1,3 @@
|
||||
"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
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from . import test_document_definition
|
@ -1,9 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestDocumentDefinition(TransactionCase):
|
||||
def test_document_definition(self):
|
||||
pass
|
@ -3,9 +3,80 @@
|
||||
<data>
|
||||
<template id="assets_backend" name="document_definition assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/document_definition/static/src/js/document_definition.js"></script>
|
||||
<script type="text/javascript" src="/document_definition/static/src/js/document_definition.js"/>
|
||||
<link rel="stylesheet" href="/document_definition/static/src/css/document_definition.css"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<record id="view_definition_tree" model="ir.ui.view">
|
||||
<field name="name">document.definition.tree</field>
|
||||
<field name="model">document.definition</field>
|
||||
<field name="priority">100</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Definitions" editable="top">
|
||||
<field name="term"/>
|
||||
<field name="definition"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_definition_form" model="ir.ui.view">
|
||||
<field name="name">document.definition.form</field>
|
||||
<field name="model">document.definition</field>
|
||||
<field name="priority">100</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Definitions">
|
||||
<sheet>
|
||||
<h1>
|
||||
<field name="term"/>
|
||||
</h1>
|
||||
<field name="definition"/>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- filters to group by alphabetical order, and search by term or in
|
||||
definition -->
|
||||
|
||||
<record id="view_definition_filter" model="ir.ui.view">
|
||||
<field name="name">document.definition.search</field>
|
||||
<field name="model">document.definition</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Definitions">
|
||||
<field name="term" string="Search Term" filter_domain="[('term','ilike',self)]"/>
|
||||
<field name="definition" string="Search in definition" filter_domain="[('definition','ilike',self)]"/>
|
||||
<field name="write_uid"/>
|
||||
<group expand="1" string="Group By...">
|
||||
<filter string="Alphabetical" domain="[]" context="{'group_by':'first_letter'}"/>
|
||||
<filter string="Author" domain="[]" context="{'group_by':'create_uid'}"/>
|
||||
<filter string="Last Contributor" domain="[]" context="{'group_by':'write_uid'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_definition" model="ir.actions.act_window">
|
||||
<field name="name">Terms and definitions</field>
|
||||
<field name="res_model">document.definition</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_definition_tree"/>
|
||||
<field name="search_view_id" ref="view_definition_filter"/>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_definition_top"
|
||||
parent="knowledge.menu_document"
|
||||
name="Definitions"
|
||||
sequence="10" />
|
||||
|
||||
<menuitem
|
||||
id="menu_definition"
|
||||
parent="menu_definition_top"
|
||||
name="Definitions"
|
||||
action="action_definition"
|
||||
sequence="10" />
|
||||
</data>
|
||||
</openerp>
|
||||
|
@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
Loading…
Reference in New Issue
Block a user