diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 5b45f8dd02a..cc4dada2317 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -177,6 +177,8 @@ class account_invoice(models.Model): def _compute_payments(self): partial_lines = lines = self.env['account.move.line'] for line in self.move_id.line_id: + if line.account_id != self.account_id: + continue if line.reconcile_id: lines |= line.reconcile_id.line_id elif line.reconcile_partial_id: diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index 417169fa8cb..766db9e1a99 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -23,7 +23,7 @@ Invoice - Send by Email ${(object.user_id.email or object.company_id.email or 'noreply@localhost')|safe} - ${object.company_id.name} Invoice (Ref ${object.number or 'n/a'}) + ${object.company_id.name|safe} Invoice (Ref ${object.number or 'n/a'}) ${object.partner_id.id} diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 3fcae5d711b..1983d7ec9fc 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -69,7 +69,7 @@ - + diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index 9ad646df32c..e044e603207 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -133,7 +133,7 @@ class account_fiscalyear_close(osv.osv_memory): FROM account_account a LEFT JOIN account_account_type t ON (a.user_type = t.id) WHERE a.active - AND a.type != 'view' + AND a.type not in ('view', 'consolidation') AND a.company_id = %s AND t.close_method = %s''', (company_id, 'unreconciled', )) account_ids = map(lambda x: x[0], cr.fetchall()) @@ -184,7 +184,7 @@ class account_fiscalyear_close(osv.osv_memory): FROM account_account a LEFT JOIN account_account_type t ON (a.user_type = t.id) WHERE a.active - AND a.type != 'view' + AND a.type not in ('view', 'consolidation') AND a.company_id = %s AND t.close_method = %s''', (company_id, 'detail', )) account_ids = map(lambda x: x[0], cr.fetchall()) @@ -213,7 +213,7 @@ class account_fiscalyear_close(osv.osv_memory): FROM account_account a LEFT JOIN account_account_type t ON (a.user_type = t.id) WHERE a.active - AND a.type != 'view' + AND a.type not in ('view', 'consolidation') AND a.company_id = %s AND t.close_method = %s''', (company_id, 'balance', )) account_ids = map(lambda x: x[0], cr.fetchall()) diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index 8121f7890eb..32e4d6cf66e 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -210,7 +210,7 @@ class account_analytic_plan_instance(osv.osv): ana_plan_instance_obj = self.pool.get('account.analytic.plan.instance') acct_anal_acct = self.pool.get('account.analytic.account') acct_anal_plan_line_obj = self.pool.get('account.analytic.plan.line') - if context and 'journal_id' in context: + if context and context.get('journal_id'): journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) pids = ana_plan_instance_obj.search(cr, uid, [('name','=',vals['name']), ('code','=',vals['code']), ('plan_id','<>',False)], context=context) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 8ef17fa886c..a4d9f48e359 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -22,6 +22,7 @@ ############################################################################## from openerp.osv import osv, fields +from openerp.tools.float_utils import float_round as round class account_invoice_line(osv.osv): _inherit = "account.invoice.line" @@ -36,11 +37,12 @@ class account_invoice_line(osv.osv): company_currency = inv.company_id.currency_id.id def get_price(cr, uid, inv, company_currency, i_line, price_unit): cur_obj = self.pool.get('res.currency') + decimal_precision = self.pool.get('decimal.precision') if inv.currency_id.id != company_currency: price = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, price_unit * i_line.quantity, context={'date': inv.date_invoice}) else: price = price_unit * i_line.quantity - return price + return round(price, decimal_precision.precision_get(cr, uid, 'Account')) if inv.type in ('out_invoice','out_refund'): for i_line in inv.invoice_line: @@ -118,6 +120,8 @@ class account_invoice_line(osv.osv): fpos = i_line.invoice_id.fiscal_position or False a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) diff_res = [] + decimal_precision = self.pool.get('decimal.precision') + account_prec = decimal_precision.precision_get(cr, uid, 'Account') # calculate and write down the possible price difference between invoice price and product price for line in res: if a == line['account_id'] and i_line.product_id.id == line['product_id']: @@ -132,14 +136,14 @@ class account_invoice_line(osv.osv): if valuation_stock_move: valuation_price_unit = stock_move_obj.browse(cr, uid, valuation_stock_move[0], context=context).price_unit if valuation_price_unit != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: - price_diff = i_line.price_unit - valuation_price_unit - line.update({'price': valuation_price_unit * line['quantity']}) + price_diff = round(i_line.price_unit - valuation_price_unit, account_prec) + line.update({'price': round(valuation_price_unit * line['quantity'], account_prec)}) diff_res.append({ 'type': 'src', 'name': i_line.name[:64], 'price_unit': price_diff, 'quantity': line['quantity'], - 'price': price_diff * line['quantity'], + 'price': round(price_diff * line['quantity'], account_prec), 'account_id': acc, 'product_id': line['product_id'], 'uos_id': line['uos_id'], diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6341c8b1e10..a02768079f7 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1044,7 +1044,8 @@ class account_voucher(osv.osv): 'period_id': voucher.period_id.id, 'partner_id': voucher.partner_id.id, 'currency_id': company_currency <> current_currency and current_currency or False, - 'amount_currency': company_currency <> current_currency and sign * voucher.amount or 0.0, + 'amount_currency': (sign * abs(voucher.amount) # amount < 0 for refunds + if company_currency != current_currency else 0.0), 'date': voucher.date, 'date_maturity': voucher.date_due } @@ -1210,7 +1211,7 @@ class account_voucher(osv.osv): if line.amount == line.amount_unreconciled: if not line.move_line_id: raise osv.except_osv(_('Wrong voucher line'),_("The invoice you are willing to pay is not valid anymore.")) - sign = voucher.type in ('payment', 'purchase') and -1 or 1 + sign = line.type =='dr' and -1 or 1 currency_rate_difference = sign * (line.move_line_id.amount_residual - amount) else: currency_rate_difference = 0.0 @@ -1268,8 +1269,7 @@ class account_voucher(osv.osv): # otherwise we use the rates of the system amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx) if line.amount == line.amount_unreconciled: - sign = voucher.type in ('payment', 'purchase') and -1 or 1 - foreign_currency_diff = sign * line.move_line_id.amount_residual_currency + amount_currency + foreign_currency_diff = line.move_line_id.amount_residual_currency - abs(amount_currency) move_line['amount_currency'] = amount_currency voucher_line = move_line_obj.create(cr, uid, move_line) diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index e31efa0eb2a..36db9c0da85 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -307,7 +307,7 @@ class account_analytic_account(osv.osv): dom = [] for name2 in name.split('/'): name = name2.strip() - account_ids = self.search(cr, uid, dom + [('name', 'ilike', name)] + args, limit=limit, context=context) + account_ids = self.search(cr, uid, dom + [('name', operator, name)] + args, limit=limit, context=context) if not account_ids: break dom = [('parent_id','in',account_ids)] else: diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index fd55ca114a5..5ef3d15da91 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -901,6 +901,15 @@ class calendar_event(osv.Model): 'partner_ids': fields.many2many('res.partner', 'calendar_event_res_partner_rel', string='Attendees', states={'done': [('readonly', True)]}), 'alarm_ids': fields.many2many('calendar.alarm', 'calendar_alarm_calendar_event_rel', string='Reminders', ondelete="restrict", copy=False), } + + def _get_default_partners(self, cr, uid, ctx=None): + ret = [self.pool['res.users'].browse(cr, uid, uid, context=ctx).partner_id.id] + active_id = ctx.get('active_id') + if ctx.get('active_model') == 'res.partner' and active_id: + if active_id not in ret: + ret.append(active_id) + return ret + _defaults = { 'end_type': 'count', 'count': 1, @@ -913,7 +922,7 @@ class calendar_event(osv.Model): 'interval': 1, 'active': 1, 'user_id': lambda self, cr, uid, ctx: uid, - 'partner_ids': lambda self, cr, uid, ctx: [self.pool['res.users'].browse(cr, uid, [uid], context=ctx)[0].partner_id.id] + 'partner_ids': _get_default_partners, } def _check_closing_date(self, cr, uid, ids, context=None): diff --git a/addons/calendar/calendar_view.xml b/addons/calendar/calendar_view.xml index 0c5f67ab2f9..29cc3e90e9c 100644 --- a/addons/calendar/calendar_view.xml +++ b/addons/calendar/calendar_view.xml @@ -41,7 +41,7 @@

-