[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_partial = self.cr.fetchall()
partners_amount = dict((i[0],0) for i in partners_partial) partners_amount = dict((i[0],0) for i in partners_partial)
for partner_info in partners_partial: for partner_info in partners_partial:
partial = False
if partner_info[2]: if partner_info[2]:
# in case of partial reconciliation, we want to keep the left amount in the oldest period # 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],)) 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() date = self.cr.fetchall()
if date and args_list[-3] <= date[0][0] <= args_list[-2]: if date and args_list[-3] <= date[0][0] <= args_list[-2]:
# partial reconcilation # partial reconcilation
partial = True
self.cr.execute('''SELECT SUM(l.debit-l.credit) self.cr.execute('''SELECT SUM(l.debit-l.credit)
FROM account_move_line AS l FROM account_move_line AS l
WHERE l.reconcile_partial_id = %s''', (partner_info[2],)) WHERE l.reconcile_partial_id = %s''', (partner_info[2],))
unreconciled_amount = self.cr.fetchall() unreconciled_amount = self.cr.fetchall()
partners_amount[partner_info[0]] += unreconciled_amount[0][0] partners_amount[partner_info[0]] += unreconciled_amount[0][0]
else: if not partial:
partners_amount[partner_info[0]] += partner_info[1] partners_amount[partner_info[0]] += partner_info[1]
history.append(partners_amount) history.append(partners_amount)

View File

@ -471,11 +471,14 @@ class email_template(osv.osv):
results = dict() results = dict()
for template, template_res_ids in templates_to_res_ids.iteritems(): for template, template_res_ids in templates_to_res_ids.iteritems():
# generate fields value for all res_ids linked to the current template # 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: for field in fields:
generated_field_values = self.render_template_batch( generated_field_values = self.render_template_batch(
cr, uid, getattr(template, field), template.model, template_res_ids, cr, uid, getattr(template, field), template.model, template_res_ids,
post_process=(field == 'body_html'), post_process=(field == 'body_html'),
context=context) context=ctx)
for res_id, field_value in generated_field_values.iteritems(): for res_id, field_value in generated_field_values.iteritems():
results.setdefault(res_id, dict())[field] = field_value results.setdefault(res_id, dict())[field] = field_value
# compute recipients # compute recipients
@ -503,13 +506,9 @@ class email_template(osv.osv):
if template.report_template: if template.report_template:
for res_id in template_res_ids: for res_id in template_res_ids:
attachments = [] 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 = report_xml_pool.browse(cr, uid, template.report_template.id, context)
report_service = report.report_name 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']: 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' 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') email_template = self.pool.get('email.template')
ir_model_pool = self.pool.get('ir.model') ir_model_pool = self.pool.get('ir.model')
for record in self.browse(cr, uid, ids, context=context): 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_id = model_ids and model_ids[0] or False
model_name = '' model_name = ''
if model_id: if model_id:

View File

@ -1160,7 +1160,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}, },
build_eval_context: function() { build_eval_context: function() {
var a_dataset = this.dataset; 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; var self = this;
self.load_views(); self.load_views();
this.is_loaded.done(function() { var destroy = function() {
self.on("change:effective_readonly", self, function() {
self.is_loaded = self.is_loaded.then(function() { self.is_loaded = self.is_loaded.then(function() {
self.viewmanager.destroy(); self.viewmanager.destroy();
return $.when(self.load_views()).done(function() { return $.when(self.load_views()).done(function() {
self.reload_current_view(); 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.is_started = true;
this.reload_current_view(); this.reload_current_view();
}, },