jurek
5 years ago
49 changed files with 882 additions and 170 deletions
-
1galicea_base/README.md
-
2galicea_base/__init__.py
-
23galicea_base/__manifest__.py
-
6galicea_base/views/base_menu.xml
-
6galicea_environment_checkup/__init__.py
-
4galicea_environment_checkup/__manifest__.py
-
4galicea_environment_checkup/environment_checkup/__init__.py
-
2galicea_environment_checkup/environment_checkup/custom.py
-
10galicea_environment_checkup/environment_checkup/dependencies.py
-
2galicea_environment_checkup/environment_checkup/runtime.py
-
80galicea_environment_checkup/static/src/js/environment_checkup.js
-
108galicea_environment_checkup/static/src/js/environment_checkup10.js
-
6galicea_environment_checkup/static/src/xml/templates.xml
-
2galicea_environment_checkup/views/views.xml
-
4galicea_git/__manifest__.py
-
8galicea_git/controllers/main.py
-
3galicea_git/data/config.xml
-
7galicea_git/models/repository.py
-
71galicea_git/views/views.org.xml
-
35galicea_git/views/views.xml
-
5galicea_openapi/__init__.py
-
33galicea_openapi/__manifest__.py
-
4galicea_openapi/controllers/__init__.py
-
56galicea_openapi/controllers/api.py
-
22galicea_openapi/doc/helloworld.py
-
41galicea_openapi/doc/test1.py
-
3galicea_openapi/models/__init__.py
-
52galicea_openapi/openapi.py
-
2galicea_openapi/security/ir.model.access.csv
-
BINgalicea_openapi/static/description/icon.png
-
2galicea_openid_connect/__init__.py
-
8galicea_openid_connect/__manifest__.py
-
35galicea_openid_connect/api.py
-
13galicea_openid_connect/controllers/main.py
-
1galicea_openid_connect/models/__init__.py
-
4galicea_openid_connect/models/client.py
-
28galicea_openid_connect/models/config_parameter.py
-
2galicea_openid_connect/random_tokens.py
-
8galicea_openid_connect/security/init.xml
-
5galicea_openid_connect/views/views.xml
-
30galicea_toolset/README.md
-
1galicea_toolset/__init__.py
-
20galicea_toolset/__manifest__.py
-
1galicea_toolset/static/src/js/.#one2many_flexible_widget.js
-
38galicea_toolset/static/src/js/client_actions.js
-
49galicea_toolset/static/src/js/iframe_widget.js
-
68galicea_toolset/static/src/js/one2many_flexible_widget.js
-
16galicea_toolset/utils.py
-
11galicea_toolset/views/data.xml
@ -0,0 +1 @@ |
|||
Base menu for Odoo Galicea Ecosystem |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': "Base menu for Odoo Galicea Ecosystem", |
|||
|
|||
'summary': """ |
|||
Menu only |
|||
""", |
|||
|
|||
'author': "Jurek Wawro", |
|||
'maintainer': "Galicea", |
|||
'website': "http://galicea.pl", |
|||
|
|||
'category': 'Technical Settings', |
|||
'version': '12.0.1.0', |
|||
|
|||
'depends': ['web',], |
|||
|
|||
'data': [ |
|||
'views/base_menu.xml', |
|||
], |
|||
|
|||
'installable': True |
|||
} |
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<menuitem name="Galicea" id="galicea_admin_menu" |
|||
parent="base.menu_administration" groups="base.group_erp_manager" /> |
|||
|
|||
</odoo> |
@ -1,7 +1,9 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
|||
|
|||
from .environment_checkup.custom import custom_check |
|||
from .environment_checkup.core import CheckFail, CheckWarning, CheckSuccess |
|||
|
|||
from . import controllers |
|||
|
|||
from environment_checkup.custom import custom_check |
|||
from environment_checkup.core import CheckFail, CheckWarning, CheckSuccess |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import core |
|||
from . import custom |
@ -0,0 +1,108 @@ |
|||
odoo.define('galicea_environment_checkup', function(require) { |
|||
"use strict"; |
|||
|
|||
var core = require('web.core'); |
|||
var form_common = require('web.form_common'); |
|||
var Widget = require('web.Widget'); |
|||
var session = require('web.session'); |
|||
var QWeb = core.qweb; |
|||
var SystrayMenu = require('web.SystrayMenu'); |
|||
var Model = require('web.Model'); |
|||
|
|||
var Users = new Model('res.users'); |
|||
|
|||
var SystrayIcon = Widget.extend({ |
|||
tagName: 'li', |
|||
events: { |
|||
"click": "on_click", |
|||
}, |
|||
|
|||
start: function(){ |
|||
this.load(this.all_dashboards); |
|||
return this._super(); |
|||
}, |
|||
|
|||
load: function(dashboards){ |
|||
var self = this; |
|||
var loading_done = new $.Deferred(); |
|||
Users.call('has_group', ['base.group_erp_manager']).then(function(is_admin) { |
|||
if (is_admin) { |
|||
session.rpc('/galicea_environment_checkup/data', {}) |
|||
.then(function (data) { |
|||
var counts = { 'success': 0, 'warning': 0, 'fail': 0 }; |
|||
data.forEach(function (check) { ++counts[check.result]; }); |
|||
|
|||
var result; |
|||
if (counts['fail']) { |
|||
result = 'fail'; |
|||
} else if (counts['warning']) { |
|||
result = 'warning'; |
|||
} else { |
|||
result = 'success'; |
|||
} |
|||
|
|||
self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupIcon', { |
|||
'result': result, |
|||
'count': counts['warning'] + counts['fail'] |
|||
})); |
|||
loading_done.resolve(); |
|||
}); |
|||
} else { |
|||
loading_done.resolve(); |
|||
} |
|||
}); |
|||
|
|||
return loading_done; |
|||
}, |
|||
|
|||
on_click: function (event) { |
|||
event.preventDefault(); |
|||
this.do_action('galicea_environment_checkup.dashboard_action', {clear_breadcrumbs: true}); |
|||
}, |
|||
}); |
|||
|
|||
SystrayMenu.Items.push(SystrayIcon); |
|||
|
|||
var Dashboard = Widget.extend({ |
|||
start: function(){ |
|||
return this.load(this.all_dashboards); |
|||
}, |
|||
|
|||
load: function(dashboards) { |
|||
var self = this; |
|||
var loading_done = new $.Deferred(); |
|||
session.rpc('/galicea_environment_checkup/data', {}) |
|||
.then(function (data) { |
|||
self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupDashboard', {'data': data})); |
|||
loading_done.resolve(); |
|||
}); |
|||
return loading_done; |
|||
}, |
|||
}); |
|||
|
|||
core.action_registry.add('galicea_environment_checkup.dashboard', Dashboard); |
|||
|
|||
var FormWidget = form_common.AbstractField.extend({ |
|||
init: function() { |
|||
this._super.apply(this, arguments); |
|||
this.set("value", "[]"); |
|||
}, |
|||
|
|||
render_value: function() { |
|||
var data = JSON.parse(this.get('value')); |
|||
if (data.length == 0) { |
|||
this.replaceElement('<div />'); |
|||
return; |
|||
} |
|||
this.replaceElement(QWeb.render('GaliceaEnvironmentCheckupFormWidget', {'data': data})); |
|||
}, |
|||
}); |
|||
|
|||
core.form_widget_registry.add('environment_checks', FormWidget); |
|||
|
|||
return { |
|||
SystrayIcon: SystrayIcon, |
|||
Dashboard: Dashboard, |
|||
FormWidget: FormWidget |
|||
}; |
|||
}); |
@ -1,9 +1,12 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
|
|||
<record id="config_git_backend_path" model="ir.config_parameter"> |
|||
<field name="key">galicea_git.git_http_backend</field> |
|||
<field name="value">/usr/lib/git-core/git-http-backend</field> |
|||
<field name="group_ids" eval="[(4, ref('galicea_git.group_admin'))]" /> |
|||
</record> |
|||
|
|||
</data> |
|||
</odoo> |
@ -0,0 +1,71 @@ |
|||
<odoo> |
|||
<data> |
|||
<record id="repository_view_form" model="ir.ui.view"> |
|||
<field name="model">galicea_git.repository</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<group> |
|||
<field name="state" invisible="1" /> |
|||
<field name="name" /> |
|||
<field name="system_name" groups="galicea_git.group_admin" /> |
|||
<field name="collaborator_ids" widget="many2many_tags" options="{'no_create': True}" /> |
|||
</group> |
|||
<group class="oe_read_only"> |
|||
<label for="url" /> |
|||
<span style="font-family: monospace">git clone <field name="url" nolabel="True" /></span> |
|||
<field name="local_directory" style="font-family: monospace" /> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="repository_view_tree" model="ir.ui.view"> |
|||
<field name="model">galicea_git.repository</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="state" invisible="1" /> |
|||
<field name="name" /> |
|||
<field name="system_name" groups="galicea_git.group_admin" /> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<act_window id="repository_action" |
|||
name="Git repositories" |
|||
res_model="galicea_git.repository" /> |
|||
|
|||
<record id="config_settings_view_form" model="ir.ui.view"> |
|||
<field name="model">galicea_git.config.settings</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Git hosting settings" class="oe_form_configuration"> |
|||
<header> |
|||
<button string="Save" type="object" name="execute" class="oe_highlight"/> |
|||
<button string="Cancel" type="object" name="cancel" class="oe_link"/> |
|||
</header> |
|||
<field name="git_http_backend_valid" invisible="1" /> |
|||
<group> |
|||
<label for="git_http_backend" /> |
|||
<span> |
|||
<field name="git_http_backend" nolabel="True" class="oe_inline" style="min-width:300px; margin-right:5px" /> |
|||
<i class="fa fa-check" aria-hidden="true" style="color: green" |
|||
attrs="{'invisible': [('git_http_backend_valid', '=', False)]}" /> |
|||
<i class="fa fa-times" aria-hidden="true" style="color: red" |
|||
attrs="{'invisible': [('git_http_backend_valid', '=', True)]}" /> |
|||
</span> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<act_window id="config_settings_action" |
|||
name="Settings" |
|||
res_model="galicea_git.config.settings" |
|||
parent="base.menu_administration" |
|||
view_mode="form" target="inline" /> |
|||
|
|||
<menuitem name="Git hosting" id="git_root_menu" sequence="20" /> |
|||
<menuitem name="Repositories" id="repo_menu" parent="galicea_git.git_root_menu" action="repository_action" sequence="1" /> |
|||
<menuitem name="Settings" id="settings_menu" parent="galicea_git.git_root_menu" action="config_settings_action" sequence="99" |
|||
groups="galicea_git.group_admin" /> |
|||
</data> |
|||
</odoo> |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
#from . import models |
|||
from . import controllers |
|||
|
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': "openapi", |
|||
|
|||
'summary': """ |
|||
Odoo Opnapi |
|||
UWAGA! Obecnie dekorator apiroute ma ograniczoną funkcjonalność. |
|||
M.in. tylko jeden URL |
|||
controllers/api.py zawiera przykład wykorzystania - |
|||
pod adresem /oapi/api zwraca dokumentację w JSON |
|||
""", |
|||
|
|||
'description': """ |
|||
|
|||
""", |
|||
|
|||
'author': 'Jerzy Wawro', |
|||
'maintainer': "Galicea", |
|||
'website': "http://www.galicea.pl", |
|||
'category': 'Tools', |
|||
'version': '12.0.0.1', |
|||
|
|||
'depends': [ |
|||
], |
|||
'external_dependencies': { |
|||
'python': [ 'fastapi', 'pydantic', 'starlette' ] |
|||
}, |
|||
'data': [ |
|||
], |
|||
'application': True, |
|||
'installable': True, |
|||
|
|||
} |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import api |
|||
|
@ -0,0 +1,56 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import json |
|||
|
|||
from fastapi.openapi.docs import get_swagger_ui_html |
|||
|
|||
from odoo import http, _ |
|||
from ..openapi import apiroute |
|||
from ..openapi import oapi |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
class OpenApiTest(http.Controller): |
|||
|
|||
|
|||
@http.route(['/oapi/tst1',], type='http', auth="user", website=True) |
|||
def tst1(self, **kw): |
|||
return "tst1" |
|||
|
|||
@oapi.get('/oapi/tst2') |
|||
@http.route(['/oapi/tst2',], type='http', auth="user", website=True) |
|||
def tst2(self): |
|||
return 'ok test2' |
|||
|
|||
@oapi.api_route('/oapi/tst3') |
|||
@http.route(['/oapi/tst3',], type='http', auth="user", website=True) |
|||
def tst3(self, par1="abc"): |
|||
return par1 |
|||
|
|||
|
|||
@oapi.api_route('/oapi/tst4') |
|||
@http.route(['/oapi/tst4', ], type='http', auth="user", website=True) |
|||
def tst4(self,par1="444"): |
|||
return par1 |
|||
|
|||
|
|||
@apiroute('/oapi/tst5') |
|||
def tst5(self, par1="555"): |
|||
return par1 |
|||
|
|||
@http.route(['/oapi/api',], type='http', auth="user", website=True) |
|||
def api(self, **kw): |
|||
return json.dumps(oapi.openapi()) |
|||
# wynik możesz skopiować do https://editor.swagger.io/ |
|||
|
|||
@http.route(['/oapi/docs',], type='http', auth="user", website=True) |
|||
def api_UI(self, **kw): |
|||
response = get_swagger_ui_html(openapi_url = '/oapi/api', title = 'tytuł') |
|||
return response.body |
|||
|
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,22 @@ |
|||
# pip install fastapi |
|||
# pip install email-validator |
|||
# pip install pydantic |
|||
# pip install starlette |
|||
# pip install uvicorn |
|||
|
|||
import uvicorn |
|||
from fastapi import FastAPI |
|||
|
|||
app = FastAPI() |
|||
|
|||
|
|||
@app.get("/") |
|||
def read_root(): |
|||
return {"Hello": "World"} |
|||
|
|||
def run_server(): |
|||
uvicorn.run(app) |
|||
|
|||
if __name__ == '__main__': |
|||
uvicorn.run(app, #'server:app', |
|||
host='127.0.0.1', port=8000, reload=True) |
@ -0,0 +1,41 @@ |
|||
# pip install fastapi |
|||
# pip install email-validator |
|||
# pip install pydantic |
|||
# pip install starlette |
|||
# pip install uvicorn |
|||
|
|||
import uvicorn |
|||
from fastapi import FastAPI |
|||
from fastapi.openapi.utils import get_openapi |
|||
|
|||
app = FastAPI() |
|||
|
|||
|
|||
@app.get("/items/") |
|||
async def read_items(): |
|||
return [{"name": "Foo"}] |
|||
|
|||
|
|||
def custom_openapi(): |
|||
if app.openapi_schema: |
|||
return app.openapi_schema |
|||
openapi_schema = get_openapi( |
|||
title="Custom title", |
|||
version="2.5.0", |
|||
description="This is a very custom OpenAPI schema", |
|||
routes=app.routes, |
|||
) |
|||
openapi_schema["info"]["x-logo"] = { |
|||
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" |
|||
} |
|||
app.openapi_schema = openapi_schema |
|||
return app.openapi_schema |
|||
|
|||
|
|||
app.openapi = custom_openapi |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
print("see http://127.0.0.1:8000/docs") |
|||
uvicorn.run(app, #'server:app', |
|||
host='127.0.0.1', port=8000, reload=True) |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
|
@ -0,0 +1,52 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
|
|||
import functools |
|||
from fastapi import FastAPI |
|||
from fastapi.openapi.utils import get_openapi |
|||
|
|||
|
|||
|
|||
def custom_openapi(): |
|||
if oapi.openapi_schema: |
|||
return oapi.openapi_schema |
|||
openapi_schema = get_openapi( |
|||
title="Custom title", |
|||
version="2.5.0", |
|||
description="This is a very custom OpenAPI schema", |
|||
routes=oapi.routes, |
|||
) |
|||
openapi_schema["info"]["x-logo"] = { |
|||
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" |
|||
} |
|||
oapi.openapi_schema = openapi_schema |
|||
return oapi.openapi_schema |
|||
|
|||
oapi = FastAPI() |
|||
oapi.openapi = custom_openapi |
|||
|
|||
def apiroute(route=None, **kw): |
|||
|
|||
routing = kw.copy() |
|||
def apidecorator(f): |
|||
if route: |
|||
if isinstance(route, list): |
|||
routes = route |
|||
else: |
|||
routes = [route] |
|||
routing['routes'] = routes |
|||
|
|||
@functools.wraps(f) |
|||
def response_wrap(*args, **kw): |
|||
response = f(*args, **kw) |
|||
return response |
|||
|
|||
oapi.add_api_route(routes[0], f, include_in_schema=True) |
|||
response_wrap.routing = routing |
|||
response_wrap.original_func = f |
|||
return response_wrap |
|||
|
|||
return apidecorator |
|||
|
|||
|
|||
# |
@ -0,0 +1,2 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_galicea_openapi,galicea_openapi,model_galicea_openapi_openapi_script,galicea_openapi.script,1,1,1,0 |
After Width: 128 | Height: 128 | Size: 10 KiB |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from odoo import models, fields, api |
|||
from .. import random_tokens |
|||
try: |
|||
from jwcrypto import jwk |
|||
except ImportError: |
|||
pass |
|||
|
|||
class ConfigParameter(models.Model): |
|||
_inherit = 'ir.config_parameter' |
|||
|
|||
@api.model |
|||
def openid_init_keys(self): |
|||
keys = { |
|||
'galicea_openid_connect.authorization_code_jwk': lambda: \ |
|||
jwk.JWK.generate(kty='oct', size=256, kid=random_tokens.alpha_numeric(16), use='sig', alg='HS256').export(), |
|||
'galicea_openid_connect.id_token_jwk': lambda: \ |
|||
jwk.JWK.generate(kty='RSA', size=2054, kid=random_tokens.alpha_numeric(16), use='sig', alg='RS256').export() |
|||
} |
|||
|
|||
for key, gen in iter(keys.items()): |
|||
if not self.search([('key', '=', key)]): |
|||
self.create({ |
|||
'key': key, |
|||
'value': gen(), |
|||
'group_ids': [(4, self.env.ref('base.group_erp_manager').id)] |
|||
}) |
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<data noupdate="1"> |
|||
<function model="ir.config_parameter" |
|||
name="openid_init_keys" |
|||
/> |
|||
</data> |
|||
</odoo> |
@ -0,0 +1,30 @@ |
|||
Widgets |
|||
======= |
|||
|
|||
<field name="url_field" widget="iframe" style="width: 100%" iframe_style="width: 100%" /> |
|||
|
|||
Creates an iframe with ``url_field`` value as a source. |
|||
|
|||
<field name="article_ids" widget="one2many_flexible" click_target="current" /> |
|||
|
|||
Allows changing the target for the item click action. |
|||
|
|||
Functions |
|||
========= |
|||
odoo.addons.galicea_toolset.utils.get_base_url(env) |
|||
|
|||
Client actions |
|||
============== |
|||
@api.multi |
|||
|
|||
def button_action(self): |
|||
|
|||
return { |
|||
|
|||
'type': 'ir.actions.client', |
|||
|
|||
'tag': 'galicea_toolset.open_edit_dialog', |
|||
|
|||
'params': { 'res_id': <id>, 'res_model': <model>, 'title': <title>} |
|||
|
|||
}; |
@ -0,0 +1 @@ |
|||
# -*- coding: utf-8 -*- |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
{ |
|||
'name': "galicea toolset", |
|||
|
|||
'summary': """ |
|||
A couple of small convenience widgets and functions""", |
|||
|
|||
'author': "Maciej Wawro", |
|||
'maintainer': "Galicea", |
|||
'website': "http://www.galicea.pl", |
|||
|
|||
'category': 'Technical Settings', |
|||
'version': '12.0.0.1', |
|||
|
|||
'depends': ['base'], |
|||
|
|||
'data': [ |
|||
'views/data.xml' |
|||
], |
|||
} |
@ -0,0 +1 @@ |
|||
jurek@jurek.15022 |
@ -0,0 +1,38 @@ |
|||
odoo.define('galicea_toolset.client_actions', function(require) { |
|||
var Widget = require('web.Widget'); |
|||
var core = require('web.core'); |
|||
var common = require('web.form_common'); |
|||
var ActionManager = require('web.ActionManager'); |
|||
|
|||
var OpenEditDialogAction = Widget.extend({ |
|||
init: function(parent, context) { |
|||
this._super.apply(this, arguments); |
|||
this.context = context; |
|||
if (parent instanceof ActionManager) { |
|||
this.am = parent; |
|||
} |
|||
}, |
|||
|
|||
start: function () { |
|||
var params = this.context.params; |
|||
|
|||
var popup = new common.FormViewDialog(self, { |
|||
title: params.title, |
|||
res_model: params.res_model, |
|||
res_id: params.res_id, |
|||
}).open(); |
|||
popup.on('closed', this, function() { |
|||
this.am && this.am.history_back(); |
|||
}); |
|||
}, |
|||
}); |
|||
|
|||
core.action_registry.add( |
|||
'galicea_toolset.open_edit_dialog', |
|||
OpenEditDialogAction |
|||
); |
|||
|
|||
return { |
|||
open_edit_dialog_action: OpenEditDialogAction, |
|||
}; |
|||
}); |
@ -0,0 +1,49 @@ |
|||
odoo.define('pwste_epub.iframe_widget', function(require) { |
|||
|
|||
var AbstractField = require('web.AbstractField'); |
|||
var fieldRegistry = require('web.field_registry'); |
|||
|
|||
|
|||
|
|||
var core = require('web.core'); |
|||
var Widget= require('web.Widget'); |
|||
var widgetRegistry = require('web.widget_registry'); |
|||
var FieldManagerMixin = require('web.FieldManagerMixin'); |
|||
|
|||
var IFrameWidget = AbstractField.extend({ |
|||
|
|||
init: function () { |
|||
this._super.apply(this, arguments); |
|||
// this.set("value", "");
|
|||
}, |
|||
|
|||
_renderReadonly: function() { |
|||
window.widget=this; |
|||
this.$el.html( |
|||
$('<iframe>', { |
|||
src: this.value || 'about:blank', |
|||
style: this.attrs.iframe_style |
|||
}) |
|||
); |
|||
if (this.attrs.new_window_label && this.value) { |
|||
this.$el.prepend( |
|||
$('<a>', { |
|||
href: this.value, |
|||
target: '_blank', |
|||
style: 'float:right; margin-bottom: 10px', |
|||
'class': 'btn btn-primary', |
|||
}).html('<i class="fa fa-external-link-square" aria-hidden="true"></i> Otwórz w nowym oknie') |
|||
) |
|||
} |
|||
}, |
|||
}); |
|||
|
|||
fieldRegistry.add( |
|||
'iframe', IFrameWidget |
|||
); |
|||
|
|||
return { |
|||
IFrameWidget: IFrameWidget, |
|||
}; |
|||
|
|||
}); |
@ -0,0 +1,68 @@ |
|||
odoo.define('galicea_toolset.one2many_flexible_widget', function(require) { |
|||
var core = require('web.core'); |
|||
/* |
|||
var view_dialogs = require('web.view_dialogs'), |
|||
relational_fields = require('web.relational_fields'), |
|||
rpc = require('web.rpc'), |
|||
field_registry = require('web.field_registry');*/ |
|||
|
|||
var form_relational = require('web.form_relational'); |
|||
|
|||
/* var X2ManyList = form_relational.X2ManyList; |
|||
var ListView = require('web.ListView'); |
|||
var FieldOne2Many = field_registry.get('one2many'); |
|||
var FieldOne2Many = relational_fields.FieldOne2Many; |
|||
|
|||
|
|||
var FormController = require('web.FormController'); |
|||
*/ |
|||
/* |
|||
ListView.include({ |
|||
do_activate_record: function (index, id, dataset, view) { |
|||
var action = this.ViewManager.action; |
|||
if (!action || !action.context || !action.context.open_formview) |
|||
return this._super(index, id, dataset, view); |
|||
do_action(this, id, action.context); |
|||
} |
|||
}); |
|||
|
|||
|
|||
var One2ManyListView = core.one2many_view_registry.get('list'); |
|||
*/ |
|||
|
|||
var One2ManyFlexibleListView = form_relational.One2ManyListView.extend({ |
|||
do_activate_record: function(index, id) { |
|||
var self = this; |
|||
if (!this.x2m.get("effective_readonly")) { |
|||
this._super.apply(this, arguments); |
|||
return; |
|||
} |
|||
|
|||
this.do_action({ |
|||
'type': 'ir.actions.act_window', |
|||
'views': [[false, 'form']], |
|||
'res_model': self.x2m.field.relation, |
|||
'res_id': id, |
|||
'target': self.x2m.node.attrs.click_target || 'current', |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
var FieldOne2Many = core.form_widget_registry.get('one2many'); |
|||
|
|||
var FieldOne2ManyFlexible = FieldOne2Many.extend({ |
|||
init: function() { |
|||
this._super.apply(this, arguments); |
|||
this.x2many_views = { |
|||
kanban: core.view_registry.get('one2many_kanban'), |
|||
list: One2ManyFlexibleListView, |
|||
}; |
|||
}, |
|||
}); |
|||
|
|||
core.form_widget_registry.add('one2many_flexible', FieldOne2ManyFlexible); |
|||
|
|||
return { |
|||
FieldOne2ManyFlexible: FieldOne2ManyFlexible, |
|||
}; |
|||
}); |
@ -0,0 +1,16 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from odoo import http |
|||
|
|||
def get_base_url(env): |
|||
""" |
|||
Better host name detection |
|||
@param env odoo.api.Environment""" |
|||
|
|||
if http.request: |
|||
# Preferuj nazwę hosta, która została użyta do tego zapytania |
|||
return http.request.httprequest.host_url |
|||
else: |
|||
# Jeśli nie jesteśmy wewnątrz zapytania HTTP, zwróć domenę ostatnio użytą |
|||
# przez admina do zalogowania |
|||
return env['ir.config_parameter'].get_param('web.base.url') + '/' |
@ -0,0 +1,11 @@ |
|||
<odoo> |
|||
<data> |
|||
<template id="assets_backend" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<script src="/galicea_toolset/static/src/js/iframe_widget.js" type="text/javascript" /> |
|||
<script src="/galicea_toolset/static/src/js/one2many_flexible_widget.js" type="text/javascript" /> |
|||
<script src="/galicea_toolset/static/src/js/client_actions.js" type="text/javascript" /> |
|||
</xpath> |
|||
</template> |
|||
</data> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue