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 _
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 """
'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):
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."
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.
-