[MERGE] forward port of branch saas-3 up to e11d1c2

This commit is contained in:
Denis Ledoux 2014-12-11 14:11:33 +01:00
commit a6212d2d20
4 changed files with 19 additions and 16 deletions

View File

@ -177,18 +177,20 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
partners_partial = self.cr.fetchall()
partners_amount = dict((i[0],0) for i in partners_partial)
for partner_info in partners_partial:
partial = False
if partner_info[2]:
# in case of partial reconciliation, we want to keep the left amount in the oldest period
self.cr.execute('''SELECT MIN(COALESCE(date_maturity,date)) FROM account_move_line WHERE reconcile_partial_id = %s''', (partner_info[2],))
date = self.cr.fetchall()
if date and args_list[-3] <= date[0][0] <= args_list[-2]:
# partial reconcilation
partial = True
self.cr.execute('''SELECT SUM(l.debit-l.credit)
FROM account_move_line AS l
WHERE l.reconcile_partial_id = %s''', (partner_info[2],))
unreconciled_amount = self.cr.fetchall()
partners_amount[partner_info[0]] += unreconciled_amount[0][0]
else:
if not partial:
partners_amount[partner_info[0]] += partner_info[1]
history.append(partners_amount)

View File

@ -471,11 +471,14 @@ class email_template(osv.osv):
results = dict()
for template, template_res_ids in templates_to_res_ids.iteritems():
# generate fields value for all res_ids linked to the current template
ctx = context.copy()
if template.lang:
ctx['lang'] = template._context.get('lang')
for field in fields:
generated_field_values = self.render_template_batch(
cr, uid, getattr(template, field), template.model, template_res_ids,
post_process=(field == 'body_html'),
context=context)
context=ctx)
for res_id, field_value in generated_field_values.iteritems():
results.setdefault(res_id, dict())[field] = field_value
# compute recipients
@ -503,13 +506,9 @@ class email_template(osv.osv):
if template.report_template:
for res_id in template_res_ids:
attachments = []
report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context)
report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=ctx)
report = report_xml_pool.browse(cr, uid, template.report_template.id, context)
report_service = report.report_name
# Ensure report is rendered using template's language
ctx = context.copy()
if template.lang:
ctx['lang'] = self.render_template_batch(cr, uid, template.lang, template.model, [res_id], context)[res_id] # take 0 ?
if report.report_type in ['qweb-html', 'qweb-pdf']:
result, format = self.pool['report'].get_pdf(cr, uid, [res_id], report_service, context=ctx), 'pdf'

View File

@ -129,7 +129,7 @@ class mail_compose_message(osv.TransientModel):
email_template = self.pool.get('email.template')
ir_model_pool = self.pool.get('ir.model')
for record in self.browse(cr, uid, ids, context=context):
model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model)], context=context)
model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model or 'mail.message')], context=context)
model_id = model_ids and model_ids[0] or False
model_name = ''
if model_id:

View File

@ -1160,7 +1160,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
build_eval_context: function() {
var a_dataset = this.dataset;
return new instance.web.CompoundContext(a_dataset.get_context(), this._build_view_fields_values());
return new instance.web.CompoundContext(this._build_view_fields_values(), a_dataset.get_context());
},
});
@ -4046,16 +4046,18 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var self = this;
self.load_views();
this.is_loaded.done(function() {
self.on("change:effective_readonly", self, function() {
self.is_loaded = self.is_loaded.then(function() {
self.viewmanager.destroy();
return $.when(self.load_views()).done(function() {
self.reload_current_view();
});
var destroy = function() {
self.is_loaded = self.is_loaded.then(function() {
self.viewmanager.destroy();
return $.when(self.load_views()).done(function() {
self.reload_current_view();
});
});
};
this.is_loaded.done(function() {
self.on("change:effective_readonly", self, destroy);
});
this.view.on("on_button_cancel", self, destroy);
this.is_started = true;
this.reload_current_view();
},