From: niv-openerp Date: Fri, 4 Oct 2013 15:37:34 +0000 (+0200) Subject: still some problems X-Git-Tag: InsPy_master01~895^2~3 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=63c0220d3152332e54f118c6affc9fffcacde3dd;p=odoo%2Fodoo.git still some problems bzr revid: nicolas.vanhoren@openerp.com-20131004153734-rxdt32qvu3gcxip2 --- diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a00b66c..2069a33 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5701,6 +5701,80 @@ instance.web.form.FieldMany2ManyCheckBoxes = instance.web.form.AbstractField.ext }, }); +instance.web.form.X2ManyCounter = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { + className: "oe_form_x2many_counter", + init: function() { + this._super.apply(this, arguments); + this.set("value", []); + _.defaults(this.options, { + "views": [[false, "tree"], [false, "form"]], + }); + }, + render_value: function() { + var text = _.str.sprintf("%d %s", this.val().length, this.string); + this.$().html(QWeb.render("X2ManyCounter", {text: text})); + this.$("a").click(_.bind(this.go_to, this)); + }, + go_to: function() { + return this.view.recursive_save().then(_.bind(function() { + var val = this.val(); + var context = {}; + +/* +Object {groups_id: Array[0], domain: false, help: "

Click here to …documents, etc.↵

↵ ", res_model: "project.task", search_view_id: Array[2]…} +auto_refresh: 0 +auto_search: true +context: Class +domain: false +filter: false +flags: Object +groups_id: Array[0] +help: "

Click here to add new tasks

↵ OpenERP's project management allows you to manage the pipeline↵ of tasks in order to get things done efficiently. You can↵ track progress, discuss on tasks, attach documents, etc.↵

↵ " +id: 151 +limit: 80 +multi: false +name: "Tasks" +res_id: 0 +res_model: "project.task" +search_view: "{'name': u'project.task.search.form', 'fields': {'categ_ids': {'domain': [], 'string': 'Tags', 'views': {}, 'm2m_join_columns': ['project_task_id', 'project_category_id'], 'm2m_join_table': 'project_category_project_task_rel', 'relation': 'project.category', 'context': {}, 'selectable': True, 'type': 'many2many'}, 'partner_id': {'domain': [], 'string': 'Customer', 'views': {}, 'relation': 'res.partner', 'context': {}, 'selectable': True, 'type': 'many2one'}, 'user_id': {'domain': [], 'string': 'Assigned to', 'views': {}, 'relation': 'res.users', 'context': {}, 'selectable': True, 'type': 'many2one'}, 'project_id': {'domain': [], 'string': 'Project', 'views': {}, 'relation': 'project.project', 'context': {}, 'selectable': True, 'type': 'many2one', 'select': '1'}, 'stage_id': {'domain': "[('project_ids', '=', project_id)]", 'string': 'Stage', 'views': {}, 'relation': 'project.task.type', 'context': {}, 'selectable': True, 'type': 'many2one'}, 'name': {'string': 'Task Summary', 'views': {}, 'required': True, 'selectable': True, 'type': 'char', 'select': True, 'size': 128}}, 'arch': '\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ', 'model': 'project.task', 'type': u'search', 'view_id': 288, 'field_parent': False}" +search_view_id: Array[2] +src_model: false +target: "current" +type: "ir.actions.act_window" +usage: false +view_id: false +view_ids: Array[0] +view_mode: "kanban,list,form,calendar,gantt,graph" +views: Array[6] +__proto__: Object +*/ + + if (this.field.type === "one2many") { + context["default_" + this.field.relation_field] = this.view.datarecord.id; + } + context["search_default_"+ this.field.relation_field] = [this.view.datarecord.id]; + return this.do_action({ + type: 'ir.actions.act_window', + auto_search: true, + name: this.string, + res_model: this.field.relation, + res_id: val.length >= 1 ? val[0] : false, + res_ids: val, + views: this.options.views, + target: 'current', + context: {}, + }); + }, this)); + }, + val: function() { + var value = this.get("value") || []; + if (value.length >= 1 && value[0] instanceof Array) { + value = value[0][2]; + } + return value; + } +}); + /** * Registry of form fields, called by :js:`instance.web.FormView`. * @@ -5737,6 +5811,7 @@ instance.web.form.widgets = new instance.web.Registry({ 'statusbar': 'instance.web.form.FieldStatus', 'monetary': 'instance.web.form.FieldMonetary', 'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes', + 'x2many_counter': 'instance.web.form.X2ManyCounter', }); /** diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 48c51c4..20ee254 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1947,4 +1947,7 @@ + + +