if rest_qty > 0 :
stock_mov_obj.action_consume(cr, uid, [produce_product.id], (subproduct_factor * production_qty), context=context)
- for raw_product in production.move_lines2:
- new_parent_ids = []
- parent_move_ids = [x.id for x in raw_product.move_history_ids]
- for final_product in production.move_created_ids2:
- if final_product.id not in parent_move_ids:
- new_parent_ids.append(final_product.id)
- for new_parent_id in new_parent_ids:
- stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]})
+# for raw_product in production.move_lines2:
+# new_parent_ids = []
+# parent_move_ids = [x.id for x in raw_product.move_history_ids]
+# for final_product in production.move_created_ids2:
+# if final_product.id not in parent_move_ids:
+# new_parent_ids.append(final_product.id)
+# for new_parent_id in new_parent_ids:
+# stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]})
self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
self.signal_button_produce_done(cr, uid, [production_id])
return True
if not self.action_compute(cr, uid, [production.id]):
res = False
return res
+
+ def consume_lines_get(self, cr, uid, ids, *args):
+ res = []
+ for order in self.browse(cr, uid, ids, context={}):
+ res += [x.id for x in order.move_lines]
+ return res
+
+
+ def test_ready2(self, cr, uid, ids):
+ res = True
+ assign = self._moves_assigned(cr, uid, ids, False, False)
+ for production in ids:
+ if not assign[production]:
+ res = False
+ return res
+
+ def test_ready(self, cr, uid, ids):
+ res = True
+ for production in self.browse(cr, uid, ids):
+ if not production.ready_production:
+ res = False
+ return res
def _make_production_produce_line(self, cr, uid, production, context=None):
stock_move = self.pool.get('stock.move')
'name': production.name,
'date': production.date_planned,
'product_id': production_line.product_id.id,
- 'product_qty': production_line.product_qty,
- 'product_uom_qty': production.product_qty,
- 'product_uom': production_line.product_uom.id,
+ 'product_uom_qty': production_line.product_qty,
+ 'product_uom': production_line.product_uom.id,
'product_uos_qty': production_line.product_uos and production_line.product_uos_qty or False,
'product_uos': production_line.product_uos and production_line.product_uos.id or False,
'location_id': source_location_id,
@param *args: Arguments
@return: True
"""
- pick_obj = self.pool.get('stock.picking')
- pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])
+
+ move_obj = self.pool.get('stock.move')
+ for order in self.browse(cr, uid, ids):
+ move_obj.force_assign(cr, uid, [x.id for x in order.move_lines])
return True
move = order.move_created_ids[0]
source_location_id = order.product_id.property_stock_production.id
assert move.date == order.date_planned, "Planned date is not correspond."
- assert move.product_id.id == order.product_id.id, "Product is not correspond."
- assert move.product_uom.id == order.product_uom.id, "UOM is not correspond."
- assert move.product_qty == order.product_qty, "Qty is not correspond."
- assert move.product_uos_qty == order.product_uos and order.product_uos_qty or order.product_qty, "UOS qty is not correspond."
+ assert move.product_id.id == order.product_id.id, "Product does not correspond."
+ assert move.product_uom.id == order.product_uom.id, "UOM does not correspond."
+ assert move.product_qty == order.product_qty, "Qty does not correspond."
+ assert move.product_uos_qty == order.product_uos and order.product_uos_qty or order.product_qty, "UOS qty does not correspond."
if order.product_uos:
- assert move.product_uos.id == order.product_uos.id, "UOS is not correspond."
- assert move.location_id.id == source_location_id, "Source Location is not correspond."
- assert move.location_dest_id.id == order.location_dest_id.id, "Destination Location is not correspond."
+ assert move.product_uos.id == order.product_uos.id, "UOS does not correspond."
+ assert move.location_id.id == source_location_id, "Source Location does not correspond."
+ assert move.location_dest_id.id == order.location_dest_id.id, "Destination Location does not correspond."
routing_loc = None
if order.bom_id.routing_id and order.bom_id.routing_id.location_id:
routing_loc = order.bom_id.routing_id.location_id.id
date_planned = order.date_planned
for move_line in order.move_lines:
for order_line in order.product_lines:
- if move_line.product_id.type not in ('product', 'consu'):
- continue
- if move_line.product_id.id == order_line.product_id.id:
- assert move_line.date == date_planned, "Planned date is not correspond in 'To consume line'."
- assert move_line.product_qty == order_line.product_qty, "Qty is not correspond in 'To consume line'."
- assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond in 'To consume line'."
- assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond in 'To consume line'."
- if order_line.product_uos:
- assert move_line.product_uos.id == order_line.product_uos.id, "UOS is not correspond in 'To consume line'."
- assert move_line.location_id.id == routing_loc or order.location_src_id.id, "Source location is not correspond in 'To consume line'."
- assert move_line.location_dest_id.id == source_location_id, "Destination Location is not correspond in 'To consume line'."
--
- I check details of an Internal Shipment after confirmed production order to bring components in Raw Materials Location.
--
- !python {model: mrp.production}: |
- procurement = self.pool.get('procurement.order')
- order = self.browse(cr, uid, ref("mrp_production_test1"))
- assert order.picking_id, 'Internal Shipment should be created!'
-
- routing_loc = None
- pick_type = 'internal'
- partner_id = False
- if order.bom_id.routing_id and order.bom_id.routing_id.location_id:
- routing_loc = order.bom_id.routing_id.location_id
- if routing_loc.usage != 'internal':
- pick_type = 'out'
- partner_id = routing_loc.partner_id and routing_loc.partner_id.id or False
- routing_loc = routing_loc.id
- assert order.picking_id.type == pick_type, "Shipment should be Internal."
- assert order.picking_id.partner_id.id == partner_id, "Shipment Address is not correspond with Adderss of Routing Location."
- date_planned = order.date_planned
- for move_line in order.picking_id.move_lines:
- for order_line in order.product_lines:
- if move_line.product_id.type not in ('product', 'consu'):
- continue
- if move_line.product_id.id == order_line.product_id.id:
- assert move_line.date == date_planned, "Planned date is not correspond."
- assert move_line.product_qty == order_line.product_qty, "Qty is not correspond."
- assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond."
- assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond."
- if order_line.product_uos:
- assert move_line.product_uos.id == order_line.product_uos.id, "UOS is not correspond."
- assert move_line.location_id.id == order.location_src_id.id, "Source location is not correspond."
- assert move_line.location_dest_id.id == routing_loc or order.location_src_id.id, "Destination Location is not correspond."
- 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)
- 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."
- assert shipment_procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond in procurement."
- assert shipment_procurement.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond in procurement."
- if order_line.product_uos:
- assert shipment_procurement.product_uos.id == order_line.product_uos.id, "UOS is not correspond in procurement."
- assert shipment_procurement.location_id.id == order.location_src_id.id, "Location is not correspond in procurement."
- assert shipment_procurement.procure_method == order_line.product_id.procure_method, "Procure method is not correspond in procurement."
+ if move_line.product_id.type not in ('product', 'consu'):
+ continue
+ if move_line.product_id.id == order_line.product_id.id:
+ assert move_line.date == date_planned, "Planned date does not correspond in 'To consume line'."
+ assert move_line.product_qty == order_line.product_qty, "Qty does not correspond in 'To consume line'."
+ assert move_line.product_uom.id == order_line.product_uom.id, "UOM does not correspond in 'To consume line'."
+ assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond in 'To consume line'."
+ if order_line.product_uos:
+ assert move_line.product_uos.id == order_line.product_uos.id, "UOS is not correspond in 'To consume line'."
+ assert move_line.location_id.id == routing_loc or order.location_src_id.id, "Source location is not correspond in 'To consume line'."
+ assert move_line.location_dest_id.id == source_location_id, "Destination Location is not correspond in 'To consume line'."
+-
+ I check procurements have been generated for every consume line
+-
+ !python {model: procurement.order}: |
+ order = self.pool.get("mrp.production").browse(cr, uid, ref("mrp_production_test1"))
+ move_line_ids = [x.id for x in order.move_lines]
+ procurements = self.search(cr, uid, [('move_dest_id', 'in', move_line_ids)])
+ for proc in self.browse(cr, uid, procurements):
+ for order_line in order.product_lines:
+ date_planned = order.date_planned
+ if proc.product_id.type not in ('product', 'consu'):
+ continue
+ if proc.product_id.id == order_line.product_id.id:
+ assert proc.date_planned == date_planned, "Planned date does not correspond"
+ assert proc.product_qty == order_line.product_qty, "Qty does not correspond"
+ assert proc.location_id.id == order.location_src_id.id, "Input location and procurement location do not correspond"
+ assert proc.product_uom.id == order_line.product_uom.id, "UOM does not correspond in procurement."
+ assert proc.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty does not correspond in procurement."
+ if order_line.product_uos:
+ assert proc.product_uos.id == order_line.product_uos.id, "UOS is not correspond in procurement."
-
I change production qty with 3 PC Assemble SC349.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
- The production order is Waiting Goods, I forcefully done internal shipment.
+ The production order is Waiting Goods, will force production which should set consume lines as available
-
!python {model: mrp.production}: |
self.force_production(cr, uid, [ref("mrp_production_test1")])
-
- I check that production order in ready state after forcefully done internal shipment.
+ I check that production order in ready state after forcing production.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_test1"))
assert order.state == 'ready', 'Production order should be in Ready State.'
- assert order.picking_id.state == 'done', 'Internal shipment should be done.'
-
Now I start production.
-
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.
-
raise AssertionError('unknown cost line: %s' % line)
assert line.general_account_id.id == wc.costs_general_account_id.id, "General Account is not correspond."
assert line.journal_id.id == wc.costs_journal_id.id, "Account Journal is not correspond."
- assert line.product_id.id == wc.product_id.id, "Product is not correspond."
- assert line.product_uom_id.id == wc.product_id.uom_id.id, "UOM is not correspond."
+ assert line.product_id.id == wc.product_id.id, "Product does not correspond."
+ assert line.product_uom_id.id == wc.product_id.uom_id.id, "UOM does not correspond."
-
I print a "BOM Structure".
-
ctx.update({'model': 'mrp.workcenter','active_ids': [ref('mrp_workcenter_0'),ref('mrp_workcenter_1')]})
data_dict = {'time_unit': 'day', 'measure_unit': 'hours'}
from openerp.tools import test_reports
- test_reports.try_report_action(cr, uid, 'action_mrp_workcenter_load_wizard',wiz_data=data_dict, context=ctx, our_module='mrp')
-
+ test_reports.try_report_action(cr, uid, 'action_mrp_workcenter_load_wizard',wiz_data=data_dict, context=ctx, our_module='mrp')
\ No newline at end of file