|
|
|
|
@@ -278,7 +278,7 @@ class MrpProduction(models.Model):
|
|
|
|
|
|
|
|
|
|
@api.depends(
|
|
|
|
|
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
|
|
|
|
|
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state')
|
|
|
|
|
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state', 'is_adjust')
|
|
|
|
|
def _compute_state(self):
|
|
|
|
|
for production in self:
|
|
|
|
|
if not production.state or not production.product_uom_id:
|
|
|
|
|
@@ -314,11 +314,16 @@ class MrpProduction(models.Model):
|
|
|
|
|
if not production.workorder_ids or production.is_adjust is True:
|
|
|
|
|
production.state = 'technology_to_confirmed'
|
|
|
|
|
else:
|
|
|
|
|
production.state = 'confirmed'
|
|
|
|
|
if production.is_adjust is True:
|
|
|
|
|
production.state = 'technology_to_confirmed'
|
|
|
|
|
else:
|
|
|
|
|
production.state = 'confirmed'
|
|
|
|
|
elif production.state == 'pending_cam' and production.schedule_state == '未排':
|
|
|
|
|
production.state = 'confirmed'
|
|
|
|
|
elif production.state == 'to_close' and production.schedule_state == '已排':
|
|
|
|
|
production.state = 'pending_cam'
|
|
|
|
|
elif production.state == 'confirmed' and production.is_adjust is True:
|
|
|
|
|
production.state = 'technology_to_confirmed'
|
|
|
|
|
if production.state == 'progress':
|
|
|
|
|
if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in
|
|
|
|
|
production.workorder_ids.mapped('state')):
|
|
|
|
|
@@ -1397,7 +1402,7 @@ class MrpProduction(models.Model):
|
|
|
|
|
def _compute_production_type(self):
|
|
|
|
|
for production in self:
|
|
|
|
|
production.production_type = '自动化产线加工' if not production.product_id.is_manual_processing else '人工线下加工'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.model_create_multi
|
|
|
|
|
def create(self, vals_list):
|
|
|
|
|
"""
|
|
|
|
|
@@ -1413,7 +1418,7 @@ class MrpProduction(models.Model):
|
|
|
|
|
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
|
|
|
|
if not vals.get('procurement_group_id'):
|
|
|
|
|
product_id = self.env['product.product'].browse(vals['product_id'])
|
|
|
|
|
if product_id.product_tmpl_id.single_manufacturing:
|
|
|
|
|
if product_id.product_tmpl_id.single_manufacturing:
|
|
|
|
|
if product_id.id not in product_group_id.keys():
|
|
|
|
|
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
|
|
|
|
group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
|
|
|
|
@@ -1423,23 +1428,29 @@ class MrpProduction(models.Model):
|
|
|
|
|
vals['procurement_group_id'] = product_group_id[product_id.id]
|
|
|
|
|
return super(MrpProduction, self).create(vals_list)
|
|
|
|
|
|
|
|
|
|
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', 'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
|
|
|
|
|
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id',
|
|
|
|
|
'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
|
|
|
|
|
def _compute_purchase_order_count(self):
|
|
|
|
|
for production in self:
|
|
|
|
|
# 找到来源的第一张制造订单的采购组
|
|
|
|
|
if production.product_id.product_tmpl_id.single_manufacturing == True:
|
|
|
|
|
first_production = self.env['mrp.production'].search([('origin', '=', production.origin), ('product_id', '=', production.product_id.id)], limit=1, order='id asc')
|
|
|
|
|
production.purchase_order_count = len(first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
|
|
|
|
first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
|
|
|
|
first_production = self.env['mrp.production'].search(
|
|
|
|
|
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)], limit=1,
|
|
|
|
|
order='id asc')
|
|
|
|
|
production.purchase_order_count = len(
|
|
|
|
|
first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
|
|
|
|
first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
|
|
|
|
else:
|
|
|
|
|
production.purchase_order_count = len(production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
|
|
|
|
production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
|
|
|
|
production.purchase_order_count = len(
|
|
|
|
|
production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
|
|
|
|
production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
|
|
|
|
|
|
|
|
|
@api.depends('procurement_group_id', 'procurement_group_id.stock_move_ids.group_id')
|
|
|
|
|
def _compute_picking_ids(self):
|
|
|
|
|
for order in self:
|
|
|
|
|
if order.product_id.product_tmpl_id.single_manufacturing == True:
|
|
|
|
|
first_order = self.env['mrp.production'].search([('origin', '=', order.origin), ('product_id', '=', order.product_id.id)], limit=1, order='id asc')
|
|
|
|
|
first_order = self.env['mrp.production'].search(
|
|
|
|
|
[('origin', '=', order.origin), ('product_id', '=', order.product_id.id)], limit=1, order='id asc')
|
|
|
|
|
order.picking_ids = self.env['stock.picking'].search([
|
|
|
|
|
('group_id', '=', first_order.procurement_group_id.id), ('group_id', '!=', False),
|
|
|
|
|
])
|
|
|
|
|
@@ -1450,6 +1461,7 @@ class MrpProduction(models.Model):
|
|
|
|
|
])
|
|
|
|
|
order.delivery_count = len(order.picking_ids)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class sf_detection_result(models.Model):
|
|
|
|
|
_name = 'sf.detection.result'
|
|
|
|
|
_description = "检测结果"
|
|
|
|
|
|