diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 3885973415f..6544752ff62 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -174,6 +174,8 @@ class account_invoice(osv.osv): lines = [] if invoice.move_id: for m in invoice.move_id.line_id: + if m.account_id != invoice.account_id: + continue temp_lines = [] if m.reconcile_id: temp_lines = map(lambda x: x.id, m.reconcile_id.line_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 eebc95ae0e2..21d751725a1 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -32,7 +32,7 @@ - + diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index 266b8ccbc50..52708b6e87a 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -132,7 +132,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()) @@ -182,7 +182,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()) @@ -211,7 +211,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 23a309c1dda..f98fce52413 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 a16a542445d..2aeafd74053 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1039,7 +1039,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 } @@ -1201,7 +1202,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 @@ -1259,8 +1260,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 61e5c1166ea..9b4daab3c2b 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -302,7 +302,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 b6473a7f1a7..3e51407339b 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -903,6 +903,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"), } + + 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, @@ -915,7 +924,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 4c17e3e8e70..68d2cfb40f0 100644 --- a/addons/calendar/calendar_view.xml +++ b/addons/calendar/calendar_view.xml @@ -41,7 +41,7 @@

-