summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-09-11 15:20:44 +0200
committerThibault Delavallée <tde@openerp.com>2012-09-11 15:20:44 +0200
commit13da3d028f2b77827309084d05ba00a1b9cc12fb (patch)
treeb62aa21d9b9a4b3e51eb53a3aad9f5b6e20da2e9
parent52a2174a5d6406a2b74b23782e4e193fd34a00a5 (diff)
parent4ecf30824ec4e5deb3661e6b65c3d0be5827edee (diff)
[MERGE] Merged with addons/trunk.
bzr revid: tde@openerp.com-20120911132044-vqmmkg5tr6ijy5m3
-rw-r--r--addons/email_template/wizard/mail_compose_message.py6
-rw-r--r--addons/email_template/wizard/mail_compose_message_view.xml6
-rw-r--r--addons/mail/static/src/js/mail.js24
-rw-r--r--addons/purchase/purchase_view.xml4
-rw-r--r--addons/sale/edi/sale_order_action_data.xml2
-rw-r--r--addons/sale/sale.py11
-rw-r--r--addons/sale/sale_view.xml6
7 files changed, 35 insertions, 24 deletions
diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py
index 2baef6e6c90..c0cb7fc92e5 100644
--- a/addons/email_template/wizard/mail_compose_message.py
+++ b/addons/email_template/wizard/mail_compose_message.py
@@ -51,9 +51,11 @@ class mail_compose_message(osv.osv_memory):
context = {}
result = super(mail_compose_message, self).default_get(cr, uid, fields, context=context)
result['template_id'] = context.get('default_template_id', context.get('mail.compose.template_id', False))
- # force html when using templates
+ # pre-render the template if any
if result.get('use_template'):
- result['content_subtype'] = 'html'
+ onchange_res = self.onchange_use_template(cr, uid, [], result.get('use_template'), result.get('template_id'),
+ result.get('composition_mode'), result.get('model'), result.get('res_id'), context=context)
+ result.update(onchange_res['value'])
return result
_columns = {
diff --git a/addons/email_template/wizard/mail_compose_message_view.xml b/addons/email_template/wizard/mail_compose_message_view.xml
index 96aaa1cfaae..8d5bc26b213 100644
--- a/addons/email_template/wizard/mail_compose_message_view.xml
+++ b/addons/email_template/wizard/mail_compose_message_view.xml
@@ -11,14 +11,14 @@
<xpath expr="//form/footer/button" position="before">
<field name="use_template" invisible="1"/>
<button icon="gtk-paste" type="object" name="toggle_template"
- string="" help="Use a message template" />
+ string="" help="Use a message template" invisible="1"/>
<button icon="gtk-save" type="object" name="save_as_template"
- string="" help="Save as a new template"/>
+ string="" help="Save as a new template" invisible="1"/>
</xpath>
<xpath expr="//form/notebook" position="after">
<group attrs="{'invisible':[('use_template','=',False)]}" colspan="4" col="4">
<field name="use_template" invisible="1"/>
- <field name="template_id" colspan="3"
+ <field name="template_id" colspan="3" invisible="1"
on_change="onchange_template_id(use_template, template_id, composition_mode, model, res_id, context)"/>
</group>
</xpath>
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index c02b81d0c4f..a4be9456ab3 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -17,19 +17,15 @@ openerp.mail = function(session) {
*/
session.web.FormView = session.web.FormView.extend({
- // TDE FIXME TODO: CHECK WITH NEW BRANCH
do_action: function(action, on_close) {
if (action.res_model == 'mail.compose.message' &&
+ action.context && action.context.redirect == true &&
this.fields && this.fields.message_ids &&
this.fields.message_ids.view.get("actual_mode") != 'create') {
- // debug
- console.groupCollapsed('FormView do_action on mail.compose.message');
- console.log('message_ids field:', this.fields.message_ids);
- console.groupEnd();
var record_thread = this.fields.message_ids;
var thread = record_thread.thread;
- thread.instantiate_composition_form('comment', true, false, 0, action.context);
- return false;
+ thread.refresh_composition_form(action.context);
+ return true;
}
else {
return this._super(action, on_close);
@@ -234,7 +230,7 @@ openerp.mail = function(session) {
this.ds_compose.context = _.extend(this.ds_compose.context, this.options.context);
return this.ds_compose.call('default_get', [
['subject', 'body_text', 'body', 'attachment_ids', 'partner_ids', 'composition_mode',
- 'model', 'res_id', 'parent_id', 'content_subtype'],
+ 'use_template', 'template_id', 'model', 'res_id', 'parent_id', 'content_subtype'],
this.ds_compose.get_context(),
]).then( function (result) { self.form_view.on_processed_onchange({'value': result}, []); });
},
@@ -433,6 +429,11 @@ openerp.mail = function(session) {
return compose_done;
},
+ refresh_composition_form: function (context) {
+ if (! this.compose_message_widget) return;
+ return this.compose_message_widget.refresh(context);
+ },
+
/** Clean the thread */
message_clean: function() {
this.$el.find('div.oe_mail_thread_display').empty();
@@ -611,7 +612,6 @@ openerp.mail = function(session) {
this.options.domain = this.options.domain || [];
this.options.context = {'default_model': 'mail.thread', 'default_res_id': false};
this.options.thread_level = this.options.thread_level || 0;
- this.thread_list = [];
},
start: function() {
@@ -627,7 +627,7 @@ openerp.mail = function(session) {
},
destroy: function() {
- for (var i in this.thread_list) { this.thread_list[i].destroy(); }
+ if (this.thread) { this.thread.destroy(); }
this._super.apply(this, arguments);
},
@@ -644,13 +644,13 @@ openerp.mail = function(session) {
default_model: this.view.model });
// create and render Thread widget
this.$el.find('div.oe_mail_recthread_main').empty();
- for (var i in this.thread_list) { this.thread_list[i].destroy(); }
+ if (this.thread) { this.thread.destroy(); }
var thread = new mail.Thread(self, {
'context': this.options.context,
'thread_level': this.options.thread_level, 'show_header_compose': true,
'message_ids': this.get_value(),
'show_delete': true, 'composer': true });
- this.thread_list.push(thread);
+ this.thread = thread;
return thread.appendTo(this.$el.find('div.oe_mail_recthread_main'));
},
});
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index ab5df67f52d..5d6f6c34b3b 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -347,6 +347,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order</field>
<field name="context">{'search_default_draft': 1}</field>
+ <field name="domain">[('state','in',('draft','sent','confirmed'))]</field>
<field name="view_mode">tree,form,graph,calendar</field>
<field name="search_view_id" ref="view_purchase_order_filter"/>
<field name="help" type="html">
@@ -371,7 +372,8 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order</field>
<field name="view_mode">tree,form,graph,calendar</field>
- <field name="context">{'search_default_approved': 1}</field>
+ <field name="context">{}</field>
+ <field name="domain">[('state','not in',('draft','sent','confirmed'))]</field>
<field name="search_view_id" ref="view_purchase_order_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index 49ebe6053e6..c818a3a22ab 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -47,7 +47,7 @@
<p>Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},</p>
- <p>Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from {$object.company_id.name}: </p>
+ <p>Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 6a6678d6163..553b8993ab8 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -769,13 +769,18 @@ class sale_order(osv.osv):
template_id = template and template[1] or False
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
res_id = res and res[1] or False
- ctx = dict(context, active_model='sale.order', active_id=ids[0])
- ctx.update({'mail.compose.template_id': template_id})
+ ctx = dict(context)
+ ctx.update({
+ 'default_model': 'sale.order',
+ 'default_res_id': ids[0],
+ 'default_use_template': True,
+ 'default_template_id': template_id,
+ })
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
- 'views': [(res_id,'form')],
+ 'views': [(res_id, 'form')],
'view_id': res_id,
'type': 'ir.actions.act_window',
'target': 'new',
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 2c2acff227e..1f077f6601d 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -404,7 +404,8 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="search_view_id" ref="view_sales_order_filter"/>
- <field name="context">{"search_default_sales":1}</field>
+ <field name="context">{}</field>
+ <field name="domain">[('state','not in',('draft','sent','cancel'))]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a quotation that can be converted into a sale
@@ -445,7 +446,8 @@
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
- <field name="context">{"search_default_draft":1}</field>
+ <field name="context">{}</field>
+ <field name="domain">[('state','in',('draft','sent','cancel'))]</field>
<field name="search_view_id" ref="view_sales_order_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">