From cf34ac5bbcfae30f66e81f668ad9d68b584867dd Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 17 Oct 2024 16:31:13 +0800 Subject: [PATCH 01/50] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 6 ++++-- sf_manufacturing/models/mrp_workorder.py | 3 +++ sf_manufacturing/models/stock.py | 4 ++++ sf_manufacturing/views/mrp_production_addional_change.xml | 3 ++- sf_manufacturing/views/mrp_workorder_view.xml | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index da54f77b..496c6a10 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -118,10 +118,12 @@ class MrpProduction(models.Model): ], string='工序状态', default='待装夹') # 零件图号 - part_number = fields.Char('零件图号') + part_number = fields.Char('零件图号', readonly=True) # 上传零件图纸 - part_drawing = fields.Binary('零件图纸') + part_drawing = fields.Binary('零件图纸', readonly=True) + + quality_standard = fields.Binary('质检标准', readonly=True) @api.depends('product_id.manual_quotation') def _compute_manual_quotation(self): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index e896ca40..0ad53892 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -225,6 +225,9 @@ class ResMrpWorkOrder(models.Model): material_height = fields.Float(string='高') # 零件图号 part_number = fields.Char(related='production_id.part_number', string='零件图号') + machining_drawings = fields.Binary('2D加工图纸', related='production_id.part_drawing', readonly=True) + quality_standard = fields.Binary('质检标准', related='production_id.quality_standard', readonly=True) + # 工序状态 process_state = fields.Selection([ ('待装夹', '待装夹'), diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index daf049eb..85290d18 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -272,6 +272,10 @@ class StockRule(models.Model): if quick_easy_order: production.write({'part_number': quick_easy_order.part_drawing_number, 'part_drawing': quick_easy_order.machining_drawings}) + else: + production.write({'part_number': production.product_id.part_number, + 'part_drawing': production.product_id.machining_drawings, + 'quality_standard': production.product_id.quality_standard}) if sale_order: # sale_order.write({'schedule_status': 'to schedule'}) self.env['sf.production.plan'].sudo().with_company(company_id).create({ diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 670dea7c..edfddf83 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -98,7 +98,8 @@ - + + diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index ef95a934..c108e35a 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -268,6 +268,8 @@ + + 计划加工时间 From cc40d479a9d3225db40b67d4e4552ac997208a24 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 17 Oct 2024 17:20:51 +0800 Subject: [PATCH 02/50] =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/common.py | 8 +++++ sf_base/views/base_view.xml | 2 ++ sf_mrs_connect/models/res_config_setting.py | 2 ++ sf_mrs_connect/models/sync_common.py | 35 +++++++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 95572631..6c0cfc28 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -187,3 +187,11 @@ class MrsMaterialApply(models.Model): name = fields.Char('名称', default=True) active = fields.Boolean('有效', default=True) + + +class MachiningAccuracy(models.Model): + _name = 'sf.machining.accuracy' + _description = '加工精度' + name = fields.Char('精度名称', index=True) + discount = fields.Float('折扣') + sync_id = fields.Char('同步ID') diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index 8127efb7..841e3467 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -614,4 +614,6 @@ sf.machine.control_system tree + + #------------------加工精度------------------ \ No newline at end of file diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index 6ec49f74..5243ccb2 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -84,6 +84,8 @@ class ResConfigSettings(models.TransientModel): _logger.info("同步刀具物料切削速度完成") self.env['sf.feed.per.tooth'].sync_all_feed_per_tooth() _logger.info("同步刀具物料每齿走刀量完成") + self.env['sf.machining.accuracy'].sync_machining_accuracy_all() + _logger.info("同步加工精度完成") except Exception as e: _logger.info("sf_all_sync error: %s" % e) diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index 615c69a0..75938068 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -74,6 +74,8 @@ class MrStaticResourceDataSync(models.Model): _logger.info("同步刀具物料切削速度完成") self.env['sf.feed.per.tooth'].sync_feed_per_tooth_yesterday() _logger.info("同步刀具物料每齿走刀量完成") + self.env['sf.machining.accuracy'].sync_machining_accuracy_all() + _logger.info("同步加工精度完成") except Exception as e: traceback_error = traceback.format_exc() logging.error("同步静态资源库失败:%s" % traceback_error) @@ -3133,3 +3135,36 @@ class CuttingToolBasicParameters(models.Model): }) else: raise ValidationError("刀具物料基本参数认证未通过") + + +class MachiningAccuracySync(models.Model): + _inherit = 'sf.machining.accuracy' + _description = '加工精度' + url = '/api/machining_accuracy/list' + + def sync_machining_accuracy_all(self): + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strUrl = config['sf_url'] + self.url + r = requests.post(strUrl, json={}, data=None, headers=headers) + r = r.json() + result = json.loads(r['result']) + _logger.info('加工精度:%s' % result) + if result['status'] == 1: + machining_accuracy_all_list = result['machining_accuracy_all_list'] + # 获取同步的id集合 + ids = [obj['id'] for obj in machining_accuracy_all_list] + self.env['sf.machining.accuracy'].sudo().search( + [('sync_id', 'not in', ids)]).unlink() + for time in machining_accuracy_all_list: + machining_accuracy = self.env['sf.machining.accuracy'].sudo().search( + [('sync_id', '=', time['id'])]) + if machining_accuracy: + machining_accuracy.name = time['name'] + machining_accuracy.discount = time['discount'] + else: + self.env['sf.machining.accuracy'].sudo().create({ + "sync_id": time['id'], + "name": time['name'], + "discount": time['discount'], + }) From 00a04af94f0a8ed2a4868d725e122daa84b25cd7 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 18 Oct 2024 09:30:20 +0800 Subject: [PATCH 03/50] =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=B2=BE=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/base.py | 8 ++++++++ sf_base/models/common.py | 8 -------- sf_base/security/ir.model.access.csv | 4 ++++ sf_base/views/base_view.xml | 17 +++++++++++++++++ sf_base/views/menu_view.xml | 8 +++++++- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/sf_base/models/base.py b/sf_base/models/base.py index c3152098..b257feb8 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -394,3 +394,11 @@ class MachineToolCategory(models.Model): active = fields.Boolean('有效', default=True) category = fields.Selection([('shukong', u'数控'), ('putong', u'普通')], string=u'机床类别', default='shukong') + + +class MachiningAccuracy(models.Model): + _name = 'sf.machining.accuracy' + _description = '加工精度' + name = fields.Char('精度名称', index=True) + discount = fields.Float('折扣') + sync_id = fields.Char('同步ID') \ No newline at end of file diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 6c0cfc28..95572631 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -187,11 +187,3 @@ class MrsMaterialApply(models.Model): name = fields.Char('名称', default=True) active = fields.Boolean('有效', default=True) - - -class MachiningAccuracy(models.Model): - _name = 'sf.machining.accuracy' - _description = '加工精度' - name = fields.Char('精度名称', index=True) - discount = fields.Float('折扣') - sync_id = fields.Char('同步ID') diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 3d4ba3a0..34605cca 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -247,3 +247,7 @@ access_sf_cutting_tool_type_group_sf_stock_manager,sf_cutting_tool_type_group_sf access_sf_cutting_tool_material_group_plan_dispatch,sf_cutting_tool_material_group_plan_dispatch,model_sf_cutting_tool_material,sf_base.group_plan_dispatch,1,0,0,0 access_sf_functional_cutting_tool_model_group_plan_dispatch,sf_functional_cutting_tool_model_group_plan_dispatch,model_sf_functional_cutting_tool_model,sf_base.group_plan_dispatch,1,0,0,0 access_sf_cutting_tool_type_group_plan_dispatch,sf_cutting_tool_type_group_plan_dispatch,model_sf_cutting_tool_type,sf_base.group_plan_dispatch,1,0,0,0 + + +access_sf_machining_accuracy,sf_machining_accuracy,model_sf_machining_accuracy,base.group_user,1,0,0,0 +access_sf_machining_accuracy_admin,sf_machining_accuracy_admin,model_sf_machining_accuracy,base.group_system,1,0,0,0 diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index 841e3467..bea75a4f 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -616,4 +616,21 @@ #------------------加工精度------------------ + + tree.sf.machining.accuracy + sf.machining.accuracy + + + + + + + + + + 加工精度 + ir.actions.act_window + sf.machining.accuracy + tree + \ No newline at end of file diff --git a/sf_base/views/menu_view.xml b/sf_base/views/menu_view.xml index 21bb519d..4c662976 100644 --- a/sf_base/views/menu_view.xml +++ b/sf_base/views/menu_view.xml @@ -141,12 +141,18 @@ sequence="1" action="action_sf_machine_brand"/> + From b132771c9215b2e038866ff7753f915f2a8b7aa9 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 18 Oct 2024 14:32:20 +0800 Subject: [PATCH 04/50] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm_management/views/product_template_management_view.xml | 4 ++-- sf_manufacturing/views/mrp_production_addional_change.xml | 4 ++-- sf_manufacturing/views/mrp_workorder_view.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 69c1a8b0..b1083332 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -16,8 +16,8 @@ - - + + - - + + diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index c108e35a..3af811e6 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -268,8 +268,8 @@ - - + + 计划加工时间 From 8cff3d8377579f3e0079b02c5037fd743e3dfa2a Mon Sep 17 00:00:00 2001 From: hujiaying Date: Fri, 18 Oct 2024 16:39:15 +0800 Subject: [PATCH 05/50] =?UTF-8?q?sf=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=96=B0=E5=A2=9E=E6=98=AF=E5=90=A6=E5=B8=A6?= =?UTF-8?q?=E6=96=99=EF=BC=8C=E5=B8=A6=E6=96=99=E5=B0=BA=E5=AF=B8=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9bfm=E5=88=86=E9=85=8D=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=EF=BC=8Csf=E6=8E=A5=E6=94=B6=E8=AE=A2=E5=8D=95=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85=E5=8F=8A=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E8=A1=A8=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/sale_order.py | 8 ++++++-- sf_sale/views/sale_order_view.xml | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index f28a76c4..d3ec1aa0 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -57,7 +57,6 @@ class ReSaleOrder(models.Model): delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效') - # 业务平台分配工厂后在智能工厂先创建销售订单 def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, deadline_of_delivery, payments_way, pay_way): @@ -128,7 +127,9 @@ class ReSaleOrder(models.Model): 'price_unit': product.list_price, 'product_uom_qty': item['number'], 'model_glb_file': base64.b64decode(item['model_file']), - 'remark': item.get('remark') + 'remark': item.get('remark'), + 'is_incoming_material': item.get('is_incoming_material'), + 'incoming_size': item.get('incoming_size'), } return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals) @@ -169,6 +170,9 @@ class ResaleOrderLine(models.Model): check_status = fields.Selection(related='order_id.check_status') remark = fields.Char('备注') + is_incoming_material = fields.Boolean('是否带料', default=False) + incoming_size = fields.Char('带料尺寸') + @api.depends('product_template_id') def _compute_model_glb_file(self): for line in self: diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 61b53b08..be8c469b 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -118,6 +118,8 @@ + + {'readonly': [('state', 'in', ['cancel','sale'])]} @@ -162,6 +164,11 @@ 拒绝接单 + + + + + @@ -265,7 +272,6 @@ - {"search_default_categ_id":1, "search_default_filter_to_sell":1,"sale_multi_pricelist_product_template": 1} From cae5149fba1c7cd5f81938daeefc125e22ddf0ff Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 21 Oct 2024 10:07:49 +0800 Subject: [PATCH 06/50] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 8 ++++---- sf_quality/__manifest__.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 6c6b1bf8..8e81d076 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -774,8 +774,8 @@ class ResProductMo(models.Model): # bfm下单 manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) part_number = fields.Char(string='零件图号', readonly=True) - # machining_drawings = fields.Binary('2D加工图纸', readonly=True) - # quality_standard = fields.Binary('质检标准', readonly=True) + machining_drawings = fields.Binary('2D加工图纸', readonly=True) + quality_standard = fields.Binary('质检标准', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): @@ -875,8 +875,8 @@ class ResProductMo(models.Model): 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', 'active': True, - # 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), - # 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), + 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), + 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), } tax_id = self.env['account.tax'].sudo().search( [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) diff --git a/sf_quality/__manifest__.py b/sf_quality/__manifest__.py index b1151b6d..2c18bad3 100644 --- a/sf_quality/__manifest__.py +++ b/sf_quality/__manifest__.py @@ -16,7 +16,7 @@ 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing'], 'data': [ 'security/ir.model.access.csv', - 'views/view.xml', + # 'views/view.xml', 'views/quality_cnc_test_view.xml' ], From 1a3a178ec6c0a165da8ba7232dd03f20a6f16697 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 21 Oct 2024 10:08:35 +0800 Subject: [PATCH 07/50] =?UTF-8?q?Revert=20"=E8=BE=85=E5=8A=A9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit cae5149fba1c7cd5f81938daeefc125e22ddf0ff. --- sf_manufacturing/models/product_template.py | 8 ++++---- sf_quality/__manifest__.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 8e81d076..6c6b1bf8 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -774,8 +774,8 @@ class ResProductMo(models.Model): # bfm下单 manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) part_number = fields.Char(string='零件图号', readonly=True) - machining_drawings = fields.Binary('2D加工图纸', readonly=True) - quality_standard = fields.Binary('质检标准', readonly=True) + # machining_drawings = fields.Binary('2D加工图纸', readonly=True) + # quality_standard = fields.Binary('质检标准', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): @@ -875,8 +875,8 @@ class ResProductMo(models.Model): 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', 'active': True, - 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), - 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), + # 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), + # 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), } tax_id = self.env['account.tax'].sudo().search( [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) diff --git a/sf_quality/__manifest__.py b/sf_quality/__manifest__.py index 2c18bad3..b1151b6d 100644 --- a/sf_quality/__manifest__.py +++ b/sf_quality/__manifest__.py @@ -16,7 +16,7 @@ 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing'], 'data': [ 'security/ir.model.access.csv', - # 'views/view.xml', + 'views/view.xml', 'views/quality_cnc_test_view.xml' ], From 124bc8478e975cac5d9e351e782396331d59e326 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 21 Oct 2024 10:09:19 +0800 Subject: [PATCH 08/50] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 6c6b1bf8..8e81d076 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -774,8 +774,8 @@ class ResProductMo(models.Model): # bfm下单 manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) part_number = fields.Char(string='零件图号', readonly=True) - # machining_drawings = fields.Binary('2D加工图纸', readonly=True) - # quality_standard = fields.Binary('质检标准', readonly=True) + machining_drawings = fields.Binary('2D加工图纸', readonly=True) + quality_standard = fields.Binary('质检标准', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): @@ -875,8 +875,8 @@ class ResProductMo(models.Model): 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', 'active': True, - # 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), - # 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), + 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(item['machining_drawings']), + 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), } tax_id = self.env['account.tax'].sudo().search( [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) From 2af21bc4eed5e07c121b0911c9b2148f0240d9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 11:37:01 +0800 Subject: [PATCH 09/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/main.py | 2 +- .../test_jikimo_workorder_exception_notify.py | 55 ++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/jikimo_workorder_exception/controllers/main.py b/jikimo_workorder_exception/controllers/main.py index 6a17f958..0bd3d762 100644 --- a/jikimo_workorder_exception/controllers/main.py +++ b/jikimo_workorder_exception/controllers/main.py @@ -21,7 +21,7 @@ class WorkorderExceptionConroller(http.Controller): try: res = {'Succeed': True, 'ErrorCode': 0, 'Error': ''} datas = request.httprequest.data - ret = json.loads(datas)['Datas'] + ret = json.loads(datas) if not ret.get('RfidCode') or not ret.get('ErrorType'): res = {'Succeed': False, 'ErrorCode': 400, 'Error': '参数错误'} return json.JSONEncoder().encode(res) diff --git a/jikimo_workorder_exception_notify/tests/test_jikimo_workorder_exception_notify.py b/jikimo_workorder_exception_notify/tests/test_jikimo_workorder_exception_notify.py index 85d304be..92886ff3 100644 --- a/jikimo_workorder_exception_notify/tests/test_jikimo_workorder_exception_notify.py +++ b/jikimo_workorder_exception_notify/tests/test_jikimo_workorder_exception_notify.py @@ -14,12 +14,25 @@ class TestJikimoWorkorderExceptionNotify(TestJikimoWorkorderExceptionNotifyCommo ('model', '=', 'jikimo.workorder.exception') ])) self.assertTrue(self.env['jikimo.message.template'].search([ - ('name', '=', '加工失败'), + ('name', '=', '工单加工失败提醒'), ('model', '=', 'jikimo.workorder.exception') ])) + def test_create_message_queue_yc0001(self): + exception_record = self.env['jikimo.workorder.exception'].create({ + 'workorder_id': self.workorder.id, + 'exception_code': 'YC0001', + 'exception_content': '无CNC程序' + }) - def test_create_message_queue(self): + message_record = self.env['jikimo.message.queue'].search([ + ('res_id', '=', exception_record.id), + ('model', '=', 'jikimo.workorder.exception'), + ('message_status', '=', 'pending') + ]) + self.assertFalse(message_record) + + def test_create_message_queue_yc0002(self): exception_record = self.env['jikimo.workorder.exception'].create({ 'workorder_id': self.workorder.id, 'exception_code': 'YC0002', @@ -43,7 +56,45 @@ class TestJikimoWorkorderExceptionNotify(TestJikimoWorkorderExceptionNotifyCommo ('message_template_id', '=', message_template.id) ]) self.assertTrue(message_record) + + def test_create_message_queue_yc0003(self): + exception_record = self.env['jikimo.workorder.exception'].create({ + 'workorder_id': self.workorder.id, + 'exception_code': 'YC0003', + 'exception_content': '无定位数据' + }) + + bussiness_node = self.env['jikimo.message.bussiness.node'].search([ + ('name', '=', '无定位数据'), + ('model', '=', 'jikimo.workorder.exception') + ]) + + message_template = self.env['jikimo.message.template'].search([ + ('bussiness_node_id', '=', bussiness_node.id), + ('model', '=', 'jikimo.workorder.exception') + ]) + + message_record = self.env['jikimo.message.queue'].search([ + ('res_id', '=', exception_record.id), + ('model', '=', 'jikimo.workorder.exception'), + ('message_status', '=', 'pending'), + ('message_template_id', '=', message_template.id) + ]) + self.assertTrue(message_record) + def test_create_message_queue_yc0004(self): + exception_record = self.env['jikimo.workorder.exception'].create({ + 'workorder_id': self.workorder.id, + 'exception_code': 'YC0004', + 'exception_content': '无CNC程序' + }) + + message_record = self.env['jikimo.message.queue'].search([ + ('res_id', '=', exception_record.id), + ('model', '=', 'jikimo.workorder.exception'), + ('message_status', '=', 'pending') + ]) + self.assertFalse(message_record) def test_get_message(self): exception_record = self.env['jikimo.workorder.exception'].create({ From 81cfbfb540a7809d66331c843036ac9ad139b430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 11:46:14 +0800 Subject: [PATCH 10/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_workorder_exception/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jikimo_workorder_exception/controllers/main.py b/jikimo_workorder_exception/controllers/main.py index 0bd3d762..03744ff9 100644 --- a/jikimo_workorder_exception/controllers/main.py +++ b/jikimo_workorder_exception/controllers/main.py @@ -22,7 +22,7 @@ class WorkorderExceptionConroller(http.Controller): res = {'Succeed': True, 'ErrorCode': 0, 'Error': ''} datas = request.httprequest.data ret = json.loads(datas) - if not ret.get('RfidCode') or not ret.get('ErrorType'): + if not ret.get('RfidCode') or not ret.get('coding'): res = {'Succeed': False, 'ErrorCode': 400, 'Error': '参数错误'} return json.JSONEncoder().encode(res) @@ -38,7 +38,7 @@ class WorkorderExceptionConroller(http.Controller): # 创建工单异常记录,关联工单 request.env['jikimo.workorder.exception'].sudo().create({ 'workorder_id': workorder.id, - 'exception_code': ret.get('ErrorType'), + 'exception_code': ret.get('coding'), 'exception_content': ret.get('Error', '') }) From 22c9de86f6fa828f2eb1ed4b14fbb16f306f5324 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 21 Oct 2024 13:56:34 +0800 Subject: [PATCH 11/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 14 +++++++++++++- .../views/mrp_production_addional_change.xml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 0b68852b..4eac6f54 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -18,7 +18,7 @@ class MrpProduction(models.Model): _inherit = 'mrp.production' _description = "制造订单" _order = 'create_date desc' - + deadline_of_delivery = fields.Date('订单交期', tracking=True, compute='_compute_deadline_of_delivery') # tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘") maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests") request_ids = fields.One2many('maintenance.request', 'production_id') @@ -34,6 +34,18 @@ class MrpProduction(models.Model): tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True) tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True) + @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') + def _compute_deadline_of_delivery(self): + for production in self: + production.sale_order_count = len( + production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id) + sale_order_ids = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id.ids + if len(sale_order_ids) < 1: + continue + sale_id = self.env['sale.order'].browse(sale_order_ids[0]) + if sale_id: + production.deadline_of_delivery = sale_id.deadline_of_delivery + @api.depends('workorder_ids.tool_state_remark') def _compute_tool_state_remark(self): for item in self: diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index c6ae49ad..86a9ce9e 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -101,6 +101,7 @@ + From c01e9a4d3901b6f9874cee3868e67df0c7bbde36 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 21 Oct 2024 14:18:53 +0800 Subject: [PATCH 12/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 6b75ef53..361d6b98 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -42,7 +42,7 @@ class MrpProduction(models.Model): sale_order_ids = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id.ids if len(sale_order_ids) < 1: continue - sale_id = self.env['sale.order'].browse(sale_order_ids[0]) + sale_id = self.env['sale.order'].sudo().browse(sale_order_ids[0]) if sale_id: production.deadline_of_delivery = sale_id.deadline_of_delivery From 86c1880cdbc16fccaea4fe5894a027a23fb9f525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 14:41:09 +0800 Subject: [PATCH 13/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_workorder_exception_notify/data/template_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jikimo_workorder_exception_notify/data/template_data.xml b/jikimo_workorder_exception_notify/data/template_data.xml index 554ef2c2..612b4f78 100644 --- a/jikimo_workorder_exception_notify/data/template_data.xml +++ b/jikimo_workorder_exception_notify/data/template_data.xml @@ -19,7 +19,7 @@ markdown urgent - ### 生产线无功能刀具提醒 + ### 工单无定位数据提醒 单号:工单[{{workorder_id.production_id.name}}]({{url}}) 原因:无装夹定位测量数据 From b00038aaedc86ee3a4b840b0703af7a12ce1f678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 14:59:16 +0800 Subject: [PATCH 14/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9YC0004=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/jikimo_workorder_exception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py b/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py index bbe69ab5..9849f2cd 100644 --- a/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py +++ b/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py @@ -34,7 +34,7 @@ class JikimoWorkorderException(models.Model): rec.add_queue('无定位数据') elif rec.exception_code == 'YC0004': # 无FTP文件,调用cloud接口 - data = {'name': rec.workorder_id.programming_no, 'exception_code': 'YC0004'} + data = {'name': rec.workorder_id.production_id.programming_no, 'exception_code': 'YC0004'} configsettings = self.env['res.config.settings'].sudo().get_values() config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) url = '/api/message/workorder_exception' From e9dbbaedf4f28981a39321352468d37d34a8101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 15:40:38 +0800 Subject: [PATCH 15/50] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=95=85=E9=9A=9C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/models/sf_message_maintenance_logs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_message/models/sf_message_maintenance_logs.py b/sf_message/models/sf_message_maintenance_logs.py index 288043ff..b830d806 100644 --- a/sf_message/models/sf_message_maintenance_logs.py +++ b/sf_message/models/sf_message_maintenance_logs.py @@ -4,11 +4,11 @@ class SFMessageMaintenanceLogs(models.Model): _name = 'sf.maintenance.logs' _inherit = ['sf.maintenance.logs', 'jikimo.message.dispatch'] - @api._model_create_multi + @api.model_create_multi def create(self, vals_list): res = super(SFMessageMaintenanceLogs, self).create(vals_list) for rec in res: - rec.add_queue() + rec.add_queue('设备故障') return res def _get_message(self, message_queue_ids): From 41b287d5590504f2487540bc828ddeb91a786f05 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 21 Oct 2024 16:06:03 +0800 Subject: [PATCH 16/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 361d6b98..3269164c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -37,8 +37,6 @@ class MrpProduction(models.Model): @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') def _compute_deadline_of_delivery(self): for production in self: - production.sale_order_count = len( - production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id) sale_order_ids = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id.ids if len(sale_order_ids) < 1: continue From 736a18518c7764aeb9fda84d1351aeb4e473bf78 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 21 Oct 2024 16:07:43 +0800 Subject: [PATCH 17/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 3269164c..6584b04f 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -38,7 +38,7 @@ class MrpProduction(models.Model): def _compute_deadline_of_delivery(self): for production in self: sale_order_ids = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id.ids - if len(sale_order_ids) < 1: + if not sale_order_ids or len(sale_order_ids) < 1: continue sale_id = self.env['sale.order'].sudo().browse(sale_order_ids[0]) if sale_id: From 6c1c2ca0fc615cd8de9f4e54a127f7bcecee3fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 21 Oct 2024 17:02:59 +0800 Subject: [PATCH 18/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=8E=9F=E5=9B=A0=E8=AF=9D=E6=9C=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_workorder_exception_notify/data/template_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jikimo_workorder_exception_notify/data/template_data.xml b/jikimo_workorder_exception_notify/data/template_data.xml index 612b4f78..dec81e71 100644 --- a/jikimo_workorder_exception_notify/data/template_data.xml +++ b/jikimo_workorder_exception_notify/data/template_data.xml @@ -10,7 +10,7 @@ urgent ### 生产线无功能刀具提醒 单号:工单[{{workorder_id.production_id.name}}]({{url}}) -原因:生产线无加工程序用的{{function_tool_name}}名称功能刀具 +原因:生产线无加工程序要用的功能刀具 工单无定位数据提醒 From f897955f688037e0a6ba770722c368eb63b913ad Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 22 Oct 2024 11:45:08 +0800 Subject: [PATCH 19/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 6584b04f..b956e902 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -37,10 +37,10 @@ class MrpProduction(models.Model): @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') def _compute_deadline_of_delivery(self): for production in self: - sale_order_ids = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id.ids - if not sale_order_ids or len(sale_order_ids) < 1: + sale_order_id = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id + if not sale_order_id: continue - sale_id = self.env['sale.order'].sudo().browse(sale_order_ids[0]) + sale_id = self.env['sale.order'].sudo().browse(sale_order_id) if sale_id: production.deadline_of_delivery = sale_id.deadline_of_delivery From da38d241114a4514401dff858401609c04a9082b Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 22 Oct 2024 13:33:53 +0800 Subject: [PATCH 20/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index b956e902..55076fc6 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -40,7 +40,7 @@ class MrpProduction(models.Model): sale_order_id = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id if not sale_order_id: continue - sale_id = self.env['sale.order'].sudo().browse(sale_order_id) + sale_id = self.env['sale.order'].sudo().browse(int(sale_order_id)) if sale_id: production.deadline_of_delivery = sale_id.deadline_of_delivery From f2482b5128b2274bc36c4fa28eec741b1949e48a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 22 Oct 2024 13:45:08 +0800 Subject: [PATCH 21/50] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E4=BA=A7=E7=94=9F=E5=BA=93=E5=AD=98=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=EF=BC=8C=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=B2=A1=E6=9C=89=E5=AE=9E=E6=97=B6=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E5=8F=98=E6=9B=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_tool.py | 4 +++- sf_tool_management/models/stock.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index e8523cd3..78a652f4 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -51,6 +51,8 @@ class FunctionalCuttingToolEntity(models.Model): string='位置', compute='_compute_current_location_id', store=True) image = fields.Binary('图片', readonly=True) + stock_num = fields.Integer('库存变更次数', default=0) + safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools', string='功能刀具安全库存', readonly=True) @@ -71,7 +73,7 @@ class FunctionalCuttingToolEntity(models.Model): }) @api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status', - 'current_shelf_location_id') + 'current_shelf_location_id', 'stock_num') def _compute_current_location_id(self): for record in self: if record.functional_tool_status == '已拆除': diff --git a/sf_tool_management/models/stock.py b/sf_tool_management/models/stock.py index 9f0d9f82..92198239 100644 --- a/sf_tool_management/models/stock.py +++ b/sf_tool_management/models/stock.py @@ -53,6 +53,13 @@ class StockMoveLine(models.Model): [('barcode_id', '=', line_id.lot_id.id), ('functional_tool_status', '=', '正常')]).cnc_function_tool_use_verify() + for move_line in move_lines: + if move_line.lot_id: + tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search( + [('barcode_id', '=', move_line.lot_id.id), + ('functional_tool_status', '=', '正常')]) + tool_id.stock_num += tool_id.stock_num + class StockPicking(models.Model): _inherit = 'stock.picking' From 0d512e2e43ea966542917cf49e1f04f39353b01d Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 22 Oct 2024 13:55:24 +0800 Subject: [PATCH 22/50] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E4=BA=A4=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 55076fc6..573bb73f 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -37,12 +37,25 @@ class MrpProduction(models.Model): @api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id') def _compute_deadline_of_delivery(self): for production in self: - sale_order_id = production.procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id - if not sale_order_id: - continue - sale_id = self.env['sale.order'].sudo().browse(int(sale_order_id)) - if sale_id: - production.deadline_of_delivery = sale_id.deadline_of_delivery + # 确保 procurement_group_id 和相关字段存在 + if production.procurement_group_id: + # 获取相关的 sale_id + sale_order_id = production.procurement_group_id.mrp_production_ids.mapped( + 'move_dest_ids.group_id.sale_id') + + # 确保 sale_order_id 是有效的 ID 列表 + if sale_order_id: + # 获取 sale.order 记录 + sale_id = self.env['sale.order'].sudo().browse(sale_order_id.ids) # 使用 mapped 返回的 ID 列表 + + # 处理 sale_id + if sale_id: + # 假设我们只需要第一个 sale_id + production.deadline_of_delivery = sale_id[0].deadline_of_delivery if sale_id else False + else: + production.deadline_of_delivery = False + else: + production.deadline_of_delivery = False @api.depends('workorder_ids.tool_state_remark') def _compute_tool_state_remark(self): From 7157ea15870d5dc50f6b0ce95bf1557948826d4d Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 22 Oct 2024 15:35:34 +0800 Subject: [PATCH 23/50] =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/base.py | 4 ++-- sf_base/views/base_view.xml | 4 ++-- sf_mrs_connect/models/sync_common.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sf_base/models/base.py b/sf_base/models/base.py index b257feb8..6c01fc48 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -400,5 +400,5 @@ class MachiningAccuracy(models.Model): _name = 'sf.machining.accuracy' _description = '加工精度' name = fields.Char('精度名称', index=True) - discount = fields.Float('折扣') - sync_id = fields.Char('同步ID') \ No newline at end of file + standard_tolerance = fields.Char(string="标准公差") + sync_id = fields.Char('同步ID') diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index bea75a4f..eb2c1571 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -620,9 +620,9 @@ tree.sf.machining.accuracy sf.machining.accuracy - + - + diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index 75938068..ae1930c6 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -3161,7 +3161,7 @@ class MachiningAccuracySync(models.Model): [('sync_id', '=', time['id'])]) if machining_accuracy: machining_accuracy.name = time['name'] - machining_accuracy.discount = time['discount'] + machining_accuracy.standard_tolerance = time['standard_tolerance'] else: self.env['sf.machining.accuracy'].sudo().create({ "sync_id": time['id'], From 8661dd16c1b2084c8a85fff0b6f74ab6c31a02bc Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 22 Oct 2024 15:37:41 +0800 Subject: [PATCH 24/50] =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_base/models/base.py b/sf_base/models/base.py index 6c01fc48..3d83cc96 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -399,6 +399,6 @@ class MachineToolCategory(models.Model): class MachiningAccuracy(models.Model): _name = 'sf.machining.accuracy' _description = '加工精度' - name = fields.Char('精度名称', index=True) + name = fields.Char('一般公差', index=True) standard_tolerance = fields.Char(string="标准公差") sync_id = fields.Char('同步ID') From 98923c1797fbcc47eaa0f78caed76ef419ffa223 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 22 Oct 2024 17:52:20 +0800 Subject: [PATCH 25/50] =?UTF-8?q?1=E3=80=81=E8=AE=BE=E5=A4=87=E7=BB=B4?= =?UTF-8?q?=E4=BF=9D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/sf_maintenance.py | 61 +++++++++- .../models/sf_maintenance_requests.py | 2 + sf_maintenance/security/ir.model.access.csv | 2 +- sf_maintenance/views/maintenance_views.xml | 115 +++++++++++------- 4 files changed, 130 insertions(+), 50 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index d5bfa6b4..95e38d02 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- import json import base64 +import logging from datetime import timedelta import requests from odoo.addons.sf_base.commons.common import Common from odoo import api, fields, models, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError class SfMaintenanceEquipmentCategory(models.Model): @@ -122,6 +123,10 @@ class SfMaintenanceEquipment(models.Model): 'sf_maintenance_equipment_ids', string='设备维保标准') eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准', domain="[('maintenance_type','=','保养')]") + + initial_action_date = fields.Date(string='初始保养日期') + next_action_date = fields.Date(string='下次预防保养') + initial_overhaul_date = fields.Date(string='初始维修日期') overhaul_date = fields.Date(string='下次预防检修') overhaul_period = fields.Integer(string='预防检修频次') overhaul_duration = fields.Float(string='检修时长') @@ -129,6 +134,52 @@ class SfMaintenanceEquipment(models.Model): overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', domain="[('maintenance_type','=','检修')]") + def confirm_maintenance(self): + """ + 确认保养/检修 + """ + context = self.env.context + initial_date = None + next_date = None + if context['type'] == '保养': + if not self.initial_action_date: + raise ValidationError('初始保养日期不能为空!!') + elif self.initial_action_date < fields.Date.today(): + raise ValidationError('初始保养日期不能小于当前日期!!') + else: + initial_date = self.initial_action_date + next_date = self.next_action_date + elif context['type'] == '检修': + if not self.initial_overhaul_date: + raise ValidationError('初始检修日期不能为空!!') + elif self.initial_overhaul_date < fields.Date.today(): + raise ValidationError('初始检修日期不能小于当前日期!!') + else: + initial_date = self.initial_overhaul_date + next_date = self.overhaul_date + + request_id = self.env['maintenance.request'].search([('stage_id.done', '=', False), + ('equipment_id', '=', self.id), + ('maintenance_type', '=', 'preventive'), + ('request_date', '=', next_date), + ('sf_maintenance_type', '=', context['type'])]) + if not request_id: + if context['type'] == '保养': + self._create_new_request(initial_date) + elif context['type'] == '检修': + self._create_new_request1(initial_date) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': f'创建{context["type"]}计划', + 'message': f'{context["type"]}维保计划创建成功', + 'type': 'success' + } + } + else: + pass + @api.onchange('eq_maintenance_id', 'overhaul_id') def _compute_equipment_maintenance_standards_ids(self): for record in self: @@ -624,7 +675,7 @@ class SfMaintenanceEquipment(models.Model): if next_date < date_now: next_date = date_now else: - next_date = equipment.effective_date + timedelta(days=equipment.period) + next_date = equipment.initial_action_date + timedelta(days=equipment.period) equipment.next_action_date = next_date else: self.next_action_date = False @@ -668,7 +719,7 @@ class SfMaintenanceEquipment(models.Model): if next_date < date_now: next_date = date_now else: - next_date = equipment.effective_date + timedelta(days=equipment.overhaul_period) + next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period) equipment.overhaul_date = next_date else: self.overhaul_date = False @@ -678,7 +729,7 @@ class SfMaintenanceEquipment(models.Model): self.ensure_one() return { 'name': _('Preventive Maintenance - %s', self.name), - 'request_date': date, + 'request_date': fields.Date.today(), 'schedule_date': date, 'category_id': self.category_id.id, 'equipment_id': self.id, @@ -698,7 +749,7 @@ class SfMaintenanceEquipment(models.Model): self.ensure_one() return { 'name': _('Preventive Maintenance - %s', self.name), - 'request_date': date, + 'request_date': fields.Date.today(), 'schedule_date': date, 'category_id': self.category_id.id, 'equipment_id': self.id, diff --git a/sf_maintenance/models/sf_maintenance_requests.py b/sf_maintenance/models/sf_maintenance_requests.py index 8686926b..397c8c90 100644 --- a/sf_maintenance/models/sf_maintenance_requests.py +++ b/sf_maintenance/models/sf_maintenance_requests.py @@ -14,6 +14,8 @@ class SfMaintenanceEquipmentCategory(models.Model): equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准', domain="[('maintenance_type','=',sf_maintenance_type)]") + active = fields.Boolean('有效', default=True) + @api.onchange('sf_maintenance_type') def _compute_equipment_maintenance_request_id(self): for record in self: diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index abbd4878..0317cf7a 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -20,7 +20,7 @@ access_maintenance_equipment_agv_log,maintenance_equipment_agv_log,model_mainten -access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,0,0,0 +access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,1,1,0 access_maintenance_equipment_group_plan_dispatch,maintenance.equipment,maintenance.model_maintenance_equipment,sf_base.group_plan_dispatch,1,0,0,0 access_maintenance_equipment_oee_group_plan_dispatch,maintenance_equipment_oee,model_maintenance_equipment_oee,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 8c6cb40d..4fe044d3 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -60,9 +60,9 @@ - + + domain="[('brand_id', '=', brand_id)]"/> @@ -73,7 +73,7 @@ + options="{'no_create': True}"/>