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