-
+
+
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index f2876350..3a49c2fa 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -53,7 +53,8 @@ class MrpProduction(models.Model):
active = fields.Boolean(string='已归档', default=True)
programming_no = fields.Char('编程单号')
work_state = fields.Char('业务状态')
- programming_state = fields.Char('编程状态', tracking=True)
+ programming_state = fields.Selection(
+ [('编程中', '编程中'), ('已编程', '已编程')], string='编程状态', tracking=True)
glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间')
@@ -102,7 +103,7 @@ class MrpProduction(models.Model):
elif not production.workorder_ids and float_compare(production.qty_producing, production.product_qty,
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
- elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
+ elif any(wo_state in ('progress') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing,
precision_rounding=production.product_uom_id.rounding):
@@ -119,6 +120,10 @@ class MrpProduction(models.Model):
production.state = 'confirmed'
# if production.schedule_state == '已完成':
# production.state = 'completed'
+ elif production.workorder_ids and production.workorder_ids[0].state == 'ready':
+ production.state = 'confirmed'
+ elif all(wo_state in ('done') for wo_state in production.workorder_ids.mapped('state')):
+ production.state = 'done'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing,
@@ -128,9 +133,6 @@ class MrpProduction(models.Model):
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
for move in production.move_raw_ids):
production.state = 'progress'
-
-
-
# if production.state == 'progress' and production.schedule_state == '已排' and production.process_state == '待装夹':
# # production.state = 'pending_processing'
# production.state = 'pending_cam'
@@ -357,6 +359,7 @@ class MrpProduction(models.Model):
# 表面工艺工序
# 获取表面工艺id
if production.product_id.model_process_parameters_ids:
+ logging.info('model_process_parameters_ids:%s' % production.product_id.model_process_parameters_ids)
surface_technics_arr = []
# 工序id
route_workcenter_arr = []
@@ -371,6 +374,7 @@ class MrpProduction(models.Model):
# 用filter刷选表面工艺id'是否存在工艺类别对象里
if production_process_category:
for p in production_process_category:
+ logging.info('production_process_category:%s' % p.name)
production_process = p.production_process_ids.filtered(
lambda pp: pp.id in surface_technics_arr)
if production_process:
@@ -424,7 +428,7 @@ class MrpProduction(models.Model):
else:
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
- production_item)
+ production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
@@ -432,21 +436,21 @@ class MrpProduction(models.Model):
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
if is_pick is False:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
- production_item)
+ production)
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
- production_item)
+ production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
if m == len(consecutive_workorders) - 1 and m != 0:
- self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
+ self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
if is_pick is False and m == 0:
if len(sorted_workorders) == 1:
- self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
+ self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
else:
- self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
+ self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
@@ -653,7 +657,7 @@ class MrpProduction(models.Model):
for production in self:
production.write({
'date_finished': fields.Datetime.now(),
- 'product_qty': production.qty_produced,
+ 'product_qty': production.qty_produced if production.qty_produced < 1 else production.product_qty,
'priority': '0',
'is_locked': True,
'state': 'done',
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index ae25f8b7..1cdbb7af 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -136,11 +136,6 @@ class ResMrpWorkOrder(models.Model):
supplier_id = fields.Many2one('res.partner', string='外协供应商')
equipment_id = fields.Many2one('maintenance.equipment', string='加工设备', tracking=True)
- is_ok = fields.Boolean(string='是否合格')
- # 加工人
- processing_user_id = fields.Many2one('res.users', string='加工人')
- # 检测人
- inspection_user_id = fields.Many2one('res.users', string='检测人')
# 保存名称
save_name = fields.Char(string='检测文件保存名称', compute='_compute_save_name')
# 获取数据状态
@@ -207,6 +202,7 @@ class ResMrpWorkOrder(models.Model):
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
+
# is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
@api.onchange('rfid_code')
@@ -234,16 +230,6 @@ class ResMrpWorkOrder(models.Model):
ids = [t[0] for t in self.env.cr.fetchall()]
return [('id', 'in', ids)]
- @api.onchange('is_ok')
- def _onchange_inspection_user_id(self):
- """
- 检测is_ok(是否合格)被修改的话,就将当前用户赋值给inspection_user_id
- """
- if not self.inspection_user_id:
- self.inspection_user_id = self.env.user.id
- else:
- self.inspection_user_id = False
-
@api.onchange('functional_fixture_id')
def _onchange_functional_fixture_id(self):
if self.functional_fixture_id:
@@ -876,10 +862,9 @@ class ResMrpWorkOrder(models.Model):
('location_dest_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id),
('origin', '=', self.production_id.name)])
- purchase = self.env['purchase.order'].search([('origin', '=', self.production_id.name)])
- if purchase and move_out:
+ if move_out:
move_out.write({'state': 'assigned'})
- self.env['stock.move.line'].create(move_out.get_move_line(purchase, self))
+ self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self))
# move_out._action_assign()
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
@@ -1025,6 +1010,7 @@ class ResMrpWorkOrder(models.Model):
workorder.rfid_code_old = rfid_code
workorder.rfid_code = ''
if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
+ logging.info('product_qty:%s' % record.production_id.product_qty)
for move_raw_id in record.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty
record.process_state = '已完工'
@@ -1036,7 +1022,7 @@ class ResMrpWorkOrder(models.Model):
if raw_move:
raw_move.write({'state': 'done'})
record.production_id.button_mark_done1()
- record.production_id.state = 'done'
+ # record.production_id.state = 'done'
# 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath):
@@ -1266,6 +1252,7 @@ class SfWorkOrderBarcodes(models.Model):
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
def on_barcode_scanned(self, barcode):
+ logging.info('Rfid:%s' % barcode)
workorder = self.env['mrp.workorder'].browse(self.ids)
# workorder_preset = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
@@ -1309,7 +1296,7 @@ class SfWorkOrderBarcodes(models.Model):
self.process_state = '待检测'
self.date_start = datetime.now()
else:
- raise UserError('该托盘信息不存在!!!')
+ raise UserError('没有找到Rfid为【%s】的托盘信息!!!' % barcode)
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
# if stock_move_line.product_id.categ_type == '夹具':
# workorder.write({
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index ee24b72c..9234060f 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -204,14 +204,14 @@ class StockRule(models.Model):
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
productions_values)
- # self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
+ self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
'''
创建工单
'''
# productions._create_workorder()
#
- # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
+ self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
(
p.move_dest_ids.procure_method != 'make_to_order' and not
@@ -261,13 +261,14 @@ class StockRule(models.Model):
'product_id': production.product_id.id,
'state': 'draft',
})
- grouped_product_ids = {k: list(g) for k, g in groupby(productions, key=lambda x: x.product_id.id)}
+ all_production = productions
+ grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
product_id_to_production_names = {}
# 对于每个product_id,获取其所有生产订单的名称
- for product_id, productions in grouped_product_ids.items():
+ for product_id, all_production in grouped_product_ids.items():
# 为同一个product_id创建一个生产订单名称列表
- product_id_to_production_names[product_id] = [production.name for production in productions]
+ product_id_to_production_names[product_id] = [production.name for production in all_production]
for production_item in productions:
if production_item.product_id.id in product_id_to_production_names:
# # 同一个产品多个制造订单对应一个编程单和模型库
@@ -486,10 +487,10 @@ class StockPicking(models.Model):
('location_dest_id', '=', self.env['stock.location'].search(
[('barcode', 'ilike', 'VL-SPOC')]).id),
('origin', '=', self.origin)])
- if self.id == move_out.picking_id.id:
- if move_out.move_line_ids.workorder_id.state not in ['progress']:
- raise UserError(
- _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name))
+ # if self.id == move_out.picking_id.id:
+ # if move_out.move_line_ids.workorder_id.state not in ['progress']:
+ # raise UserError(
+ # _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name))
# 入库单验证
move_in = self.env['stock.move'].search(
[('location_dest_id', '=', self.env['stock.location'].search(
@@ -505,18 +506,17 @@ class StockPicking(models.Model):
res = super().button_validate()
if res is True:
if self.id == move_out.picking_id.id:
- if move_out.move_line_ids.workorder_id.state == 'progress':
- move_in = self.env['stock.move'].search(
- [('location_dest_id', '=', self.env['stock.location'].search(
- [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
- ('location_id', '=', self.env['stock.location'].search(
- [('barcode', 'ilike', 'VL-SPOC')]).id),
- ('origin', '=', self.origin)])
- # purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
- if move_in:
- move_in.write({'state': 'assigned'})
- purchase = self.env['purchase.order'].search([('origin', '=', self.origin)])
- self.env['stock.move.line'].create(move_in.get_move_line(purchase, None))
+ # if move_out.move_line_ids.workorder_id.state == 'progress':
+ move_in = self.env['stock.move'].search(
+ [('location_dest_id', '=', self.env['stock.location'].search(
+ [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
+ ('location_id', '=', self.env['stock.location'].search(
+ [('barcode', 'ilike', 'VL-SPOC')]).id),
+ ('origin', '=', self.origin)])
+ production = self.env['mrp.production'].search([('name', '=', self.origin)])
+ if move_in:
+ move_in.write({'state': 'assigned'})
+ self.env['stock.move.line'].create(move_in.get_move_line(production, None))
return res
@@ -598,7 +598,7 @@ class ReStockMove(models.Model):
'state': 'confirmed',
}
- def get_move_line(self, purchase, sorted_workorders):
+ def get_move_line(self, production_id, sorted_workorders):
return {
'move_id': self.id,
'product_id': self.product_id.id,
@@ -607,7 +607,7 @@ class ReStockMove(models.Model):
'location_dest_id': self.picking_id.location_dest_id.id,
'picking_id': self.picking_id.id,
'reserved_uom_qty': 1.0,
- 'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
+ 'lot_id': production_id.move_line_raw_ids.lot_id.id,
'company_id': self.company_id.id,
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index e0cddf21..efab7e2d 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -75,11 +75,12 @@
+
+
-
-
@@ -281,9 +282,11 @@
-
+
-
+
@@ -136,7 +136,7 @@
-
@@ -160,11 +160,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -183,8 +183,11 @@
-
+
+
+
计划加工时间
@@ -239,23 +242,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -575,9 +561,6 @@