mirror of https://github.com/OCA/web.git
[IMP] Add 'web_completion_search' module
parent
ee954bbf32
commit
bd8abd2bb8
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Web completion_search',
|
||||
'version': '0.1',
|
||||
'author': 'Akretion, Odoo Community Association (OCA)',
|
||||
'depends': [
|
||||
'web',
|
||||
],
|
||||
'demo': [],
|
||||
'website': 'https://www.akretion.com',
|
||||
'data': [
|
||||
'views/web_completion_search.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
openerp.web_completion_search = function(instance, local) {
|
||||
var _t = instance.web._t;
|
||||
|
||||
|
||||
instance.web.form.CompletionFieldMixin.init = function() {
|
||||
if (this.field.type == 'many2many') {
|
||||
this.limit = 0;
|
||||
} else {
|
||||
this.limit = 7;
|
||||
}
|
||||
this.orderer = new instance.web.DropMisordered();
|
||||
};
|
||||
|
||||
instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) {
|
||||
var self = this;
|
||||
var pop = new instance.web.form.SelectCreatePopup(this);
|
||||
pop.select_element(
|
||||
self.field.relation,
|
||||
{
|
||||
title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string,
|
||||
initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined,
|
||||
initial_view: view,
|
||||
disable_multiple_selection: this.field.type != 'many2many',
|
||||
},
|
||||
self.build_domain(),
|
||||
new instance.web.CompoundContext(self.build_context(), context || {})
|
||||
);
|
||||
pop.on("elements_selected", self, function(element_ids) {
|
||||
for(var i=0, len=element_ids.length; i<len;i++) {
|
||||
self.add_id(element_ids[i]);
|
||||
if (self.field.type != 'many2many') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.focus();
|
||||
});
|
||||
};
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="web_completion_search" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/web_completion_search/static/src/js/view_form.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue