[IMP] Implement many2one initiall work.
bzr revid: sma@tinyerp.com-20110427122051-h80fka7fqjz0fcpz
This commit is contained in:
parent
ceb524e337
commit
5060d7111c
|
@ -420,6 +420,12 @@ class DataSet(openerpweb.Controller):
|
|||
r = m.default_get(fields, context)
|
||||
return {'result': r}
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def name_search(self, req, model, search_str, domain=[], context={}):
|
||||
m = req.session.model(model)
|
||||
r = m.name_search(search_str, domain, 'ilike', context)
|
||||
return {'result': r}
|
||||
|
||||
class View(openerpweb.Controller):
|
||||
def fields_view_get(self, request, model, view_id, view_type,
|
||||
transform=True, toolbar=False, submenu=False):
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<script type="text/javascript" src="/base/static/src/js/list.js"></script>
|
||||
<script type="text/javascript" src="/base/static/src/js/search.js"></script>
|
||||
<script type="text/javascript" src="/base/static/src/js/views.js"></script>
|
||||
<script type="text/javascript" src="/base/static/src/js/m2o.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui.notify/css/ui.notify.css" />
|
||||
|
|
|
@ -779,3 +779,62 @@ body.openerp {
|
|||
background: url(http://placekitten.com/g/212/100) repeat;
|
||||
}
|
||||
|
||||
/* Many2one Autosearch */
|
||||
|
||||
.openerp .combo_img {
|
||||
position: absolute;
|
||||
margin-left: -19px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.openerp .autoTextResults {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
background-color: #fff;
|
||||
border: 1px solid #333;
|
||||
display: none;
|
||||
padding: 0 2px 0 2px;
|
||||
min-width: 132px;
|
||||
border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
color: #1F1F1F;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable {
|
||||
border: none;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 13px;
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
font-weight: normal;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable tr.autoTextNormalRow td {
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable tr.autoTextSelectedRow td {
|
||||
background-color: DarkGray;
|
||||
color: #1F1F1F;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable ul{
|
||||
list-style-image:none;
|
||||
list-style-type:none;
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable td a.autoTextHighlight {
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.openerp table.autoTextTable td.autoTextHidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ------------- End autocomplete ------- */
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ openerp.base = function(instance) {
|
|||
openerp.base.views(instance);
|
||||
openerp.base.search(instance);
|
||||
openerp.base.list(instance);
|
||||
openerp.base.m2o(instance);
|
||||
openerp.base.form(instance);
|
||||
};
|
||||
|
||||
|
|
|
@ -118,6 +118,16 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
|
|||
ids: ids,
|
||||
args: args
|
||||
}, callback);
|
||||
|
||||
},
|
||||
name_search: function (search_str, callback) {
|
||||
search_str = search_str || '';
|
||||
return this.rpc('/base/dataset/name_search', {
|
||||
model: this.model,
|
||||
search_str: search_str,
|
||||
domain: this.domain || [],
|
||||
context: this.context
|
||||
}, callback);
|
||||
},
|
||||
exec_workflow: function (id, signal, callback) {
|
||||
return this.rpc('/base/dataset/exec_workflow', {
|
||||
|
|
|
@ -824,10 +824,24 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({
|
|||
}
|
||||
});
|
||||
|
||||
openerp.base.form.FieldMany2OneDatasSet = openerp.base.DataSetStatic.extend({
|
||||
start: function() {
|
||||
},
|
||||
write: function (id, data, callback) {
|
||||
this._super(id, data, callback);
|
||||
},
|
||||
});
|
||||
|
||||
openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
|
||||
init: function(view, node) {
|
||||
this._super(view, node);
|
||||
this.template = "FieldMany2One";
|
||||
this.is_field_m2o = true;
|
||||
},
|
||||
start: function() {
|
||||
this.$element = $('#' + this.element_id);
|
||||
this.dataset = new openerp.base.form.FieldMany2OneDatasSet(this.session, this.field.relation);
|
||||
new openerp.base.m2o(this.$element, this.field.relation, this.dataset)
|
||||
},
|
||||
set_value: function(value) {
|
||||
this._super.apply(this, arguments);
|
||||
|
@ -837,6 +851,8 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
|
|||
this.value = value[0];
|
||||
}
|
||||
this.$element.find('input').val(show_value);
|
||||
// Need to replace this `text` with original `id` after discuss with xmo
|
||||
this.$element.find('input').attr('text', this.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@
|
|||
<t t-foreach="row" t-as="td">
|
||||
<td t-att-colspan="td.colspan gt 1 ? td.colspan : undefined"
|
||||
t-att-width="td.width ? td.width : undefined"
|
||||
t-att-nowrap="td.is_field_label ? 'true' : undefined"
|
||||
t-att-nowrap="td.is_field_label or td.is_field_m2o? 'true' : undefined"
|
||||
t-att-valign="td.table ? 'top' : undefined"
|
||||
t-att-id="td.element_id"
|
||||
t-att-class="'oe_form_' + (td.is_field_label ? 'label' : (td.field ? 'field_' + td.type : td.type))"
|
||||
|
@ -343,7 +343,10 @@
|
|||
t-att-name="widget.name"
|
||||
t-att-id="widget.element_id + '_field'"
|
||||
t-att-class="'field_' + widget.type"
|
||||
t-att-type="widget.type"
|
||||
style="width: 100%;"/>
|
||||
<img t-att-id="widget.name + '_select'" t-att-src="'/base/static/src/img/icons/index1.jpeg'" t-att-class="'combo_img'" width="15" height="16"/>
|
||||
<div t-att-id="'autoCompleteResults_' + widget.name" t-att-class="'autoTextResults'"></div>
|
||||
</t>
|
||||
<t t-name="FieldOne2Many">
|
||||
<div t-att-id="widget.element_id">
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<script src="/base/static/src/js/data.js"></script>
|
||||
<script src="/base/static/src/js/views.js"></script>
|
||||
<script src="/base/static/src/js/search.js"></script>
|
||||
<script src="/base/static/src/js/m2o.js"></script>
|
||||
<script src="/base/static/src/js/form.js"></script>
|
||||
<script src="/base/static/src/js/list.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
|
Loading…
Reference in New Issue