diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 44d70dc8040..79fa7a4d848 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -356,13 +356,22 @@ class account_invoice(osv.osv): if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']: partner = self.pool[context['active_model']].read(cr, uid, context['active_ids'], ['supplier','customer'])[0] if not view_type: - view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')]) + try: + view_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'invoice_tree')[1] + except ValueError: + view_id = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'account.invoice.tree')], limit=1) view_type = 'tree' if view_type == 'form': if partner['supplier'] and not partner['customer']: - view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')]) + try: + view_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'invoice_supplier_form')[1] + except ValueError: + view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')], limit=1) elif partner['customer'] and not partner['supplier']: - view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')]) + try: + view_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'invoice_form')[1] + except ValueError: + view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')], limit=1) if view_id and isinstance(view_id, (list, tuple)): view_id = view_id[0] res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py index 53edbbe9685..91d2ff999f2 100644 --- a/addons/account/report/account_partner_balance.py +++ b/addons/account/report/account_partner_balance.py @@ -32,10 +32,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): self.account_ids = [] self.localcontext.update( { 'time': time, - 'lines': self.lines, - 'sum_debit': self._sum_debit, - 'sum_credit': self._sum_credit, - 'sum_litige': self._sum_litige, 'get_fiscalyear': self._get_fiscalyear, 'get_journal': self._get_journal, 'get_filter': self._get_filter, @@ -69,7 +65,20 @@ class partner_balance(report_sxw.rml_parse, common_report_header): "WHERE a.type IN %s " \ "AND a.active", (self.ACCOUNT_TYPE,)) self.account_ids = [a for (a,) in self.cr.fetchall()] - return super(partner_balance, self).set_context(objects, data, ids, report_type=report_type) + res = super(partner_balance, self).set_context(objects, data, ids, report_type=report_type) + lines = self.lines() + sum_debit = sum_credit = sum_litige = 0 + for line in filter(lambda x: x['type'] == 3, lines): + sum_debit += line['debit'] or 0 + sum_credit += line['credit'] or 0 + sum_litige += line['enlitige'] or 0 + self.localcontext.update({ + 'lines': lambda: lines, + 'sum_debit': lambda: sum_debit, + 'sum_credit': lambda: sum_credit, + 'sum_litige': lambda: sum_litige, + }) + return res def lines(self): move_state = ['draft','posted'] @@ -235,62 +244,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header): i = i + 1 return completearray - def _sum_debit(self): - move_state = ['draft','posted'] - if self.target_move == 'posted': - move_state = ['posted'] - - if not self.ids: - return 0.0 - self.cr.execute( - "SELECT sum(debit) " \ - "FROM account_move_line AS l " \ - "JOIN account_move am ON (am.id = l.move_id)" \ - "WHERE l.account_id IN %s" \ - "AND am.state IN %s" \ - "AND " + self.query + "", - (tuple(self.account_ids), tuple(move_state))) - temp_res = float(self.cr.fetchone()[0] or 0.0) - return temp_res - - def _sum_credit(self): - move_state = ['draft','posted'] - if self.target_move == 'posted': - move_state = ['posted'] - - if not self.ids: - return 0.0 - self.cr.execute( - "SELECT sum(credit) " \ - "FROM account_move_line AS l " \ - "JOIN account_move am ON (am.id = l.move_id)" \ - "WHERE l.account_id IN %s" \ - "AND am.state IN %s" \ - "AND " + self.query + "", - (tuple(self.account_ids), tuple(move_state))) - temp_res = float(self.cr.fetchone()[0] or 0.0) - return temp_res - - def _sum_litige(self): - #gives the total of move lines with blocked boolean set to TRUE for the report selection - move_state = ['draft','posted'] - if self.target_move == 'posted': - move_state = ['posted'] - - if not self.ids: - return 0.0 - self.cr.execute( - "SELECT sum(debit-credit) " \ - "FROM account_move_line AS l " \ - "JOIN account_move am ON (am.id = l.move_id)" \ - "WHERE l.account_id IN %s" \ - "AND am.state IN %s" \ - "AND " + self.query + " " \ - "AND l.blocked=TRUE ", - (tuple(self.account_ids), tuple(move_state), )) - temp_res = float(self.cr.fetchone()[0] or 0.0) - return temp_res - def _get_partners(self): if self.result_selection == 'customer': diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.py b/addons/hr_timesheet_invoice/report/account_analytic_profit.py index bfaf585aff5..d9fb879ccaa 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.py @@ -36,13 +36,15 @@ class account_analytic_profit(report_sxw.rml_parse): return user_obj.browse(self.cr, self.uid, ids) def _journal_ids(self, form, user_id): + if isinstance(user_id, (int, long)): + user_id = [user_id] line_obj = self.pool['account.analytic.line'] journal_obj = self.pool['account.analytic.journal'] line_ids=line_obj.search(self.cr, self.uid, [ ('date', '>=', form['date_from']), ('date', '<=', form['date_to']), ('journal_id', 'in', form['journal_ids'][0][2]), - ('user_id', '=', user_id), + ('user_id', 'in', user_id), ]) ids=list(set([b.journal_id.id for b in line_obj.browse(self.cr, self.uid, line_ids)])) return journal_obj.browse(self.cr, self.uid, ids) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index e32b039d293..9e10c22c6b9 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -72,7 +72,7 @@ class sale_order_line(osv.osv): price=result['price_unit'] else: return res - + uom = result.get('product_uom', uom) product = product_obj.browse(cr, uid, product, context) list_price = pricelist_obj.price_get(cr, uid, [pricelist], product.id, qty or 1.0, partner_id, {'uom': uom,'date': date_order }) diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index 36b0a74015c..6329463805f 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -36,7 +36,11 @@ class sale_order_line(osv.osv): frm_cur = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id to_cur = self.pool.get('product.pricelist').browse(cr, uid, [pricelist])[0].currency_id.id if product: - purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price + product = self.pool['product.product'].browse(cr, uid, product, context=context) + purchase_price = product.standard_price + to_uom = res.get('product_uom', uom) + if to_uom != product.uom_id.id: + purchase_price = self.pool['product.uom']._compute_price(cr, uid, product.uom_id.id, purchase_price, to_uom) ctx = context.copy() ctx['date'] = date_order price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False, context=ctx) diff --git a/addons/stock/wizard/stock_partial_picking_view.xml b/addons/stock/wizard/stock_partial_picking_view.xml index 595336071d7..202058bc8a6 100644 --- a/addons/stock/wizard/stock_partial_picking_view.xml +++ b/addons/stock/wizard/stock_partial_picking_view.xml @@ -18,7 +18,7 @@ - +