diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index a3769e08818..896f359beae 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -20,6 +20,7 @@ ############################################################################## from openerp.osv import fields, osv, expression +from openerp.tools import float_is_zero from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp from openerp.report import report_sxw @@ -597,7 +598,7 @@ class account_bank_statement_line(osv.osv): domain += [(amount_field, '<', 0), (amount_field, '>', (sign * amount))] else: domain += [(amount_field, '>', 0), (amount_field, '<', (sign * amount))] - mv_lines = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, limit=5, additional_domain=domain) + mv_lines = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, limit=5, additional_domain=domain, context=context) ret = [] total = 0 for line in mv_lines: @@ -841,6 +842,11 @@ class account_bank_statement_line(osv.osv): if mv_line_dict.get('counterpart_move_line_id'): #post an account line that use the same currency rate than the counterpart (to balance the account) and post the difference in another line ctx['date'] = mv_line.date + if mv_line.currency_id.id == mv_line_dict['currency_id'] \ + and float_is_zero(abs(mv_line.amount_currency) - abs(mv_line_dict['amount_currency']), precision_rounding=mv_line.currency_id.rounding): + debit_at_old_rate = mv_line.credit + credit_at_old_rate = mv_line.debit + else: debit_at_old_rate = currency_obj.compute(cr, uid, st_line_currency.id, company_currency.id, mv_line_dict['debit'], context=ctx) credit_at_old_rate = currency_obj.compute(cr, uid, st_line_currency.id, company_currency.id, mv_line_dict['credit'], context=ctx) mv_line_dict['credit'] = credit_at_old_rate diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 73ce713d994..2c4b9ef0bb1 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -131,7 +131,7 @@ class account_invoice(models.Model): continue # Get the correct line residual amount if line.currency_id == self.currency_id: - line_amount = line.currency_id and line.amount_residual_currency or line.amount_residual + line_amount = line.amount_residual_currency if line.currency_id else line.amount_residual else: from_currency = line.company_id.currency_id.with_context(date=line.date) line_amount = from_currency.compute(line.amount_residual, self.currency_id) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 77a6ff2ed86..520b3ddad80 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -867,12 +867,17 @@ class account_move_line(osv.osv): total_amount_currency_str = rml_parser.formatLang(total_amount, currency_obj=line_currency) ret_line['credit_currency'] = actual_credit ret_line['debit_currency'] = actual_debit - ctx = context.copy() - if target_date: - ctx.update({'date': target_date}) - total_amount = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, total_amount, context=ctx) - actual_debit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_debit, context=ctx) - actual_credit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_credit, context=ctx) + if target_currency == company_currency: + actual_debit = debit + actual_credit = credit + total_amount = debit or credit + else: + ctx = context.copy() + if target_date: + ctx.update({'date': target_date}) + total_amount = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, total_amount, context=ctx) + actual_debit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_debit, context=ctx) + actual_credit = currency_obj.compute(cr, uid, line_currency.id, target_currency.id, actual_credit, context=ctx) amount_str = rml_parser.formatLang(actual_debit or actual_credit, currency_obj=target_currency) total_amount_str = rml_parser.formatLang(total_amount, currency_obj=target_currency) diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index dd2f40560d0..9e042712ed0 100644 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -134,7 +134,7 @@ class account_entries_report(osv.osv): l.amount_currency as amount_currency, l.debit as debit, l.credit as credit, - l.debit-l.credit as balance + coalesce(l.debit, 0.0) - coalesce(l.credit, 0.0) as balance from account_move_line l left join account_account a on (l.account_id = a.id) diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index 86a5172005d..da0e51a8680 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -236,7 +236,7 @@ openerp.account = function (instance) { // Display the reconciliations return self.model_bank_statement_line - .call("get_data_for_reconciliations", [reconciliations_to_show]) + .call("get_data_for_reconciliations", [reconciliations_to_show], {context:self.session.user_context}) .then(function (data) { var child_promises = []; while ((datum = data.shift()) !== undefined) @@ -1638,7 +1638,7 @@ openerp.account = function (instance) { limit += 1; // Let's fetch 1 more item than requested if (limit > 0) { return self.model_bank_statement_line - .call("get_move_lines_for_reconciliation_by_statement_line_id", [self.st_line.id, excluded_ids, self.filter, offset, limit]) + .call("get_move_lines_for_reconciliation_by_statement_line_id", [self.st_line.id, excluded_ids, self.filter, offset, limit], {context:self.session.user_context}) .then(function (lines) { _.each(lines, function(line) { self.decorateMoveLine(line, self.st_line.currency_id) }, self); // If we could fetch 1 more item than what we'll display, that means there are move lines left to be displayed (so we enable the pager) diff --git a/addons/account/wizard/account_statement_from_invoice.py b/addons/account/wizard/account_statement_from_invoice.py index 658e1b4d829..e43988d1121 100644 --- a/addons/account/wizard/account_statement_from_invoice.py +++ b/addons/account/wizard/account_statement_from_invoice.py @@ -47,8 +47,8 @@ class account_statement_from_invoice_lines(osv.osv_memory): statement_obj = self.pool.get('account.bank.statement') statement_line_obj = self.pool.get('account.bank.statement.line') currency_obj = self.pool.get('res.currency') - line_date = time.strftime('%Y-%m-%d') statement = statement_obj.browse(cr, uid, statement_id, context=context) + line_date = statement.date # for each selected move lines for line in line_obj.browse(cr, uid, line_ids, context=context): diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 90f81e8d884..28f5191666e 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -702,6 +702,9 @@ class calendar_event(osv.Model): val = pytz.UTC.localize(val) return val.astimezone(timezone) + if context is None: + context = {} + timezone = pytz.timezone(context.get('tz') or 'UTC') startdate = pytz.UTC.localize(datetime.strptime(event.start, DEFAULT_SERVER_DATETIME_FORMAT)) # Add "+hh:mm" timezone if not startdate: diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index b07b21e02a6..3fad50e1595 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -408,8 +408,8 @@
-