diff --git a/jikimo_frontend/static/src/views/list_nums/list_nums.xml b/jikimo_frontend/static/src/views/list_nums/list_nums.xml
index d2ad6824..6dee30bd 100644
--- a/jikimo_frontend/static/src/views/list_nums/list_nums.xml
+++ b/jikimo_frontend/static/src/views/list_nums/list_nums.xml
@@ -4,9 +4,9 @@
-
+
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index c1d3ee33..007b2554 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -791,11 +791,11 @@ class MrpProduction(models.Model):
self.ensure_one()
iot_code = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
'ir.sequence'].next_by_code('stock.lot.serial')
- iot_code_name = re.sub('[\u4e00-\u9fa5]', "", iot_code)
+ # iot_code_name = re.sub('[\u4e00-\u9fa5]', "", iot_code)
self.lot_producing_id = self.env['stock.lot'].create({
'product_id': self.product_id.id,
'company_id': self.company_id.id,
- 'name': iot_code_name,
+ 'name': iot_code,
})
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
self.move_finished_ids.filtered(
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 22fe0777..b14955e4 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -103,7 +103,11 @@ class ResMrpWorkOrder(models.Model):
record.back_button_display = True
else:
record.back_button_display = False
- if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹':
+ # tag_type
+ if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹' or any(
+ detection_result.processing_panel == cur_workorder.processing_panel and detection_result.routing_type == cur_workorder.routing_type and cur_workorder.tag_type !='重新加工'
+ for detection_result in cur_workorder.production_id.detection_result_ids
+ ):
record.back_button_display = False
else:
next_workorder = sorted_workorders[position + 1]
@@ -113,7 +117,10 @@ class ResMrpWorkOrder(models.Model):
record.back_button_display = True
else:
record.back_button_display = False
- if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹':
+ if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹' or any(
+ detection_result.processing_panel == cur_workorder.processing_panel and detection_result.routing_type == cur_workorder.routing_type and cur_workorder.tag_type !='重新加工'
+ for detection_result in cur_workorder.production_id.detection_result_ids
+ ):
record.back_button_display = False
date_planned_start = fields.Datetime(tracking=True)
@@ -1513,7 +1520,8 @@ class ResMrpWorkOrder(models.Model):
# ('state', '!=', 'done')])
# if raw_move:
# raw_move.write({'state': 'done'})
- record.production_id.button_mark_done1()
+ if record.production_id.state != 'rework':
+ record.production_id.button_mark_done1()
# record.production_id.state = 'done'
# ============工单完成,修改对应[质检单]的值=====================
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index e1cf0ee4..06ceb739 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -455,7 +455,8 @@ class ProductionLot(models.Model):
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
limit=1, order='name desc')
move_line_id = self.env['stock.move.line'].sudo().search(
- [('product_id', '=', product.id), ('lot_name', 'ilike', product.name)], limit=1, order='lot_name desc')
+ [('company_id', '=', company.id), ('product_id', '=', product.id), ('lot_name', 'ilike', product.name)],
+ limit=1, order='lot_name desc')
if last_serial or move_line_id:
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
not move_line_id or
@@ -645,6 +646,16 @@ class StockPicking(models.Model):
stock_picking = stock_picking_list.filtered(lambda p: p.state not in ("done", "cancel"))
if sale_id and not stock_picking:
sale_id.write({'state': 'delivered'})
+ if self.location_dest_id.name == '成品存货区' and self.state == 'done':
+ for move in self.move_ids:
+ for production in self.sale_order_id.mrp_production_ids:
+ moves = self.env['stock.move'].search([
+ ('name', '=', production.name),
+ ('state', '!=', 'cancel')
+ ])
+ finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None)
+ if finish_move.id in move.move_orig_ids.ids and finish_move.state == 'done':
+ production.workorder_ids.write({'back_button_display': False})
return res
# 创建 外协出库入单
@@ -713,20 +724,6 @@ class StockPicking(models.Model):
'draft', 'sent']:
picking.state = 'waiting'
- # def write(self, vals):
- #
- # old_state = None
- # if 'state' in vals:
- # old_state = self.state
- # res = super(StockPicking, self).write(vals)
- # if (self.picking_type_id.use_existing_lots is False and self.picking_type_id.use_create_lots is True and
- # (('move_ids_without_package' in vals and self.state == 'assigned')
- # or ('state' in vals and vals['state'] == 'assigned' and old_state not in ['assigned', 'done']))):
- # if self.move_ids_without_package:
- # for move_id in self.move_ids_without_package:
- # move_id.action_show_details()
- # return res
-
@api.constrains('state', 'move_ids_without_package')
def _check_move_ids_without_package(self):
"""
@@ -913,8 +910,8 @@ class ReStockMove(models.Model):
lot_code = '%s-%s-%s' % ('%s-T-DJWL-%s' % (
product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code),
datetime.now().strftime("%Y%m%d"), origin)
- move_line_ids = self.env['stock.move.line'].sudo().search([('lot_name', 'like', lot_code)], limit=1,
- order='id desc')
+ move_line_ids = self.env['stock.move.line'].sudo().search(
+ [('company_id', '=', company.id), ('lot_name', 'like', lot_code)], limit=1, order='id desc')
if not move_line_ids:
lot_code = '%s-001' % lot_code
else:
@@ -951,7 +948,8 @@ class ReStockMove(models.Model):
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)],
limit=1, order='id DESC')
move_line_id = self.env['stock.move.line'].sudo().search(
- [('product_id', '=', product.id), ('lot_name', 'ilike', origin)], limit=1, order='lot_name desc')
+ [('company_id', '=', company.id), ('product_id', '=', product.id), ('lot_name', 'ilike', origin)],
+ limit=1, order='lot_name desc')
split_codes = product.cutting_tool_model_id.code.split('-')
if last_serial or move_line_id:
return "%s-T-%s-%s-%03d" % (
@@ -1059,6 +1057,8 @@ class ReStockMove(models.Model):
更新序列号 功能按钮
"""
self.move_line_nosuggest_ids.unlink()
+ if self.state != 'assigned':
+ self.state = 'assigned'
return self.action_show_details()
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index bd94e9c9..ff6b0a20 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -202,10 +202,11 @@
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
-
-
-
-
+
+
+
+
diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py
index 0415d1fd..66d7ea8d 100644
--- a/sf_manufacturing/wizard/production_technology_wizard.py
+++ b/sf_manufacturing/wizard/production_technology_wizard.py
@@ -3,6 +3,7 @@
import logging
from itertools import groupby
from odoo import models, api, fields, _
+from odoo.exceptions import UserError
class ProductionTechnologyWizard(models.TransientModel):
@@ -88,7 +89,10 @@ class ProductionTechnologyWizard(models.TransientModel):
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
- if workorder[0].state in ['pending']:
- if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
- workorder[0].state = 'waiting'
+ first_element = workorder[0] if workorder else None
+ if not first_element:
+ raise UserError('工艺确认后,工单未生成,请检查配置')
+ if first_element.state in ['pending']:
+ if first_element.production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
+ first_element.state = 'waiting'
return productions
diff --git a/sf_message/data/template_data.xml b/sf_message/data/template_data.xml
index 4d580127..63e51101 100644
--- a/sf_message/data/template_data.xml
+++ b/sf_message/data/template_data.xml
@@ -262,7 +262,7 @@
markdown
normal
### {{picking_type_name}}待处理提醒:
-单号:{{name}}
+单号:[{{name}}]({{request_url}})
事项:质量检查已完成
diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py
index 10304cf3..b469e88c 100644
--- a/sf_message/models/sf_message_stock_picking.py
+++ b/sf_message/models/sf_message_stock_picking.py
@@ -51,7 +51,8 @@ class SFMessageStockPicking(models.Model):
all_ready_or_done = all(picking.state in ['assigned', 'done'] for picking in stock_picking_list)
if all_ready_or_done:
mrp_production.add_queue('工序外协发料通知')
- if all(qc.quality_state in ['pass', 'fail'] for qc in record.quality_check_ids):
+ if record.quality_check_ids and all(
+ qc.quality_state in ['pass', 'fail'] for qc in record.quality_check_ids):
record.add_queue('调拨单质检完成提醒')
except Exception as e:
logging.info('add_queue_compute_state error:%s' % e)
@@ -90,8 +91,14 @@ class SFMessageStockPicking(models.Model):
contents.append(content)
elif message_queue_id.message_template_id.name == '调拨单质检完成提醒':
content = message_queue_id.message_template_id.content
- content = content.replace('{{picking_type_name}}', self.picking_type_id.name).replace(
- '{{name}}', self.name)
+ stock_picking_line = self.env['stock.picking'].sudo().search(
+ [('id', '=', int(message_queue_id.res_id))])
+ url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ action_id = self.env.ref('stock.action_picking_tree_ready').id
+ menu_id = self.env.ref('stock.menu_stock_root').id
+ url_with_id = f"{url}/web#view_type=form&action={action_id}&menu_id={menu_id}&id={stock_picking_line.id}"
+ content = content.replace('{{picking_type_name}}', stock_picking_line.picking_type_id.name).replace(
+ '{{name}}', stock_picking_line.name).replace('{{request_url}}', url_with_id)
contents.append(content)
return contents, message_queue_ids
diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py
index fb8518e2..ebe30a71 100644
--- a/sf_quality/models/quality.py
+++ b/sf_quality/models/quality.py
@@ -40,6 +40,14 @@ class QualityCheck(models.Model):
operation_id = fields.Many2one('mrp.routing.workcenter', '作业', store=True, compute='_compute_operation_id')
is_inspect = fields.Boolean('需送检', related='point_id.is_inspect')
+ lot_name = fields.Char('批次/序列号 名称', compute='_compute_lot_name', store=True)
+
+ @api.depends('move_line_id', 'move_line_id.lot_name')
+ def _compute_lot_name(self):
+ for qc in self:
+ if qc.move_line_id:
+ qc.lot_name = qc.move_line_id.lot_name
+
@api.depends('point_id.operation_id')
def _compute_operation_id(self):
for qc in self:
diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml
index 185050c0..5a6b08de 100644
--- a/sf_sale/views/sale_order_view.xml
+++ b/sf_sale/views/sale_order_view.xml
@@ -127,6 +127,9 @@
+
+ hide
+
hide