From 527ab396eeed03fb7b09be7552c5efc835145fb8 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 30 Jan 2024 17:40:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BB=B6?= =?UTF-8?q?=E9=85=8D=E9=80=81=E5=90=91=E5=AF=BC2.=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=AE=A1=E6=A0=B8=E6=8C=89=E9=92=AE=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E8=A7=813.=E9=85=8D=E7=BD=AE=E4=B8=AD=E6=96=B0?= =?UTF-8?q?=E5=A2=9Eagv=E8=B7=AF=E5=BE=84=E5=AD=97=E6=AE=B54.=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=B7=A5=E5=8D=95=E4=B8=8A=E6=8C=89=E9=92=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__init__.py | 1 + sf_manufacturing/__manifest__.py | 1 + sf_manufacturing/models/mrp_workorder.py | 33 ++++++++++++++++--- sf_manufacturing/models/product_template.py | 4 +-- sf_manufacturing/security/ir.model.access.csv | 6 ++-- sf_manufacturing/views/mrp_workorder_view.xml | 29 +++++++++------- sf_manufacturing/wizard/__init__.py | 1 + .../wizard/workpiece_delivery_views.xml | 27 +++++++++++++++ .../wizard/workpiece_delivery_wizard.py | 16 +++++++++ sf_mrs_connect/models/res_config_setting.py | 1 + sf_sale/models/auto_quatotion_common.py | 2 +- sf_sale/models/quick_easy_order.py | 4 +-- sf_sale/security/ir.model.access.csv | 3 +- sf_sale/views/purchase_order_view.xml | 2 +- 14 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 sf_manufacturing/wizard/__init__.py create mode 100644 sf_manufacturing/wizard/workpiece_delivery_views.xml create mode 100644 sf_manufacturing/wizard/workpiece_delivery_wizard.py diff --git a/sf_manufacturing/__init__.py b/sf_manufacturing/__init__.py index f7209b17..48d99043 100644 --- a/sf_manufacturing/__init__.py +++ b/sf_manufacturing/__init__.py @@ -1,2 +1,3 @@ from . import models from . import controllers +from . import wizard diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 85e71a5d..3834e25f 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -15,6 +15,7 @@ 'data/stock_data.xml', 'security/group_security.xml', 'security/ir.model.access.csv', + 'wizard/workpiece_delivery_views.xml', 'views/mrp_views_menus.xml', 'views/mrp_production_addional_change.xml', 'views/mrp_routing_workcenter_view.xml', diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d066582b..b577c9ce 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -132,6 +132,7 @@ class ResMrpWorkOrder(models.Model): production_line = fields.Char(string="生产线") preset_program_information = fields.Char(string="预调程序信息") workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送') + is_delivery = fields.Boolean('是否配送完成',default=False) @api.onchange('is_ok') def _onchange_inspection_user_id(self): @@ -196,8 +197,10 @@ class ResMrpWorkOrder(models.Model): work = workorder.production_id.workorder_ids work.compensation_value_x = eval(self.material_center_point)[0] work.compensation_value_y = eval(self.material_center_point)[1] + workorder.workpiece_delivery_ids[0].write({ + 'status': '待下发' + }) workorder.button_finish() - except: raise UserError("参数计算有误") @@ -212,7 +215,7 @@ class ResMrpWorkOrder(models.Model): if not item.workpiece_code: raise UserError('请对【同运工件】进行扫描') else: - item.write({'task_delivery_time': fields.Datetime.now()}) + item.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'}) # 拼接工单对象属性值 def json_workorder_str(self, k, production, route): @@ -788,7 +791,7 @@ class WorkPieceDelivery(models.Model): workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True) production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True) production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id', - string='目标生产线', readonly=True, + string='目的生产线', readonly=True, store=True) plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True) workpiece_code = fields.Char('同运工件编码') @@ -797,8 +800,28 @@ class WorkPieceDelivery(models.Model): task_delivery_time = fields.Datetime('任务下发时间') task_completion_time = fields.Datetime('任务完成时间') delivery_time = fields.Char('配送时长', compute='_compute_delivery_time') - status = fields.Selection([('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', - default='待下发') + status = fields.Selection( + [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', + default='待下发') + + # 工件配送 + def button_delivery(self): + if self.status == '待下发': + return { + 'name': _('确认'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'sf.workpiece.delivery.wizard', + 'target': 'new', + 'context': { + 'default_delivery_id': self.id, + }} + else: + raise UserError('状态为【待下发】的工件记录可进行配送') + + # 配送至avg小车 + def _delivery_avg(self): + self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'}) @api.depends('production_id.production_line_id') def _compute_production_line_id(self): diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index b9209d57..e53126c5 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -6,8 +6,8 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 2e62b610..3606c3d3 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -22,12 +22,10 @@ access_mrp_workcenter,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_u access_mrp_workcenter_manager,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_manager,1,1,1,0 access_mrp_workcenter_productivity,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_user,1,0,0,0 access_mrp_workcenter_productivity_manager,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_manager,1,1,1,0 - access_sf_workpiece_delivery,sf_workpiece_delivery,model_sf_workpiece_delivery,sf_base.group_sf_mrp_user,1,0,0,0 -access_sf_workpiece_delivery_manager,sf_workpiece_delivery,model_sf_workpiece_delivery,sf_base.group_sf_mrp_manager,1,1,1,0 +access_sf_workpiece_delivery_manager,sf_workpiece_delivery,model_sf_workpiece_delivery,sf_base.group_sf_mrp_manager,1,1,0,0 access_sf_workpiece_delivery_admin,sf_workpiece_delivery_admin,model_sf_workpiece_delivery,base.group_system,1,1,1,0 - - +access_sf_workpiece_delivery_wizard,sf_workpiece_delivery_wizard,model_sf_workpiece_delivery_wizard,sf_base.group_sf_order_user,1,1,1,0 access_mrp_workcenter_productivity_loss_manager,mrp.workcenter.productivity.loss,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_sf_mrp_user,1,1,1,0 access_mrp_workcenter_productivity_loss,mrp.workcenter.productivity.loss,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_sf_mrp_user,1,0,0,0 access_mrp_workcenter_productivity_loss_type,mrp.workcenter.productivity.loss.type,mrp.model_mrp_workcenter_productivity_loss_type,sf_base.group_sf_mrp_user,1,0,0,0 diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 62d1ccd4..77a78463 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -104,27 +104,28 @@ +