diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index ff38563c0be..099ae0fbacc 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -497,6 +497,12 @@ class mrp_production(osv.osv): result[prod.id]['cycle_total'] += wc.cycle return result + def _get_workcenter_line(self, cr, uid, ids, context=None): + result = {} + for line in self.pool['mrp.production.workcenter.line'].browse(cr, uid, ids, context=context): + result[line.production_id.id] = True + return result.keys() + def _src_id_default(self, cr, uid, ids, context=None): try: location_model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock') @@ -595,8 +601,14 @@ class mrp_production(osv.osv): If the stock is available then the status is set to 'Ready to Produce'.\n\ When the production gets started then the status is set to 'In Production'.\n\ When the production is over, the status is set to 'Done'."), - 'hour_total': fields.function(_production_calc, type='float', string='Total Hours', multi='workorder', store=True), - 'cycle_total': fields.function(_production_calc, type='float', string='Total Cycles', multi='workorder', store=True), + 'hour_total': fields.function(_production_calc, type='float', string='Total Hours', multi='workorder', store={ + _name: (lambda self, cr, uid, ids, c={}: ids, ['workcenter_lines'], 40), + 'mrp.production.workcenter.line': (_get_workcenter_line, ['hour', 'cycle'], 40), + }), + 'cycle_total': fields.function(_production_calc, type='float', string='Total Cycles', multi='workorder', store={ + _name: (lambda self, cr, uid, ids, c={}: ids, ['workcenter_lines'], 40), + 'mrp.production.workcenter.line': (_get_workcenter_line, ['hour', 'cycle'], 40), + }), 'user_id': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company', 'Company', required=True), 'ready_production': fields.function(_moves_assigned, type='boolean', store={'stock.move': (_mrp_from_move, ['state'], 10)}), diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2ed4cf646fa..e3a825ee843 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -752,7 +752,7 @@ class stock_picking(osv.osv): def _get_pickings(self, cr, uid, ids, context=None): res = set() for move in self.browse(cr, uid, ids, context=context): - if move.picking_id: + if move.picking_id and (not (move.picking_id.min_date < move.date_expected < move.picking_id.max_date) or move.priority > move.picking_id.priority): res.add(move.picking_id.id) return list(res) @@ -1739,7 +1739,9 @@ class stock_move(osv.osv): 'date': fields.datetime('Date', required=True, select=True, help="Move date: scheduled date until move is done, then date of actual move processing", states={'done': [('readonly', True)]}), 'date_expected': fields.datetime('Expected Date', states={'done': [('readonly', True)]}, required=True, select=True, help="Scheduled date for the processing of this move"), 'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type', '<>', 'service')], states={'done': [('readonly', True)]}), - 'product_qty': fields.function(_quantity_normalize, fnct_inv=_set_product_qty, type='float', digits=0, store=True, string='Quantity', + 'product_qty': fields.function(_quantity_normalize, fnct_inv=_set_product_qty, type='float', digits=0, store={ + _name: (lambda self, cr, uid, ids, c={}: ids, ['product_id', 'product_uom', 'product_uom_qty'], 40), + }, string='Quantity', help='Quantity in the default UoM of the product'), 'product_uom_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True, states={'done': [('readonly', True)]}, diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py index 12c806367d5..ae5a6ebfb49 100644 --- a/addons/stock_account/stock.py +++ b/addons/stock_account/stock.py @@ -200,7 +200,7 @@ class stock_picking(osv.osv): def __get_picking_move(self, cr, uid, ids, context={}): res = [] for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context): - if move.picking_id: + if move.picking_id and move.invoice_state != move.picking_id.invoice_state: res.append(move.picking_id.id) return res