[FIX] mrp: confirmation of procurements when production order is confirmed was broken + fix and re-enable tests

During the workflow signalling refactoring the signal for
confirming the procurements was sent to the wrong model,
thus having no effect at all.
In addition the MRP tests were incorrectly disabled and
did not cover this case properly. They were re-enabled
and corrected to cover it.

bzr revid: odo@openerp.com-20130801125820-ubpq9wsew6q5w2hf
This commit is contained in:
Olivier Dony 2013-08-01 14:58:20 +02:00
parent a99b5786d1
commit 2c87609288
3 changed files with 15 additions and 18 deletions

View File

@ -77,9 +77,9 @@ Dashboard / Reports for MRP will include:
#TODO: This yml tests are needed to be completely reviewed again because the product wood panel is removed in product demo as it does not suit for new demo context of computer and consultant company
# so the ymls are too complex to change at this stage
'test': [
# 'test/order_demo.yml',
# 'test/order_process.yml',
# 'test/cancel_order.yml',
'test/order_demo.yml',
'test/order_process.yml',
'test/cancel_order.yml',
],
'installable': True,
'application': True,

View File

@ -23,7 +23,7 @@ import time
from datetime import datetime
import openerp.addons.decimal_precision as dp
from openerp.osv import fields, osv, orm
from openerp.osv import fields, osv
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
from openerp.tools import float_compare
from openerp.tools.translate import _
@ -406,20 +406,12 @@ class mrp_production(osv.osv):
return result
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')
self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
except (orm.except_orm, ValueError):
location_id = False
return location_id
src_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
return src_location_id.id
def _dest_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')
self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
except (orm.except_orm, ValueError):
location_id = False
return location_id
dest_location_id = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
return dest_location_id.id
def _get_progress(self, cr, uid, ids, name, arg, context=None):
""" Return product quantity percentage """
@ -885,7 +877,7 @@ class mrp_production(osv.osv):
'move_id': shipment_move_id,
'company_id': production.company_id.id,
})
self.signal_button_confirm(cr, uid, [procurement_id])
procurement_order.signal_button_confirm(cr, uid, [procurement_id])
return procurement_id
def _make_production_internal_shipment_line(self, cr, uid, production_line, shipment_id, parent_move_id, destination_location_id=False, context=None):

View File

@ -94,6 +94,11 @@
procurement_ids = procurement.search(cr, uid, [('move_id','=',move_line.id)])
assert procurement_ids, "Procurement should be created for shipment line of raw materials."
shipment_procurement = procurement.browse(cr, uid, procurement_ids[0], context=context)
# procurement state should be `confirmed` at this stage, except if mrp_jit is installed, in which
# case it could already be in `running` or `exception` state (not enough stock)
expected_states = ('confirmed', 'running', 'exception')
assert shipment_procurement.state in expected_states, 'Procurement state is `%s` for %s, expected one of %s' % \
(shipment_procurement.state, shipment_procurement.product_id.name, expected_states)
assert shipment_procurement.date_planned == date_planned, "Planned date is not correspond in procurement."
assert shipment_procurement.product_id.id == order_line.product_id.id, "Product is not correspond in procurement."
assert shipment_procurement.product_qty == order_line.product_qty, "Qty is not correspond in procurement."
@ -157,9 +162,9 @@
scrap_location_id = scrap_location_ids[0]
order = self.browse(cr, uid, ref("mrp_production_test1"))
for move in order.move_lines:
move.action_consume(move.product_qty)
if move.product_id.id == ref("product.product_product_6"):
move.action_scrap(5.0, scrap_location_id)
move.action_consume(move.product_qty)
-
I produce product.
-