Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/【计划】模块的【排程单】页面优化需求

This commit is contained in:
mgw
2024-06-25 09:03:13 +08:00
11 changed files with 156 additions and 92 deletions

View File

@@ -331,7 +331,7 @@ class ToolInventory(models.Model):
work_material = fields.Selection([('', ''), ('', '')], string='加工材料')
life_span = fields.Float('寿命(min)')
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组', required=True)
active = fields.Boolean('已归档', default=True)

View File

@@ -555,9 +555,9 @@
<field name="model">sf.tool.inventory</field>
<field name="arch" type="xml">
<tree string="功能刀具清单" create="1" edit="1" delete="0" editable="bottom">
<field name="name"/>
<field name="name" attrs="{'readonly': [('id', '!=', False)]}"/>
<field name="functional_cutting_tool_model_id"/>
<field name="tool_groups_id"/>
<field name="tool_groups_id" required="1" attrs="{'readonly': [('id', '!=', False)]}"/>
<field name="work_material"/>
<field name="life_span"/>
<field name="prefix" optional="hide"/>

View File

@@ -19,6 +19,13 @@
<div>
<field name="button_compensation_state" attrs='{"invisible": ["|",
("state","!=","progress"),("user_permissions","=",False)]}'/>
<!-- <span>&#32;</span>-->
<button name="button_send_program_again" type="object" string="重新下发NC程序"
class="btn-primary"
confirm="是否确认重新下发NC程序"
groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"
attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',
'progress']),('processing_drawing','=',False),('is_send_program_again','=',True)]}"/>
<!-- <button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"-->
<!-- class="btn-primary" attrs='{"invisible": ["|",-->
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->

View File

@@ -531,15 +531,23 @@ class MrpProduction(models.Model):
def _reset_work_order_sequence(self):
for rec in self:
sequence_list = {}
# 产品模型类型
model_type_id = rec.product_id.product_model_type_id
# 产品加工面板
model_processing_panel = rec.product_id.model_processing_panel
if model_type_id:
if model_processing_panel:
tmpl_num = 1
panel_list = model_processing_panel.split(',')
for panel in panel_list:
panel_sequence_list = {}
# 成品工序
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
if product_routing_tmpl_ids:
for tmpl_id in product_routing_tmpl_ids:
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
panel_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
sequence_list.update({panel: panel_sequence_list})
# 表面工艺工序
# 模型类型的表面工艺工序模版
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
@@ -565,12 +573,21 @@ class MrpProduction(models.Model):
for tmpl_id in embryo_routing_tmpl_ids:
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
tmpl_num += 1
else:
raise ValidationError('该产品【加工面板】为空!')
else:
raise ValidationError('该产品没有选择【模版类型】!')
for work in rec.workorder_ids:
if sequence_list.get(work.name):
work.sequence = sequence_list[work.name]
elif sequence_list.get(work.processing_panel):
processing_panel = sequence_list.get(work.processing_panel)
if processing_panel.get(work.name):
work.sequence = processing_panel[work.name]
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
else:
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
# if work.name == '获取CNC加工程序':

View File

@@ -1090,8 +1090,15 @@ class ResMrpWorkOrder(models.Model):
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
self.write({'is_send_program_again': True})
self.production_id.write({'work_state': '编程中', 'programming_state': '编程中'})
productions = self.env['mrp.production'].search(
[('programming_no', '=', self.production_id.programming_no), ('programming_state', '=', '已编程')])
if productions:
workorder = productions.workorder_ids.filtered(
lambda ap: ap.routing_type in ['装夹预调', 'CNC加工'] and ap.state not in ['done', 'cancel',
'progress'])
if workorder:
workorder.write({'is_send_program_again': True})
productions.write({'work_state': '编程中', 'programming_state': '编程中'})
else:
raise UserError(result['message'])
except Exception as e:

View File

