Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化

This commit is contained in:
mgw
2025-02-26 09:10:04 +08:00
10 changed files with 67 additions and 36 deletions

View File

@@ -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(

View File

@@ -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'
# ============工单完成,修改对应[质检单]的值=====================

View File

@@ -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()

View File

@@ -202,10 +202,11 @@
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
<button name="do_inspect" type="object" string="送检" class="btn-success" confirm="是否确认送检"
attrs="{'invisible': ['|', '|', ('state', 'not in', ('progress')), ('is_inspect', '=', False), ('routing_type','=','CNC加工')]}"/>
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" -->
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->
<!-- groups="sf_base.group_sf_mrp_user" -->
<button name="do_inspect" type="object" string="送检" class="btn-success" confirm="是否确认送检"
attrs="{'invisible': ['|', '|', ('state', 'not in', ('progress')), ('is_inspect', '=', False), ('production_line_state','!=','已下产线')]}"/>
<!-- <button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工" -->
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->
<!-- groups="sf_base.group_sf_mrp_user" -->
<!-- attrs="{'invisible': ['|', ('production_state', '!=', 'pending_processing'), ('state','!=','progress')]}"/> -->
<!-- <button name="button_unblock" type="object" string="Unblock" -->
<!-- context="{'default_workcenter_id': workcenter_id}" class="btn-danger" -->

View File

@@ -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