Skip to content
Draft
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
3 changes: 3 additions & 0 deletions web_diagram/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import controllers, models
32 changes: 32 additions & 0 deletions web_diagram/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'Odoo Web Diagram',
'category': 'Hidden',
'description': """
Openerp Web Diagram view.
=========================

""",
'version': "17.0.1.0.0",
'depends': ['web'],
'assets': {
'web.assets_backend': [
'web_diagram/static/lib/js/jquery.mousewheel.js',
'web_diagram/static/lib/js/raphael.js',
'web_diagram/static/src/scss/diagram_view.scss',
'web_diagram/static/src/js/vec2.js',
'web_diagram/static/src/js/graph.js',
'web_diagram/static/src/js/diagram_model.js',
'web_diagram/static/src/js/diagram_controller.js',
'web_diagram/static/src/js/diagram_renderer.js',
'web_diagram/static/src/js/diagram_view.js',
'web_diagram/static/src/xml/base_diagram.xml',
],
'web.qunit_suite_tests': [
'web_diagram/static/tests/diagram_tests.js',
],
},
'auto_install': True,
'license': 'LGPL-3',
}
3 changes: 3 additions & 0 deletions web_diagram/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import main
115 changes: 115 additions & 0 deletions web_diagram/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import odoo.http as http

from odoo.tools.safe_eval import safe_eval


class DiagramView(http.Controller):

@http.route('/web_diagram/diagram/get_diagram_info', type='json', auth='user')
def get_diagram_info(self, id, model, node, connector,
src_node, des_node, label, **kw):

visible_node_fields = kw.get('visible_node_fields', [])
invisible_node_fields = kw.get('invisible_node_fields', [])
node_fields_string = kw.get('node_fields_string', [])
connector_fields = kw.get('connector_fields', [])
connector_fields_string = kw.get('connector_fields_string', [])

bgcolors = {}
shapes = {}
bgcolor = kw.get('bgcolor', '')
shape = kw.get('shape', '')

if bgcolor:
for color_spec in bgcolor.split(';'):
if color_spec:
colour, color_state = color_spec.split(':')
bgcolors[colour] = color_state

if shape:
for shape_spec in shape.split(';'):
if shape_spec:
shape_colour, shape_color_state = shape_spec.split(':')
shapes[shape_colour] = shape_color_state

ir_view = http.request.env['ir.ui.view']
graphs = ir_view.graph_get(int(id), model, node, connector, src_node,
des_node, label, (140, 180))
nodes = graphs['nodes']
transitions = graphs['transitions']
isolate_nodes = {}
for blnk_node in graphs['blank_nodes']:
isolate_nodes[blnk_node['id']] = blnk_node
y = [
t['y']
for t in nodes.values()
if t['x'] == 20
if t['y']
]
y_max = (y and max(y)) or 120

connectors = {}
list_tr = []

for tr in transitions:
list_tr.append(tr)
connectors.setdefault(tr, {
'id': int(tr),
's_id': transitions[tr][0],
'd_id': transitions[tr][1]
})

connector_model = http.request.env[connector]
data_connectors = connector_model.search([('id', 'in', list_tr)]).read(connector_fields)

for tr in data_connectors:
transition_id = str(tr['id'])
_sourceid, label = graphs['label'][transition_id]
t = connectors[transition_id]
t.update(
source=tr[src_node][1],
destination=tr[des_node][1],
options={},
signal=label
)

for i, fld in enumerate(connector_fields):
t['options'][connector_fields_string[i]] = tr[fld]

fields = http.request.env['ir.model.fields']
field = fields.search([('model', '=', model), ('relation', '=', node)])
node_act = http.request.env[node]
search_acts = node_act.search([(field.relation_field, '=', id)])
data_acts = search_acts.read(invisible_node_fields + visible_node_fields)

for act in data_acts:
n = nodes.get(str(act['id']))
if not n:
n = isolate_nodes.get(act['id'], {})
y_max += 140
n.update(x=20, y=y_max)
nodes[act['id']] = n

n.update(
id=act['id'],
color='white',
options={}
)
for color, expr in bgcolors.items():
if safe_eval(expr, act):
n['color'] = color

for shape, expr in shapes.items():
if safe_eval(expr, act):
n['shape'] = shape

for i, fld in enumerate(visible_node_fields):
n['options'][node_fields_string[i]] = act[fld]

name = http.request.env[model].browse(id).display_name
return dict(nodes=nodes,
conn=connectors,
display_name=name,
parent_field=graphs['node_parent_field'])
93 changes: 93 additions & 0 deletions web_diagram/i18n/af.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_diagram
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-18 14:08+0000\n"
"PO-Revision-Date: 2015-08-25 10:26+0000\n"
"Last-Translator: <>\n"
"Language-Team: Afrikaans (http://www.transifex.com/odoo/odoo-9/language/"
"af/)\n"
"Language: af\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:249
#: code:addons/web_diagram/static/src/js/diagram.js:277
#, python-format
msgid "Activity"
msgstr "Aktiwiteit"

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:282
#: code:addons/web_diagram/static/src/js/diagram.js:326
#, python-format
msgid "Create:"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:220
#, python-format
msgid ""
"Deleting this node cannot be undone.\n"
"It will also delete all connected transitions.\n"
"\n"
"Are you sure ?"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:238
#, python-format
msgid ""
"Deleting this transition cannot be undone.\n"
"\n"
"Are you sure ?"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:19
#, python-format
msgid "Diagram"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:124
#, python-format
msgid "New"
msgstr "Nuwe"

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/xml/base_diagram.xml:5
#, python-format
msgid "New Node"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:254
#: code:addons/web_diagram/static/src/js/diagram.js:310
#, python-format
msgid "Open: "
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:305
#: code:addons/web_diagram/static/src/js/diagram.js:321
#, python-format
msgid "Transition"
msgstr ""
92 changes: 92 additions & 0 deletions web_diagram/i18n/am.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_diagram
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-18 14:08+0000\n"
"PO-Revision-Date: 2015-09-08 09:26+0000\n"
"Last-Translator: Martin Trigaux\n"
"Language-Team: Amharic (http://www.transifex.com/odoo/odoo-9/language/am/)\n"
"Language: am\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:249
#: code:addons/web_diagram/static/src/js/diagram.js:277
#, python-format
msgid "Activity"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:282
#: code:addons/web_diagram/static/src/js/diagram.js:326
#, python-format
msgid "Create:"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:220
#, python-format
msgid ""
"Deleting this node cannot be undone.\n"
"It will also delete all connected transitions.\n"
"\n"
"Are you sure ?"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:238
#, python-format
msgid ""
"Deleting this transition cannot be undone.\n"
"\n"
"Are you sure ?"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:19
#, python-format
msgid "Diagram"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:124
#, python-format
msgid "New"
msgstr "አዲስ"

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/xml/base_diagram.xml:5
#, python-format
msgid "New Node"
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:254
#: code:addons/web_diagram/static/src/js/diagram.js:310
#, python-format
msgid "Open: "
msgstr ""

#. module: web_diagram
#. openerp-web
#: code:addons/web_diagram/static/src/js/diagram.js:305
#: code:addons/web_diagram/static/src/js/diagram.js:321
#, python-format
msgid "Transition"
msgstr ""
Loading
Loading