From 5b0df0befd0fd2af576745129c63506292bf7913 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 17 Jul 2023 16:39:30 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=8E=86=E8=AE=BE=E7=BD=AE=E5=BC=80=E5=A7=8B=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E4=B8=BA?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=89=80=E9=80=89=E7=8F=AD=E6=AC=A1=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/models/base.py | 2 +- sf_plan_management/models/calendar_base.py | 89 ++++++--------------- sf_plan_management/views/plan_base_view.xml | 23 ++---- 3 files changed, 32 insertions(+), 82 deletions(-) diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index ca6e4693..831b735c 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -49,7 +49,7 @@ class ProcedureEquipmentResourceSetting(models.Model): @api.depends('working_calendar_id') def _onchange_working_calendar_id(self): for record in self: - record.working_shift_id = record.working_calendar_id.working_shift_id + record.working_shift_ids = record.working_calendar_id.working_shift_ids diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index 5dd7df99..5dde27db 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -1,21 +1,5 @@ -from datetime import datetime, timedelta, date - +from datetime import datetime, timedelta from odoo import models, fields, api -import re - -from odoo.exceptions import ValidationError - - -def time_H_selection(): - return [('00', '00'), ('01', '01'), ('02', '02'), ('03', '03'), ('04', '04'), ('05', '05'), - ('06', '06'), ('07', '07'), ('08', '08'), ('09', '09'), ('10', '10'), ('11', '11'), - ('12', '12'), ('13', '13'), ('14', '14'), ('15', '15'), ('16', '16'), ('17', '17'), - ('18', '18'), ('19', '19'), ('20', '20'), ('21', '21'), ('22', '22'), ('23', '23')] - - -def time_M_or_S_selection(): - return [('00', '00'), ('05', '05'), ('10', '10'), ('15', '15'), ('20', '20'), ('25', '25'), - ('30', '30'), ('35', '35'), ('40', '40'), ('45', '45'), ('50', '50'), ('55', '55')] class WorkLogSetting(models.Model): @@ -38,20 +22,15 @@ class WorkLogSetting(models.Model): num = "%03d" % m return num - code = fields.Char(string='序号', default=_get_code, readonly=True) + code = fields.Char(string='序号', default=_get_code) name = fields.Char(string='工作日历名称', required=True, size=15, length=30) - start_time = fields.Char(string='日开始时间', readonly=True, compute='_compute_start_time') - start_time_H = fields.Selection(time_H_selection(), '时', required=True) - start_time_M = fields.Selection(time_M_or_S_selection(), '分', required=True) - end_time = fields.Char(string='日结束时间', readonly=True, compute='_compute_end_time') - end_time_H = fields.Selection(time_H_selection(), '时', required=True) - end_time_M = fields.Selection(time_M_or_S_selection(), '分', required=True) + working_shift_ids = fields.Many2many('sf.working.shift', string='班次') + start_time = fields.Datetime(string='日开始时间', readonly=True, compute='_compute_working_shift_ids') + end_time = fields.Datetime(string='日结束时间', readonly=True, compute='_compute_working_shift_ids') + duration = fields.Char(string='时长', readonly=True, compute='_compute_working_shift_ids') - duration = fields.Char(string='时长', readonly=True, compute='_compute_duration') - day_off_id = fields.Many2many('sf.day.off', string='休息日', required=True) - - working_shift_id = fields.Many2many('sf.working.shift', string='班次') + day_off_ids = fields.Many2many('sf.day.off', string='休息日', required=True) status = fields.Boolean(string='状态', default=True) update_person = fields.Char(string='更新人', default=lambda self: self.env.user.name) @@ -59,48 +38,28 @@ class WorkLogSetting(models.Model): setting_to_calendar_ids = fields.One2many('sf.work.schedule.calendar', 'name_id', '工作日历') - # @api.model - # def create(self, vals): - # vals['setting_to_calendar_ids'] = [(4, child.id)] - # return super(WorkLogSetting, self).create(vals) - - @api.depends('start_time_H', 'start_time_M') - def _compute_start_time(self): + @api.depends('working_shift_ids') + def _compute_working_shift_ids(self): """ - 设置输入日开始时间 + 根据所选班次自动生成开始时间和结束时间,同时计算出工作时长 :return: """ for record in self: - record.start_time = f"{record.start_time_H}:{record.start_time_M}:00" + if record: + for working_shift_id in record.working_shift_ids: + if not record.start_time: + record.start_time = working_shift_id.start_time + record.end_time = working_shift_id.end_time + else: + if (working_shift_id.start_time - record.start_time).total_seconds() < 0: + record.start_time = working_shift_id.start_time + if (working_shift_id.end_time - record.end_time).total_seconds() > 0: + record.end_time = working_shift_id.end_time - @api.depends('end_time_H', 'end_time_M') - def _compute_end_time(self): - """ - 设置输入日结束时间 - :return: - """ - for record in self: - record.end_time = f"{record.end_time_H}:{record.end_time_M}:00" + record.duration = record.end_time - record.start_time - @api.depends('start_time_H', 'start_time_M', 'end_time_H', 'end_time_M') - def _compute_duration(self): - """ - 根据日开始时间和日结束时间计算每日工作时长 - :return: - """ - for record in self: - st_h = float(record.start_time_H) - st_m = float(record.start_time_M) - end_h = float(record.end_time_H) - end_m = float(record.end_time_M) - # 日开始时间小于日结束时间 - if st_h < end_h: - record.duration = str(round(end_h - st_h + (end_m - st_m) / 60, 2)) - else: - record.duration = str(round(end_h - st_h + (end_m - st_m) / 60 + 24, 2)) - - # @api.onchange('day_off_id') - # def _onchange_day_off_id(self): + # @api.onchange('day_off_ids') + # def _onchange_day_off_ids(self): # # 先删除之前创建的工作日历事件记录 # self.env['sf.work.schedule.calendar'].search([('calendar_code', '=', self.code)]).unlink() # @@ -176,7 +135,7 @@ class WorkLogSetting(models.Model): start_date = datetime.now().replace(month=1, day=1).date() end_date = datetime.now().replace(month=12, day=31).date() # 休息日列表 - rest_days = self.day_off_id.mapped('name') + rest_days = self.day_off_ids.mapped('name') for single_date in self.daterange(start_date, end_date): is_workday = single_date.strftime("%A") if is_workday in rest_days: diff --git a/sf_plan_management/views/plan_base_view.xml b/sf_plan_management/views/plan_base_view.xml index 04aa3400..0b1c8f06 100644 --- a/sf_plan_management/views/plan_base_view.xml +++ b/sf_plan_management/views/plan_base_view.xml @@ -11,8 +11,8 @@ - - + + @@ -40,30 +40,20 @@ - + - - - - - - - - + - - - - + - @@ -198,6 +188,7 @@ + From ebda457684793c5bb592bf9aeb5bb5ebce903ae0 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 17 Jul 2023 16:45:52 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B5=84=E6=BA=90=E8=AE=BE=E7=BD=AE=E6=96=B0?= =?UTF-8?q?=E5=BB=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan_management/models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index 831b735c..9a9c5fe3 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -49,7 +49,7 @@ class ProcedureEquipmentResourceSetting(models.Model): @api.depends('working_calendar_id') def _onchange_working_calendar_id(self): for record in self: - record.working_shift_ids = record.working_calendar_id.working_shift_ids + record.working_shift_id = record.working_calendar_id.working_shift_ids From f68dce9ee255ec15b2efac5220fde61b886e98a7 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 17 Jul 2023 16:46:01 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=AD=E4=BA=A7=E5=93=81=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E4=B8=BA=E5=88=80=E5=85=B7=E5=92=8C=E5=A4=B9=E5=85=B7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=A0=B9=E6=8D=AE=E4=BA=A7=E5=93=81=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E4=B8=BA=E5=88=80=E5=85=B7=E5=92=8C=E5=A4=B9=E5=85=B7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=9A=84page=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E5=8F=8A?= =?UTF-8?q?=E5=9B=9E=E6=98=BEBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/fixture.py | 25 +- sf_base/views/fixture_view.xml | 2 +- sf_bf_connect/controllers/controllers.py | 6 - sf_dlm/__manifest__.py | 1 - sf_dlm/data/cutting_tool_data.xml | 16 - sf_dlm/views/product_template_view.xml | 42 +- sf_manufacturing/models/product_template.py | 178 +-- sf_mrs_connect/models/sync_common.py | 12 +- .../static/src/lib/model-viewer.min.js | 1126 +++++++++++++++++ 9 files changed, 1215 insertions(+), 193 deletions(-) delete mode 100644 sf_dlm/data/cutting_tool_data.xml create mode 100644 web_widget_model_viewer/static/src/lib/model-viewer.min.js diff --git a/sf_base/models/fixture.py b/sf_base/models/fixture.py index 033ac181..fa0972bf 100644 --- a/sf_base/models/fixture.py +++ b/sf_base/models/fixture.py @@ -32,21 +32,18 @@ class FixtureModel(models.Model): clamping_way = fields.Char(string="装夹方式") port_type = fields.Char(string="接口类型") model_file = fields.Binary(string="3D模型图") - length = fields.Char(string="长度[mm]") - width = fields.Char(string="宽度[mm]") - height = fields.Char(string="高度[mm]") - weight = fields.Char(string="重量[kg]") - clamp_workpiece_length_max = fields.Char(string="夹持工件长度MAX[mm]") - clamp_workpiece_width_max = fields.Char(string="夹持工件宽度MAX[mm]") - clamp_workpiece_height_max = fields.Char(string="夹持工件高度MAX[mm]") - clamp_workpiece_diameter_max = fields.Char(string="夹持工件直径MAX[mm]") - maximum_carrying_weight = fields.Char(string="最大承载重量[kg]") - maximum_clamping_force = fields.Char(string="最大夹持力[n]") + length = fields.Char(string="长度[mm]", size=6) + width = fields.Char(string="宽度[mm]", size=6) + height = fields.Char(string="高度[mm]", size=6) + weight = fields.Char(string="重量[kg]", size=4) + clamp_workpiece_length_max = fields.Char(string="夹持工件长度MAX[mm]", size=6) + clamp_workpiece_width_max = fields.Char(string="夹持工件宽度MAX[mm]", size=6) + clamp_workpiece_height_max = fields.Char(string="夹持工件高度MAX[mm]", size=6) + clamp_workpiece_diameter_max = fields.Char(string="夹持工件直径MAX[mm]", size=6) + maximum_carrying_weight = fields.Char(string="最大承载重量[kg]", size=4) + maximum_clamping_force = fields.Char(string="最大夹持力[n]", size=8) materials_model_id = fields.Many2one('sf.materials.model', string="材料型号") driving_way = fields.Char(string="驱动方式") - apply_machine_tool_type = fields.Char(string="适用机床型号") + apply_machine_tool_type_id = fields.Many2one('sf.machine_tool.type', string="适用机床型号") through_hole_size = fields.Integer(string="过孔大小[mm]", size=6) screw_size = fields.Integer(string="螺牙大小[mm]", size=6) - - - diff --git a/sf_base/views/fixture_view.xml b/sf_base/views/fixture_view.xml index de9134aa..e064e102 100644 --- a/sf_base/views/fixture_view.xml +++ b/sf_base/views/fixture_view.xml @@ -239,7 +239,7 @@ attrs='{"invisible": [("fixture_material_type","!=",("转接板(锁板)托盘"))]}'/> - diff --git a/sf_bf_connect/controllers/controllers.py b/sf_bf_connect/controllers/controllers.py index 3a48d16f..4442567e 100644 --- a/sf_bf_connect/controllers/controllers.py +++ b/sf_bf_connect/controllers/controllers.py @@ -34,12 +34,6 @@ class Sf_Bf_Connect(http.Controller): logging.info('get_bfm_process_or===================================:%s' % order_id.name) aa.default_code = kw['order_number'] logging.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code) - # # 给stock.picking的default_code字段赋值 - # bb = request.env['stock.picking'].sudo().search([('origin', '=', order_id.name)]) - # logging.info('get_bfm_process_or===================================:%s' % order_id.name) - # bb.default_code = kw['order_number'] - # logging.info('get_bfm_process_order_listbbbbbbbbbbbbbbbbbbbbbbbbbbbb================:%s' % bb.default_code) - for item in bfm_process_order_list: product = request.env['product.template'].sudo().product_create(product_id, item, order_id, kw['order_number'], i) diff --git a/sf_dlm/__manifest__.py b/sf_dlm/__manifest__.py index 9a2b3150..20211cde 100644 --- a/sf_dlm/__manifest__.py +++ b/sf_dlm/__manifest__.py @@ -15,7 +15,6 @@ 'data': [ 'data/product_data.xml', 'data/uom_data.xml', - # 'data/cutting_tool_data.xml', 'views/product_template_view.xml', 'views/product_workorder.xml' ], diff --git a/sf_dlm/data/cutting_tool_data.xml b/sf_dlm/data/cutting_tool_data.xml deleted file mode 100644 index 9153306e..00000000 --- a/sf_dlm/data/cutting_tool_data.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - 刀具 - 刀具 - - - - 夹具 - 夹具 - - - - - diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index c475f529..a4a9d998 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -79,7 +79,7 @@ - + @@ -91,10 +91,9 @@ - + - /> - + @@ -123,7 +122,7 @@ - + - + @@ -160,7 +157,7 @@ attrs="{'invisible': [('cutting_tool_type', 'not in', ['刀杆','刀盘'])]}"/> - + @@ -170,7 +167,7 @@ - + @@ -185,7 +182,7 @@ - + @@ -193,7 +190,7 @@ - + @@ -206,7 +203,7 @@ - + - + - + attrs='{"invisible": ["|",("fixture_model_id", "=", False),("fixture_material_type","not in",("气动托盘","转接板(锁板)托盘","磁吸托盘","虎钳托盘","零点卡盘"))]}'>