From ab9fcf97e0f4d1eb743c6149f648c51ebdf8601a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 1 Feb 2024 17:37:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BB=B6=E9=85=8D?= =?UTF-8?q?=E9=80=81=E6=89=AB=E6=8F=8F=E5=B7=A5=E4=BB=B6=EF=BC=88=E5=9D=AF?= =?UTF-8?q?=E6=96=99=EF=BC=89=E6=97=B6=EF=BC=8C=E5=90=8C=E8=BF=90=E5=B7=A5?= =?UTF-8?q?=E4=BB=B6=E6=98=BE=E7=A4=BA=E7=9A=84=E6=98=AF=E5=9D=AF=E6=96=99?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=85=8D=E9=80=81=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E5=8F=8A=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=97=B6=E9=95=BF=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BB=B6=E8=A3=85=E5=A4=B9=E5=B2=97?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E4=BF=AE=E6=94=B9=E9=85=8D=E9=80=81=E5=B7=A5?= =?UTF-8?q?=E4=BB=B6=202.=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81=E4=B8=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=80=BB=E7=9B=91=E5=B2=97=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E6=80=BB=E7=9B=91=E5=B2=97=E4=B8=8D=E8=83=BD=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E5=88=87=E5=89=8A=E9=80=9F=E5=BA=A6=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/security/ir.model.access.csv | 2 + sf_manufacturing/models/mrp_workorder.py | 59 ++++++++++--------- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/security/ir.model.access.csv | 4 +- sf_manufacturing/views/mrp_workorder_view.xml | 14 ++--- sf_sale/models/auto_quatotion_common.py | 3 +- sf_sale/models/quick_easy_order.py | 4 +- 7 files changed, 47 insertions(+), 43 deletions(-) diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 198e89d3..4c93643b 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -61,6 +61,8 @@ access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user, access_sf_cutting_speed_admin,sf_cutting_speed_admin,model_sf_cutting_speed,base.group_system,1,1,1,0 access_sf_cutting_speed_group_purchase_director,sf_cutting_speed_group_purchase_director,model_sf_cutting_speed,sf_base.group_purchase_director,1,1,1,0 access_sf_cutting_speed_group_sale_director,sf_cutting_speed_group_sale_director,model_sf_cutting_speed,sf_base.group_sale_director,1,1,1,0 +access_sf_cutting_speed_group_sf_stock_manager,sf_cutting_speed_group_sf_stock_manager,model_sf_cutting_speed,sf_base.group_sf_stock_manager,1,1,1,0 +access_sf_cutting_speed_group_plan_director,sf_cutting_speed_group_plan_director,model_sf_cutting_speed,sf_base.group_plan_director,1,1,1,0 access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,0 access_sf_feed_per_tooth_admin,sf_feed_per_tooth_admin,model_sf_feed_per_tooth,base.group_system,1,1,1,0 access_sf_ramping_angle,sf_ramping_angle,model_sf_ramping_angle,base.group_user,1,1,1,1 diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index b577c9ce..01687177 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -132,7 +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) + is_delivery = fields.Boolean('是否配送完成', default=False) @api.onchange('is_ok') def _onchange_inspection_user_id(self): @@ -197,25 +197,19 @@ 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("参数计算有误") def button_workpiece_delivery(self): if self.routing_type == '装夹预调': - if not self.workpiece_delivery_ids: - raise UserError('请添加【工件配送】信息') - else: - for item in self.workpiece_delivery_ids: - if not item.feeder_station_start: - raise UserError('【工件配送】明细中请输入起点接驳站') - if not item.workpiece_code: - raise UserError('请对【同运工件】进行扫描') - else: - item.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'}) + for item in self.workpiece_delivery_ids: + if not item.feeder_station_start: + raise UserError('【工件配送】明细中请输入起点接驳站') + # if not item.workpiece_code: + # raise UserError('请对【同运工件】进行扫描') + else: + item.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'}) # 拼接工单对象属性值 def json_workorder_str(self, k, production, route): @@ -760,6 +754,13 @@ class SfWorkOrderBarcodes(models.Model): 'tray_model_id': stock_move_line.product_id.fixture_model_id.id }) workorder.button_start() + # return { + # 'type': 'ir.actions.act_window', + # 'res_model': 'mrp.workorder', + # 'view_mode': 'form', + # 'domain': [('id', 'in', workorder.id)], + # 'target': 'current' + # } else: embryo_stock_lot = self.env['stock.lot'].search([('name', '=', barcode)]) if embryo_stock_lot: @@ -769,16 +770,20 @@ class SfWorkOrderBarcodes(models.Model): ('lot_id', '=', embryo_stock_lot.id), ('product_category_name', '=', '坯料')]) if embryo_stock_move_line: + bom_production = self.env['mrp.production'].search( + [('product_id', '=', embryo_stock_lot.product_id.id), + ('origin', '=', workorder.production_id.name)], limit=1, order='id asc') workpiece_delivery = self.env['sf.workpiece.delivery'].search( [('workorder_id', '=', workorder.id)], limit=1, order='id asc') if workpiece_delivery: embryo_workpiece_code = workpiece_delivery.workpiece_code - if workpiece_delivery.workpiece_code and embryo_stock_lot.name not in \ - workpiece_delivery.workpiece_code: - embryo_workpiece_code = workpiece_delivery.workpiece_code + ',' + \ - embryo_stock_lot.name - if not workpiece_delivery.workpiece_code: - embryo_workpiece_code = embryo_stock_lot.name + if bom_production: + if workpiece_delivery.workpiece_code and bom_production.name not in \ + workpiece_delivery.workpiece_code: + embryo_workpiece_code = workpiece_delivery.workpiece_code + ',' + \ + bom_production.name + if not workpiece_delivery.workpiece_code: + embryo_workpiece_code = bom_production.name workpiece_delivery.write({'workpiece_code': embryo_workpiece_code}) else: raise UserError('工件生产线不一致,请重新确认') @@ -799,7 +804,7 @@ class WorkPieceDelivery(models.Model): feeder_station_destination = fields.Char('目的接驳站') task_delivery_time = fields.Datetime('任务下发时间') task_completion_time = fields.Datetime('任务完成时间') - delivery_time = fields.Char('配送时长', compute='_compute_delivery_time') + delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发') @@ -830,14 +835,10 @@ class WorkPieceDelivery(models.Model): self.plan_start_processing_time = self.production_id.plan_start_processing_time @api.depends('task_delivery_time', 'task_completion_time') - def _compute_delivery_time(self): + def _compute_delivery_duration(self): for obj in self: if obj.task_delivery_time and obj.task_completion_time: - delivery_duration = obj.task_completion_time - obj.task_delivery_time - hours, seconds = divmod(delivery_duration.total_seconds(), 3600) - minutes, _ = divmod(seconds, 60) - delivery_time_str = "{:.0f}时 {:.0f}分".format(hours, minutes) - - obj.delivery_time = delivery_time_str + obj.delivery_duration = round( + (obj.task_completion_time - obj.task_delivery_time).total_seconds() / 60.0, 2) else: - obj.delivery_time = '' + obj.delivery_duration = 0.0 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 3606c3d3..2dd36758 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -22,10 +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_group_sf_order_user,sf_workpiece_delivery_group_sf_order_user,model_sf_workpiece_delivery,sf_base.group_sf_order_user,1,1,0,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_sf_workpiece_delivery_wizard_group_sf_order_user,sf_workpiece_delivery_wizard_group_sf_order_user,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 77a78463..e825ef48 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -124,8 +124,8 @@ context="{'default_workcenter_id': workcenter_id}" class="btn-danger" groups="sf_base.group_sf_mrp_user" attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -