[IMP] Thread widget: added management of options: thread level can now be passed as an option to the widget (updated for mail.group, res.users, res.partner)

bzr revid: tde@openerp.com-20120515100530-rxko9551pdzo0luc
This commit is contained in:
Thibault Delavallée 2012-05-15 12:05:30 +02:00
parent aee88a31e7
commit c00875e138
4 changed files with 11 additions and 10 deletions

View File

@ -69,7 +69,8 @@
<label string="This group is visible by non members" colspan="2"/>
</group>
</group>
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"/>
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"
options='{"thread_level": 1}'/>
</form>
</field>
</record>

View File

@ -13,7 +13,8 @@
<attribute name="invisible">False</attribute>
</xpath>
<xpath expr="/form/notebook" position="after">
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"/>
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"
options='{"thread_level": 1}'/>
</xpath>
</field>
</record>
@ -30,4 +31,4 @@
</record>
</data>
</openerp>
</openerp>

View File

@ -28,7 +28,8 @@
</field>
<xpath expr="/form/sheet" position="after">
<div class="oe_form_sheet_width">
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"/>
<field name="message_ids" colspan="4" widget="ThreadView" nolabel="1"
options='{"thread_level": 1}'/>
</div>
</xpath>
</data>

View File

@ -476,10 +476,12 @@ openerp.mail = function(session) {
// QWeb template to use when rendering the object
template: 'RecordThread',
init: function() {
init: function() {
this._super.apply(this, arguments);
this.see_subscribers = true;
this.thread = null;
this.params = this.get_definition_options();
this.params.thread_level = this.params.thread_level || 0;
// datasets
this.ds = new session.web.DataSet(this, this.view.model);
this.ds_users = new session.web.DataSet(this, 'res.users');
@ -520,12 +522,8 @@ openerp.mail = function(session) {
// create and render Thread widget
this.$element.find('div.oe_mail_recthread_left').empty();
if (this.thread) this.thread.destroy();
// hack: for groups and users
if (this.view.model == 'mail.group') thread_level = 1;
if (this.view.model == 'res.users') thread_level = 1;
else thread_level = 0;
this.thread = new mail.Thread(this, {'res_model': this.view.model, 'res_id': this.view.datarecord.id, 'uid': this.session.uid,
'thread_level': thread_level, 'show_post_comment': true, 'limit': 15});
'thread_level': this.params.thread_level, 'show_post_comment': true, 'limit': 15});
var thread_done = this.thread.appendTo(this.$element.find('div.oe_mail_recthread_left'));
return fetch_sub_done && thread_done;
},