@@ -64,7 +64,8 @@
<xpath expr="//field[@name='state']" position="attributes">
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
<!-- </attribute> -->
<attribute name="statusbar_visible">progress,pending_cam,pending_processing,pending_era_cam,completed,done
<attribute name="statusbar_visible">
progress,pending_cam,pending_processing,pending_era_cam,completed,done
</attribute>
</xpath>
@@ -281,7 +282,7 @@
<field name="routing_type" invisible="True"/>
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user"/>
groups="sf_base.group_sf_mrp_user" confirm="是否确认开始?"/>
</xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace">
<button name="button_pending" type="object" string="Pause" class="btn-warning"
@@ -291,7 +292,8 @@
<xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="Done" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user"/>
groups="sf_base.group_sf_mrp_user"
confirm="是否确认完成?"/>
</xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block"
@@ -322,7 +324,7 @@
<xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="完成" class="btn-success"
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
groups="sf_base.group_sf_mrp_user"/>
groups="sf_base.group_sf_mrp_user" confirm="是否确认完成?"/>
</xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"

View File

@@ -162,7 +162,9 @@
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done')]}"/>
<button name="button_send_program_again" type="object" string="重新下发NC程序" class="btn-primary"
confirm="是否确认重新下发NC程序"
attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','not in',['ready','progress']),('processing_drawing','=',False),('is_send_program_again','=',True)]}"/>
groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"
attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',
'progress']),('cnc_worksheet','=',False),('is_send_program_again','=',True)]}"/>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>

View File

@@ -72,7 +72,8 @@ class Sf_Mrs_Connect(http.Controller):
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
cnc_workorder.write(
{'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret),
{'is_send_program_again': False,
'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret),
'cmm_ids': cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel, ret),
'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
pre_workorder = production.workorder_ids.filtered(
@@ -80,7 +81,8 @@ class Sf_Mrs_Connect(http.Controller):
'cancel'] and ap.processing_panel == panel)
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
{'is_send_program_again': False,
'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
cnc_program_ids = [item.id for item in productions]
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(

View File

@@ -581,6 +581,15 @@ class FunctionalToolAssembly(models.Model):
active = fields.Boolean(string='已归档', default=True)
def action_open_reference1(self):
self.ensure_one()
return {
'res_model': self._name,
'type': 'ir.actions.act_window',
'views': [[False, "form"]],
'res_id': self.id,
}
def put_start_preset(self):
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
self.write({
@@ -750,7 +759,8 @@ class FunctionalToolDismantle(models.Model):
return 'GNDJ-CJD-%s-%s' % (datetime, num)
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
domain=[('functional_tool_status', '!=', '已拆除')])
domain=[('functional_tool_status', '!=', '已拆除'),
('current_location', '=', '刀具房')])
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
compute='_compute_functional_tool_num')
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
@@ -1028,7 +1038,7 @@ class ProductProduct(models.Model):
'product_id': self.id,
'lot_id': lot_id.id,
'move_id': stock_move_id.id,
'destination_location_id': shelf_location_id.id,
'destination_location_id': shelf_location_id.id if shelf_location_id else False,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',

View File

@@ -387,6 +387,22 @@ class StockMoveLine(models.Model):
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(names)
def action_open_reference1(self):
self.ensure_one()
if self.functional_tool_name_id:
action = self.functional_tool_name_id.action_open_reference1()
return action
elif self.move_id:
action = self.move_id.action_open_reference()
if action['res_model'] != 'stock.move':
return action
return {
'res_model': self._name,
'type': 'ir.actions.act_window',
'views': [[False, "form"]],
'res_id': self.id,
}
class RealTimeDistributionOfFunctionalTools(models.Model):
_name = 'sf.real.time.distribution.of.functional.tools'

View File

@@ -477,7 +477,8 @@
<field name="name">功能刀具出入库记录</field>
<field name="model">stock.move.line</field>
<field name="arch" type="xml">
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0">
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0" default_order="id desc"
action="action_open_reference1" type="object">
<field name="reference" string="单据号"/>
<field name="lot_id" invisible="1"/>
<field name="rfid"/>