diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index ddcd2ccb501..527ef5c1e55 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -45,6 +45,7 @@ class mrp_repair(osv.osv): """ res = {} cur_obj = self.pool.get('res.currency') + for repair in self.browse(cr, uid, ids): res[repair.id] = 0.0 for line in repair.operations: @@ -62,6 +63,7 @@ class mrp_repair(osv.osv): @return: Dictionary of values. """ res = {} + #return {}.fromkeys(ids, 0) cur_obj = self.pool.get('res.currency') tax_obj = self.pool.get('account.tax') for repair in self.browse(cr, uid, ids): @@ -94,6 +96,14 @@ class mrp_repair(osv.osv): res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0)) return res + def _get_lines(self, cr, uid, ids, context=None): + if context is None: + context = {} + result = {} + for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context): + result[line.repair_id.id] = True + return result.keys() + _columns = { 'name': fields.char('Repair Reference',size=24, required=True), 'product_id': fields.many2one('product.product', string='Product to Repair', required=True, readonly=True, states={'draft':[('readonly',False)]}), @@ -137,9 +147,21 @@ class mrp_repair(osv.osv): 'deliver_bool': fields.boolean('Deliver', help="Check this box if you want to manage the delivery once the product is repaired. If cheked, it will create a picking with selected product. Note that you can select the locations in the Info tab, if you have the extended view."), 'invoiced': fields.boolean('Invoiced', readonly=True), 'repaired': fields.boolean('Repaired', readonly=True), - 'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'), - 'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'), - 'amount_total': fields.function(_amount_total, method=True, string='Total'), + 'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount', + store={ + 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10), + 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10), + }), + 'amount_tax': fields.function(_amount_tax, method=True, string='Taxes', + store={ + 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10), + 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10), + }), + 'amount_total': fields.function(_amount_total, method=True, string='Total', + store={ + 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10), + 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10), + }), } _defaults = { @@ -163,7 +185,6 @@ class mrp_repair(osv.osv): }) return super(mrp_repair, self).copy(cr, uid, id, default, context) - def onchange_product_id(self, cr, uid, ids, product_id=None): """ On change of product sets some values. @param product_id: Changed product diff --git a/addons/product/product.py b/addons/product/product.py index eaa1df9ebf2..1b74bef87f9 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -377,23 +377,23 @@ class product_product(osv.osv): res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra return res - def _get_partner_code_name(self, cr, uid, ids, product_id, partner_id, context={}): - product = self.browse(cr, uid, [product_id], context)[0] + def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context={}): for supinfo in product.seller_ids: if supinfo.name.id == partner_id: return {'code': supinfo.product_code, 'name': supinfo.product_name, 'variants': ''} - return {'code' : product.default_code, 'name' : product.name, 'variants': product.variants} + res = {'code': product.default_code, 'name': product.name, 'variants': product.variants} + return res def _product_code(self, cr, uid, ids, name, arg, context={}): res = {} for p in self.browse(cr, uid, ids, context): - res[p.id] = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context)['code'] + res[p.id] = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context)['code'] return res def _product_partner_ref(self, cr, uid, ids, name, arg, context={}): res = {} for p in self.browse(cr, uid, ids, context): - data = self._get_partner_code_name(cr, uid, [], p.id, context.get('partner_id', None), context) + data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context) if not data['variants']: data['variants'] = p.variants if not data['code']: diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 235d446e4a2..b5fa80b96bd 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -29,7 +29,7 @@ - + Version 6.0 diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py index 4f78b2f7c85..c0d3cebdcca 100644 --- a/addons/wiki/wiki.py +++ b/addons/wiki/wiki.py @@ -164,7 +164,7 @@ class wiki_wiki2(osv.osv): @param uid: the current user’s ID for security checks, @param id: Give wiki page's ID """ - return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context) + return super(wiki_wiki2, self).copy_data(cr, uid, id, {'wiki_id': False}, context) def create_history(self, cr, uid, ids, vals, context=None): history_id = False