Compare commits
12 Commits
release/re
...
feature/逾期
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b551777d49 | ||
|
|
01fa7bbe87 | ||
|
|
c793089131 | ||
|
|
83e57b63ec | ||
|
|
e14e750bd9 | ||
|
|
1c4a6ca85e | ||
|
|
c922ae1571 | ||
|
|
ed6189a963 | ||
|
|
a6979b213b | ||
|
|
f873ebe079 | ||
|
|
e50b601ccf | ||
|
|
37c47b0a54 |
@@ -24,6 +24,7 @@
|
||||
'wizard/production_wizard_views.xml',
|
||||
'wizard/production_technology_wizard_views.xml',
|
||||
'wizard/production_technology_re_adjust_wizard_views.xml',
|
||||
'wizard/mrp_workorder_batch_replan_wizard_views.xml',
|
||||
'views/mrp_views_menus.xml',
|
||||
'views/agv_scheduling_views.xml',
|
||||
'views/stock_lot_views.xml',
|
||||
@@ -38,6 +39,7 @@
|
||||
'views/sf_maintenance_equipment.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/sale_order_views.xml',
|
||||
'views/mrp_workorder_batch_replan.xml',
|
||||
],
|
||||
'assets': {
|
||||
|
||||
|
||||
@@ -378,16 +378,37 @@ class MrpProduction(models.Model):
|
||||
if process_parameters:
|
||||
raise UserError(_("【工艺设计】-【参数】为%s的在【产品】中不存在,请先创建", ", ".join(process_parameters)))
|
||||
if production_confirmed:
|
||||
return {
|
||||
'name': _('退回调整'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.production.technology.re_adjust.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
production_count = self.env['mrp.production'].search_count([
|
||||
('origin', '=', self.origin),
|
||||
('product_id', '=', self.product_id.id),
|
||||
('state', '=', 'confirmed')
|
||||
])
|
||||
if production_count > 1:
|
||||
return {
|
||||
'name': _('退回调整'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [(self.env.ref(
|
||||
'sf_manufacturing.sf_production_technology_re_adjust_wizard_form_view').id,
|
||||
'form')],
|
||||
'res_model': 'sf.production.technology.re_adjust.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
else:
|
||||
return {
|
||||
'name': _('退回调整'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [(self.env.ref(
|
||||
'sf_manufacturing.sf_production_technology_re_adjust_wizard_confirm_form_view').id,
|
||||
'form')],
|
||||
'res_model': 'sf.production.technology.re_adjust.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
|
||||
# 工艺确认
|
||||
def technology_confirm(self):
|
||||
@@ -441,16 +462,37 @@ class MrpProduction(models.Model):
|
||||
error_panel.append(design.panel)
|
||||
else:
|
||||
if not error_panel and not process_parameters:
|
||||
return {
|
||||
'name': _('工艺确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.production.technology.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
production_count = self.env['mrp.production'].search_count([
|
||||
('origin', '=', self.origin),
|
||||
('product_id', '=', self.product_id.id),
|
||||
('state', '=', 'technology_to_confirmed')
|
||||
])
|
||||
if production_count > 1:
|
||||
return {
|
||||
'name': _('工艺确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [(self.env.ref(
|
||||
'sf_manufacturing.sf_production_technology_wizard_form_view').id,
|
||||
'form')],
|
||||
'res_model': 'sf.production.technology.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
else:
|
||||
return {
|
||||
'name': _('工艺确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'views': [(self.env.ref(
|
||||
'sf_manufacturing.sf_production_technology_wizard_confirm_form_view').id,
|
||||
'form')],
|
||||
'res_model': 'sf.production.technology.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': self.id,
|
||||
'default_origin': self.origin,
|
||||
}}
|
||||
if error_panel:
|
||||
raise UserError(_("【加工面】为%s的标准工序顺序有误,请调整后重试", ", ".join(error_panel)))
|
||||
return True
|
||||
@@ -762,7 +804,7 @@ class MrpProduction(models.Model):
|
||||
# 立即创建外协出入库单和采购订单
|
||||
# self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||
# self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||
# product_id_to_production_names)
|
||||
# product_id_to_production_names)
|
||||
consecutive_workorders = []
|
||||
|
||||
# 处理最后一个组,即使它可能只有一个工作订单
|
||||
@@ -774,6 +816,7 @@ class MrpProduction(models.Model):
|
||||
for workorders in reversed(proc_workorders):
|
||||
self.env['stock.picking'].create_outcontract_picking(workorders, production, sorted_workorders)
|
||||
self.env['purchase.order'].get_purchase_order(workorders, production, product_id_to_production_names)
|
||||
|
||||
# 工单排序
|
||||
def _reset_work_order_sequence1(self, k):
|
||||
for rec in self:
|
||||
@@ -1495,7 +1538,9 @@ class MrpProduction(models.Model):
|
||||
|
||||
def action_view_purchase_orders(self):
|
||||
self.ensure_one()
|
||||
if self.product_id.product_tmpl_id.single_manufacturing == True:
|
||||
if self.is_remanufacture:
|
||||
production = self
|
||||
elif self.product_id.product_tmpl_id.single_manufacturing == True:
|
||||
production = self.env['mrp.production'].search(
|
||||
[('origin', '=', self.origin), ('product_id', '=', self.product_id.id)], limit=1, order='id asc')
|
||||
else:
|
||||
|
||||
@@ -129,7 +129,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
Y10_axis = fields.Float(default=0)
|
||||
Z10_axis = fields.Float(default=0)
|
||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
||||
test_results = fields.Selection([("合格", "合格")], default='合格',
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果", tracking=True)
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
||||
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
||||
|
||||
@@ -993,7 +993,8 @@ class ReStockMove(models.Model):
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search(
|
||||
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
if productions.mapped('name'):
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
res['retrospect_ref'] = production.product_id.name
|
||||
return res
|
||||
|
||||
|
||||
@@ -182,3 +182,5 @@ access_sf_manual_product_model_type_routing_sort_group_sf_mrp_user,sf_manual_pro
|
||||
access_sf_manual_product_model_type_routing_sort_manager,sf_manual_product_model_type_routing_sort,model_sf_manual_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||
access_sf_manual_product_model_type_routing_sort_group_plan_dispatch,sf_manual_product_model_type_routing_sort_group_plan_dispatch,model_sf_manual_product_model_type_routing_sort,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_detection_result_manager,sf_detection_result_manager,model_sf_detection_result,,1,1,1,1
|
||||
|
||||
access_mrp_workorder_batch_replan_wizard_group_plan_dispatch,mrp_workorder_batch_replan_wizard_group_plan_dispatch,model_mrp_workorder_batch_replan_wizard,sf_base.group_plan_dispatch,1,1,1,0
|
||||
|
18
sf_manufacturing/views/mrp_workorder_batch_replan.xml
Normal file
18
sf_manufacturing/views/mrp_workorder_batch_replan.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="mrp_production_workorder_tree_editable_view_inherit" model="ir.ui.view">
|
||||
<field name="name">>mrp.workorder.tree.editable.inherit</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree/field[1]" position="before">
|
||||
<header>
|
||||
<button string="重新安排" name="%(sf_manufacturing.mrp_workorder_batch_replan_wizard)d" type="action"
|
||||
class="treeHeaderBtn"
|
||||
invisible="context.get('workorder_type') not in ('工件装夹中心','1#自动生产线','工件拆卸中心')"/>
|
||||
</header>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -200,7 +200,7 @@
|
||||
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
||||
<!-- <button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"-->
|
||||
<!-- attrs="{'invisible': ['|','|','|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done'),('is_rework','=',True),'&',('rfid_code','in',['',False]),('state','=','done')]}"/>-->
|
||||
<button name="button_rework_pre" type="object" string="异常反馈" invisible="1"
|
||||
<button name="button_rework_pre" type="object" string="异常反馈"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('state','!=','progress'),('is_rework','=',True)]}"/>
|
||||
<button name="unbind_tray" type="object" string="解绑托盘"
|
||||
|
||||
@@ -3,3 +3,4 @@ from . import rework_wizard
|
||||
from . import production_wizard
|
||||
from . import production_technology_wizard
|
||||
from . import production_technology_re_adjust_wizard
|
||||
from . import mrp_workorder_batch_replan_wizard
|
||||
|
||||
70
sf_manufacturing/wizard/mrp_workorder_batch_replan_wizard.py
Normal file
70
sf_manufacturing/wizard/mrp_workorder_batch_replan_wizard.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, api, fields, _
|
||||
|
||||
|
||||
class MrpWorkorderBatchReplanWizard(models.TransientModel):
|
||||
_name = 'mrp.workorder.batch.replan.wizard'
|
||||
_description = '制造订单批量重新安排向导'
|
||||
|
||||
def _get_date_planned_start(self):
|
||||
planned_start_date = datetime.now() + timedelta(hours=2)
|
||||
logging.info('计划开始加工时间: %s', planned_start_date)
|
||||
return planned_start_date
|
||||
|
||||
def _get_default_workorder_count(self):
|
||||
active_ids = self.env.context.get('active_ids', [])
|
||||
return len(active_ids)
|
||||
|
||||
def _get_default_workorder_type(self):
|
||||
active_ids = self.env.context.get('active_ids', [])
|
||||
if active_ids:
|
||||
workorders = self.env['mrp.workorder'].browse(active_ids)
|
||||
if workorders:
|
||||
routing_type = set(workorders.mapped('routing_type'))
|
||||
return '/'.join(sorted(routing_type)) if routing_type else None
|
||||
return None
|
||||
|
||||
workorder_type = fields.Char(string='工单类型', default=_get_default_workorder_type, readonly=True)
|
||||
|
||||
workorder_count = fields.Integer(string='工单数量',
|
||||
default=_get_default_workorder_count,
|
||||
readonly=True)
|
||||
|
||||
workorder_id = fields.Many2many('mrp.workorder', string=u'工单')
|
||||
|
||||
def confirm(self):
|
||||
routing_type = set(self.workorder_id.mapped('routing_type'))
|
||||
if len(routing_type) > 1:
|
||||
raise models.ValidationError("批量重新安排工单类型必须一致。")
|
||||
show_json_popover = self.workorder_id.mapped('show_json_popover')
|
||||
if any(not value for value in show_json_popover):
|
||||
raise models.ValidationError("所选工单必须都为逾期状态")
|
||||
failed_workorders = {}
|
||||
for workorder_info in self.workorder_id:
|
||||
try:
|
||||
workorder_info.action_replan()
|
||||
except Exception as e:
|
||||
reason = str(e)
|
||||
if reason in failed_workorders:
|
||||
failed_workorders[reason].append(
|
||||
workorder_info.production_id.name)
|
||||
else:
|
||||
failed_workorders[reason] = [workorder_info.production_id.name]
|
||||
if failed_workorders:
|
||||
error_messages = "\n".join(
|
||||
[f"制造订单: {', '.join(workorder_names)}, 原因: {reason}" for reason, workorder_names in
|
||||
failed_workorders.items()])
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'message': f"以下工单重新安排失败:\n{error_messages}",
|
||||
'sticky': False,
|
||||
'color': 'red',
|
||||
'next': {
|
||||
'type': 'ir.actions.act_window_close'
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="mrp_workorder_batch_replan_wizard_form" model="ir.ui.view">
|
||||
<field name="name">mrp.workorder.batch.replan.wizard.form.view</field>
|
||||
<field name="model">mrp.workorder.batch.replan.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<field name="workorder_type"/>
|
||||
<field name="workorder_count"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="取消" class="btn-primary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="mrp_workorder_batch_replan_wizard" model="ir.actions.act_window">
|
||||
<field name="name">重新安排工单</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.workorder.batch.replan.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="mrp_workorder_batch_replan_wizard_form"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'default_workorder_id': active_ids}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -21,6 +21,26 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="sf_production_technology_re_adjust_wizard_confirm_form_view">
|
||||
<field name="name">sf.production.technology.re_adjust.wizard.form.view</field>
|
||||
<field name="model">sf.production.technology.re_adjust.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="origin" invisible="1"/>
|
||||
<div>
|
||||
是否确认退回调整
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sf_production_technology_re_adjust_wizard" model="ir.actions.act_window">
|
||||
<field name="name">工艺退回调整</field>
|
||||
<field name="res_model">sf.production.technology.re_adjust.wizard</field>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="sf_production_technology_wizard_form_view">
|
||||
<record model="ir.ui.view" id="sf_production_technology_wizard_form_view">
|
||||
<field name="name">sf.production.technology.wizard.form.view</field>
|
||||
<field name="model">sf.production.technology.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -13,7 +13,28 @@
|
||||
对当前制造订单,同一销售订单相同产品所生成的制造订单统一进行工艺调整与确认
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认工艺调整"/>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"
|
||||
confirm="是否确认工艺调整"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="sf_production_technology_wizard_confirm_form_view">
|
||||
<field name="name">sf.production.technology.wizard.form.view</field>
|
||||
<field name="model">sf.production.technology.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="production_id" invisible="1"/>
|
||||
<field name="origin" invisible="1"/>
|
||||
<div>
|
||||
是否确认工艺调整
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
|
||||
@@ -25,7 +25,7 @@ class SfQualityCncTest(models.Model):
|
||||
('pass', '合格'),
|
||||
('fail', '不合格')], string='判定结果')
|
||||
number = fields.Integer('数量', default=1)
|
||||
test_results = fields.Selection([("合格", "合格")], string="检测结果")
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<t t-if="record.workorder_count.raw_value > 0">
|
||||
<button class="btn btn-primary" name="action_work_order" type="object"
|
||||
attrs="{'invisible': [('name', '=', '功能刀具组装中心')]}"
|
||||
context="{'search_default_ready': 1, 'search_default_progress': 1}">
|
||||
context="{'search_default_ready': 1, 'search_default_progress': 1, 'workorder_type': name}">
|
||||
<span>工单</span>
|
||||
</button>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user