From b498637154dde7780f8ad45012239434c8834b09 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 25 Nov 2022 10:56:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9cnc=E7=BC=96=E7=A8=8B?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/models/product_template.py | 37 ++++++++++-------- sf_dlm/views/product_template_view.xml | 4 +- sf_manufacturing/models/model_type.py | 2 +- sf_manufacturing/models/mrp_workorder.py | 48 ++++++++++++------------ 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/sf_dlm/models/product_template.py b/sf_dlm/models/product_template.py index 14071dc6..b626eb69 100644 --- a/sf_dlm/models/product_template.py +++ b/sf_dlm/models/product_template.py @@ -9,7 +9,7 @@ class ResProductTemplate(models.Model): model_long = fields.Float('模型长[mm]', digits=(16, 3)) model_width = fields.Float('模型宽[mm]', digits=(16, 3)) model_height = fields.Float('模型高[mm]', digits=(16, 3)) - model_volume = fields.Float('模型体积[mm³]', digits=(16, 3)) + model_volume = fields.Float('模型体积[mm]', compute='_compute_model_volume', store=True) model_machining_precision = fields.Selection([ ('±0.10mm', '±0.10mm'), ('±0.05mm', '±0.05mm'), @@ -22,9 +22,9 @@ class ResProductTemplate(models.Model): model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数') model_price = fields.Float('模型单价', digits=(16, 3)) model_remark = fields.Char('模型备注说明') - long = fields.Float('长[mm]', digits=(16, 3), onchange='add_product_size') - width = fields.Float('宽[mm]', digits=(16, 3), onchange='add_product_size') - height = fields.Float('高[mm]', digits=(16, 3), onchange='add_product_size') + long = fields.Float('长[mm]', digits=(16, 3)) + width = fields.Float('宽[mm]', digits=(16, 3)) + height = fields.Float('高[mm]', digits=(16, 3)) materials_id = fields.Many2one('sf.production.materials', string='材料') materials_type_id = fields.Many2one('sf.materials.model', string='材料型号') volume = fields.Float(compute='_compute_volume', store=True) @@ -34,6 +34,10 @@ class ResProductTemplate(models.Model): def _compute_volume(self): self.volume = self.long * self.width * self.height + @api.depends('model_long', 'model_width', 'model_height') + def _compute_model_volume(self): + self.model_volume = self.model_long * self.model_width * self.model_height + # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品 def product_create(self, product_id, item, order_id, order_number, i): copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy() @@ -70,17 +74,20 @@ class ResProductTemplate(models.Model): if not self.model_type_id: return model_type = self.env['sf.model.type'].search( - [('id', '=', self.model_type_id.id)]) - print(self.model_long) - print(self.model_width) - print(self.model_height) - for item in self: - print(item.model_long) - print(item.model_width) - print(item.model_height) - item.model_long = item.model_long + model_type.embryo_tolerance - item.model_width = item.model_width + model_type.embryo_tolerance - item.model_height = item.model_width + model_type.embryo_tolerance + [('id', '=', self.model_type_id.id), ('embryo_tolerance', '=', True)]) + if model_type: + self.model_long = self.model_long + 1 + self.model_width = self.model_width + 1 + self.model_height = self.model_width + 1 + # for item in self: + # print(item.model_long) + # print(item.model_width) + # print(item.model_height) + # item.model_long = item.model_long + 1 + # item.model_width = item.model_width + 1 + # item.model_height = item.model_width + 1 + else: + return class ResMrpBom(models.Model): diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index 04507aaa..d8975017 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -35,8 +35,8 @@ - - + + Date: Fri, 25 Nov 2022 10:59:53 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d51a6f89..2f4286ce 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -4,6 +4,7 @@ import logging from datetime import datetime from dateutil.relativedelta import relativedelta from odoo import api, fields, models, SUPERUSER_ID, _ +from odoo.addons.sf_base.commons.common import Common class ResMrpWorkOrder(models.Model): From d6321bcb26d10d368eeeaf90e41250b7bc3f072f Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 28 Nov 2022 12:21:39 +0800 Subject: [PATCH 3/4] =?UTF-8?q?cnc=E5=AF=B9=E8=B1=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 4 +- sf_manufacturing/views/mrp_workorder_view.xml | 44 +++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2f4286ce..8de51b8a 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -310,7 +310,8 @@ class CNCprocessing(models.Model): depth_of_processing_z = fields.Char('加工深度(Z)') cutting_tool_extension_length = fields.Char('刀具伸出长度') cutting_tool_handle_type = fields.Char('刀柄型号') - estimated_processing_time = fields.Datetime('预计加工时间') + estimated_processing_time = fields.Char('预计加工时间') + remark = fields.Text('备注') workorder_id = fields.Many2one('mrp.workorder', string="工单") # mrs下发编程单创建CNC加工 @@ -330,5 +331,6 @@ class CNCprocessing(models.Model): 'depth_of_processing_z': obj['depth_of_processing_z'], 'cutting_tool_extension_length': obj['cutting_tool_extension_length'], 'cutting_tool_handle_type': obj['cutting_tool_handle_type'], + 'remark': obj['remark'] # 'FJGDate': obj[''] }) diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index b5d711d7..973f507b 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -41,16 +41,16 @@ - - mrp.production.workorder.form.inherit.sf - mrp.workorder - - - - - - - + + + + + + + + + + mrp.production.workorder.tray.form.inherit.sf @@ -213,18 +213,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From b2d1e9ce8c5d8965ed09c3fbd6de543708223487 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 30 Nov 2022 14:38:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E2=91=A0=E5=A2=9E=E5=8A=A0=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E7=BB=91=E5=AE=9A=E5=87=BD=E6=95=B0=EF=BC=9B=E2=91=A1?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=A4=84=E6=89=AB=E7=A0=81=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=89=98=E7=9B=98=E4=BB=A3=E7=A0=81=E7=A7=BB=E6=A4=8D=E5=88=B0?= =?UTF-8?q?mrp.workorder=E4=B8=8B=EF=BC=9B=E2=91=A2=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E6=A0=BC=E5=BC=8F=E4=B8=BAUsererror;?= =?UTF-8?q?=E2=91=A3=E3=80=81=E8=BF=94=E5=9B=9E=E5=81=8F=E5=B7=AE=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 +- sf_manufacturing/models/mrp_workorder.py | 42 +++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 57164e63..a39e6d92 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo import api, fields, models +from odoo import api, fields, models,_ diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 8de51b8a..7c11f6bd 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -5,6 +5,7 @@ from datetime import datetime from dateutil.relativedelta import relativedelta from odoo import api, fields, models, SUPERUSER_ID, _ from odoo.addons.sf_base.commons.common import Common +from odoo.exceptions import UserError class ResMrpWorkOrder(models.Model): @@ -94,6 +95,7 @@ class ResMrpWorkOrder(models.Model): print("(%.2f,%.2f)" % (x, y)) self.material_center_point = ("(%.2f,%.2f,%.2f)" % (x, y, z)) self.X_deviation_angle = jdz + return self.material_center_point def json_workorder_str(self, k, production, route): workorders_values_str = [0, '', { @@ -136,9 +138,9 @@ class ResMrpWorkOrder(models.Model): values = self.env['sf.tray'].search([("code", "=", self.tray_code)]) if values: if values.state == "占用": - raise ValidationError('该托盘已占用') + raise UserError('该托盘已占用') if values.state == "报损": - raise ValidationError('该托盘已损坏') + raise UserError('该托盘已损坏') else: values.update({ 'workorder_id': self, @@ -146,7 +148,26 @@ class ResMrpWorkOrder(models.Model): 'state': '占用', }) else: - raise ValidationError('该托盘编码已失效') + raise UserError('该托盘编码已失效') + else: + return "" + + def gettray_auto(self, barcode): + if barcode != False: + values = self.env['sf.tray'].search([("code", "=", barcode)]) + if values: + if values.state == "占用": + raise UserError('该托盘已占用') + if values.state == "报损": + raise UserError('该托盘已损坏') + else: + values.update({ + 'workorder_id': self, + 'production_id': self.production_id, + 'state': '占用', + }) + else: + raise UserError('该托盘编码已失效') else: return "" @@ -334,3 +355,18 @@ class CNCprocessing(models.Model): 'remark': obj['remark'] # 'FJGDate': obj[''] }) + +class SfWorkOrderBarcodes(models.Model): + """ + 智能工厂工单处扫码绑定托盘 + """ + _name = "mrp.workorder" + _inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"] + + def on_barcode_scanned(self, barcode): + + tray_code = self.env['sf.tray'].search([('code', '=', barcode)]) + self.tray_code = tray_code.code + + workorder = self.env['mrp.workorder'].browse(self.ids) + workorder.gettray_auto(barcode) \ No newline at end of file