From 3f84972bfd73c5858b9996ed1067747ee35a4a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 24 Oct 2024 13:57:26 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/wizard/action_plan_some.py | 48 ------------------------------ 1 file changed, 48 deletions(-) diff --git a/sf_plan/wizard/action_plan_some.py b/sf_plan/wizard/action_plan_some.py index 1c08ff0f..86b3f1ac 100644 --- a/sf_plan/wizard/action_plan_some.py +++ b/sf_plan/wizard/action_plan_some.py @@ -37,52 +37,4 @@ class Action_Plan_All_Wizard(models.TransientModel): # 判断能否排成 self.plan_ids.deal_processing_schedule(self.date_planned_start) self.plan_ids.do_production_schedule() - # for plan in temp_plan_ids: - # # 处理每个计划 - # # 比如更新计划状态、分配资源等 - # # 示例:plan.state = 'scheduled' - # print('处理计划:', plan.id) - # # 拿到计划对象 - # plan_obj = self.env['sf.production.plan'].browse(plan.id) - # plan_obj.production_line_id = self.production_line_id.id - # plan.date_planned_start = self.date_planned_start - # plan_obj.do_production_schedule() - # plan_obj.state = 'done' _logger.info('处理计划: %s 完成', self.plan_ids.ids) - - # # 获取当前生产线 - # production_line_id = self.production_line_id - # # 获取当前生产线的所有生产订单 - # production_order_ids = self.env['mrp.production'].search([('production_line_id', '=', production_line_id.id)]) - # # 获取当前生产线的所有生产订单的id - # production_order_id_list = [] - # for production_order_id in production_order_ids: - # production_order_id_list.append(production_order_id.id) - # # 获取当前生产线的所有生产订单的排程状态 - # production_order_plan_state_list = [] - # for production_order_id in production_order_ids: - # production_order_plan_state_list.append(production_order_id.plan_state) - # # 如果当前生产线的所有生产订单的排程状态都是已排程,则报错 - # if all(production_order_plan_state == '已排程' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已排程,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是未排程,则报错 - # if all(production_order_plan_state == '未排程' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都未排程,请先排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错 - # if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错 - # if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错 - # if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错 - # if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错 - # if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!') - # # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错 - # if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list): - # raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!') From 69c63f708d62e4401b17be68b3f72702cf568cd3 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 24 Oct 2024 17:06:31 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=92=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=91=98=E5=B7=A5=E6=97=B6=E6=A0=B9=E6=8D=AE=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E8=8E=B7=E5=8F=96=E4=BC=81=E5=BE=AEid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_hr/models/hr_employee.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sf_hr/models/hr_employee.py b/sf_hr/models/hr_employee.py index e9826f29..065288de 100644 --- a/sf_hr/models/hr_employee.py +++ b/sf_hr/models/hr_employee.py @@ -11,6 +11,38 @@ class JkmPracticeEmployee(models.Model): we_id = fields.Char(string='企微ID', index=True) + @api.model_create_multi + def create(self, vals_list): + for val in vals_list: + if 'work_email' in val: + val["we_id"] = self._get_we_id(val.get('work_email')) + if val.get('user_id'): + user = self.env['res.users'].browse(val['user_id']) + user.write({'we_employee_id': val["we_id"]}) + return super(JkmPracticeEmployee, self).create(vals_list) + + def write(self, vals): + if 'work_email' in vals: + vals["we_id"] = self._get_we_id(vals.get('work_email')) + if self.user_id: + self.user_id.write({'we_employee_id': vals["we_id"]}) + return super(JkmPracticeEmployee, self).write(vals) + + def _get_we_id(self, work_email): + json1 = { + 'params': { + 'work_email': work_email + } + } + url = '/api/get/we_id/info' + config = self.env['res.config.settings'].get_values() + ret = requests.post((config['ims_url'] + url), json=json1, data={}) + result = ret.json()['result'] + if result['code'] == 200: + if result['we_id']: + return result['we_id'] + return None + def _employee_info_sync(self): url = '/api/get/organization' config = self.env['res.config.settings'].get_values() From 5363557faf02dd11402eadc05bc405bc14baede6 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 25 Oct 2024 16:36:54 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/quick_easy_order_old.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 1c62b782..d3f9b5ab 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -220,7 +220,11 @@ class QuickEasyOrder(models.Model): 'total_amount': item.price, 'remark': '', 'manual_quotation': True, - 'barcode': barcode + 'barcode': barcode, + 'machining_drawings_name': '', + 'quality_standard_name': '', + 'machining_drawings': '', + 'quality_standard': '', }) # res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list']) product_id = self.env.ref('sf_dlm.product_template_sf').sudo() From 8dc23a638f3d81bbd2988394b193990a726d7acf Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 25 Oct 2024 17:21:45 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/models/sf_message_sale.py | 2 +- sf_message/models/sf_message_workorder.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index f9932013..91be525e 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -180,7 +180,7 @@ class SFMessageSale(models.Model): ('message_template_id', '=', message_template_warning.id) ]) if sale_order_warning: - logging.info('取消发送:%s' % sale_order_warning.name) + logging.info('取消发送:%s' % sale_order_warning) sale_order_warning.write({'message_status': 'cancel'}) def _recover_sale_time_warning_func(self): diff --git a/sf_message/models/sf_message_workorder.py b/sf_message/models/sf_message_workorder.py index 135aa1cd..6d1cff77 100644 --- a/sf_message/models/sf_message_workorder.py +++ b/sf_message/models/sf_message_workorder.py @@ -190,7 +190,7 @@ class SFMessageWork(models.Model): ('message_template_id', '=', message_template_warning.id) ]) if work_order_warning: - logging.info('取消发送:%s' % work_order_warning.name) + logging.info('取消发送:%s' % work_order_warning) work_order_warning.write({'message_status': 'cancel'}) def _recover_time_warning_func(self): From aa1353cf991a71859b14dceafe9ca54b3dd5fa30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 09:38:50 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 492ef525..ec5c8421 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -246,26 +246,26 @@ class sf_production_plan(models.Model): record.date_planned_finished = item.date_planned_finished # 计算下一个cnc工单的开始时间 last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) - record.state = 'done' - # record.production_id.schedule_state = '已排' - record.sudo().production_id.schedule_state = '已排' - record.sudo().production_id.process_state = '待装夹' - # self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process' - # sale_obj = self.env['sale.order'].search([('name', '=', record.origin)]) - # if 'S' in sale_obj.name: - # sale_obj.schedule_status = 'to process' - mrp_production_ids = record.production_id._get_children().ids - print('mrp_production_ids', mrp_production_ids) - for i in mrp_production_ids: - record.env['mrp.production'].sudo().browse(i).schedule_state = '已排' - # record.production_id.date_planned_start = record.date_planned_start - # record.production_id.date_planned_finished = record.date_planned_finished - record.sudo().production_id.production_line_id = record.production_line_id.id - if record.production_id.workorder_ids: - record.sudo().production_id.workorder_ids.filtered( - lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write( - {'production_line_id': record.production_line_id.id, - 'plan_start_processing_time': record.date_planned_start}) + record.state = 'done' + # record.production_id.schedule_state = '已排' + record.sudo().production_id.schedule_state = '已排' + record.sudo().production_id.process_state = '待装夹' + # self.env['sale.order'].browse(record.production_id.origin).schedule_status = 'to process' + # sale_obj = self.env['sale.order'].search([('name', '=', record.origin)]) + # if 'S' in sale_obj.name: + # sale_obj.schedule_status = 'to process' + mrp_production_ids = record.production_id._get_children().ids + print('mrp_production_ids', mrp_production_ids) + for i in mrp_production_ids: + record.env['mrp.production'].sudo().browse(i).schedule_state = '已排' + # record.production_id.date_planned_start = record.date_planned_start + # record.production_id.date_planned_finished = record.date_planned_finished + record.sudo().production_id.production_line_id = record.production_line_id.id + if record.production_id.workorder_ids: + record.sudo().production_id.workorder_ids.filtered( + lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write( + {'production_line_id': record.production_line_id.id, + 'plan_start_processing_time': record.date_planned_start}) # record.date_planned_finished = record.date_planned_start + timedelta(days=3) # record.state = 'done' From 1467dbf88cdb7fc9331f96412caf31697af3e927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 09:44:52 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index ec5c8421..bdf916ce 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -246,6 +246,7 @@ class sf_production_plan(models.Model): record.date_planned_finished = item.date_planned_finished # 计算下一个cnc工单的开始时间 last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) + # 没有工单也能排程 record.state = 'done' # record.production_id.schedule_state = '已排' record.sudo().production_id.schedule_state = '已排' From 18a7dbbff9d091618e44ab61484985e6bf7ef72e Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 28 Oct 2024 10:21:33 +0800 Subject: [PATCH 07/19] =?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/__manifest__.py | 2 +- sf_manufacturing/__manifest__.py | 2 +- sf_manufacturing/models/mrp_production.py | 6 +++--- sf_manufacturing/models/product_template.py | 16 ++++++++-------- sf_manufacturing/models/stock.py | 15 --------------- sf_quality/__manifest__.py | 2 +- sf_sale/models/quick_easy_order_old.py | 5 ++--- sf_sale/views/quick_easy_order_view.xml | 4 ++-- 8 files changed, 18 insertions(+), 34 deletions(-) diff --git a/sf_dlm_management/__manifest__.py b/sf_dlm_management/__manifest__.py index a5c894d4..9a94082a 100644 --- a/sf_dlm_management/__manifest__.py +++ b/sf_dlm_management/__manifest__.py @@ -9,7 +9,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_sale', 'sf_dlm', 'sf_manufacturing'], + 'depends': ['sf_sale', 'sf_dlm', 'sf_manufacturing','jikimo_attachment_viewer'], 'data': [ 'data/stock_data.xml', 'views/product_template_management_view.xml', diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 71f4027a..fd15858a 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse'], + 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','jikimo_attachment_viewer'], 'data': [ 'data/stock_data.xml', 'data/empty_racks_data.xml', diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 573bb73f..c602fd8b 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -141,12 +141,12 @@ class MrpProduction(models.Model): ], string='工序状态', default='待装夹') # 零件图号 - part_number = fields.Char('零件图号', readonly=True) + part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True) # 上传零件图纸 - part_drawing = fields.Binary('零件图纸', readonly=True) + part_drawing = fields.Binary('零件图纸', related='product_id.machining_drawings', readonly=True) - quality_standard = fields.Binary('质检标准', readonly=True) + quality_standard = fields.Binary('质检标准', related='product_id.quality_standard', readonly=True) @api.depends('product_id.manual_quotation') def _compute_manual_quotation(self): diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 0b512c36..62744db9 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -777,8 +777,6 @@ class ResProductMo(models.Model): part_number = fields.Char(string='零件图号', readonly=True) machining_drawings = fields.Binary('2D加工图纸', readonly=True) quality_standard = fields.Binary('质检标准', readonly=True) - machining_drawings_name = fields.Char('2D加工图纸名', readonly=True) - quality_standard_name = fields.Char('质检标准名', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): @@ -840,10 +838,10 @@ class ResProductMo(models.Model): else: return self.env.ref('sf_dlm.product_uom_cubic_millimeter') - def attachment_update(self, name, res_id, res_field): + def attachment_update(self, name, res_id, res_field, mimetype): attachment_info = self.env['ir.attachment'].sudo().search( [('res_id', '=', res_id), ('res_field', '=', res_field)], limit=1) - attachment_info.write({'name': name}) + attachment_info.write({'name': name, 'mimetype': mimetype}) # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品 def product_create(self, product_id, item, order_id, order_number, i): @@ -883,8 +881,10 @@ class ResProductMo(models.Model): 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', 'active': True, - 'machining_drawings_name': item['machining_drawings_name'], - 'quality_standard_name': item['quality_standard_name'], + # 'machining_drawings_name': item['machining_drawings_name'], + # 'quality_standard_name': item['quality_standard_name'], + # 'machining_drawings_mimetype': item['machining_drawings_mimetype'], + # 'quality_standard_mimetype': item['quality_standard_mimetype'], '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']), @@ -897,10 +897,10 @@ class ResProductMo(models.Model): product_id.product_tmpl_id.active = False if item['machining_drawings'] and item['machining_drawings_name']: self.attachment_update(item['machining_drawings_name'], copy_product_id.product_tmpl_id.id, - 'machining_drawings') + 'machining_drawings', item['machining_drawings_mimetype']) if item['quality_standard'] and item['quality_standard_name']: self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id, - 'quality_standard') + 'quality_standard', item['quality_standard_mimetype']) return copy_product_id def _get_ids(self, param): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 02161b4a..40d159d5 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -272,21 +272,6 @@ class StockRule(models.Model): workorder_duration += workorder.duration_expected sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) - # 根据销售订单号查询快速订单 - quick_easy_order = self.env['quick.easy.order'].sudo().search([('sale_order_id', '=', sale_order.id)]) - 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 production.product_id.machining_drawings and production.product_id.machining_drawings_name: - self.attachment_update(production.product_id.machining_drawings_name, production.id, - 'part_drawing') - if production.product_id.quality_standard and production.product_id.quality_standard_name: - self.attachment_update(production.product_id.quality_standard_name, production.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_quality/__manifest__.py b/sf_quality/__manifest__.py index b1151b6d..582e306a 100644 --- a/sf_quality/__manifest__.py +++ b/sf_quality/__manifest__.py @@ -13,7 +13,7 @@ 'author': 'jikimo', 'website': 'https://sf.cs.jikimo.com', # 此处依赖sf_manufacturing是因为我要重写其中的一个字段operation_id的string,故需要sf_manufacturing先安装 - 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing'], + 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing','jikimo_attachment_viewer'], 'data': [ 'security/ir.model.access.csv', 'views/view.xml', diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index d3f9b5ab..ab0e9449 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -221,9 +221,8 @@ class QuickEasyOrder(models.Model): 'remark': '', 'manual_quotation': True, 'barcode': barcode, - 'machining_drawings_name': '', - 'quality_standard_name': '', - 'machining_drawings': '', + 'part_number': item.part_drawing_number, + 'machining_drawings': item.machining_drawings, 'quality_standard': '', }) # res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list']) diff --git a/sf_sale/views/quick_easy_order_view.xml b/sf_sale/views/quick_easy_order_view.xml index 9111403d..aebb4e97 100644 --- a/sf_sale/views/quick_easy_order_view.xml +++ b/sf_sale/views/quick_easy_order_view.xml @@ -80,8 +80,8 @@ - - + + From ba8393a8c75ac2cb946045b850147f67f63de648 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 28 Oct 2024 10:55:18 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E8=BF=94=E5=B7=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=97=B6=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/mrp_workorder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 267dbe60..8fe9748e 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -200,6 +200,8 @@ class MrpProduction(models.Model): self[0].write({'is_rework': False}) # 修改制造订单 编程状态变为“编程中” 制造订单状态为‘返工’ self.write({'programming_state': '编程中', 'work_state': '编程中', 'state': 'rework'}) + self[0].workorder_ids.filtered( + lambda a: a.name == '装夹预调' and a.state not in ['rework', 'done', 'cancel'])._compute_state() if missing_tool_1: logging.info(f'线边、机内缺刀:{missing_tool_1}') # 修改 修改cnc程序的‘刀具状态’ 为 ‘缺刀’ From 3559d67c052c0ba539e31a7d5fc7731a44fdcd7e Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 28 Oct 2024 11:43:10 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 8 ++------ sf_sale/models/quick_easy_order_old.py | 4 ++++ sf_sale/models/sale_order.py | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 62744db9..0476c7c7 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -881,10 +881,6 @@ class ResProductMo(models.Model): 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '', 'active': True, - # 'machining_drawings_name': item['machining_drawings_name'], - # 'quality_standard_name': item['quality_standard_name'], - # 'machining_drawings_mimetype': item['machining_drawings_mimetype'], - # 'quality_standard_mimetype': item['quality_standard_mimetype'], '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']), @@ -895,10 +891,10 @@ class ResProductMo(models.Model): vals.update({'taxes_id': [(6, 0, [int(tax_id)])]}) copy_product_id.sudo().write(vals) product_id.product_tmpl_id.active = False - if item['machining_drawings'] and item['machining_drawings_name']: + if item['machining_drawings'] and item['machining_drawings_name'] and item['machining_drawings_mimetype']: self.attachment_update(item['machining_drawings_name'], copy_product_id.product_tmpl_id.id, 'machining_drawings', item['machining_drawings_mimetype']) - if item['quality_standard'] and item['quality_standard_name']: + if item['quality_standard'] and item['quality_standard_name'] and item['machining_drawings_mimetype']: self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id, 'quality_standard', item['quality_standard_mimetype']) return copy_product_id diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index ab0e9449..e974c5d4 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -222,6 +222,10 @@ class QuickEasyOrder(models.Model): 'manual_quotation': True, 'barcode': barcode, 'part_number': item.part_drawing_number, + 'machining_drawings_name': '', + 'quality_standard_name': '', + 'machining_drawings_mimetype': '', + 'quality_standard_mimetype': '', 'machining_drawings': item.machining_drawings, 'quality_standard': '', }) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index acd1d60c..53f73aef 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -118,12 +118,16 @@ class ReSaleOrder(models.Model): # 业务平台分配工厂时在创建完产品后再创建销售明细信息 def sale_order_create_line(self, product, item): + machining_accuracy_name = '' + if product.model_machining_precision: + machining_accuracy_name = self.env['sf.machining.accuracy'].sudo().search( + [('sync_id', '=', product.model_machining_precision)]).name vals = { 'order_id': self.id, 'product_id': product.id, - 'name': '%s/%s/%s/%s/±%s/%s' % ( + 'name': '%s/%s/%s/%s/%s/%s' % ( product.model_long, product.model_width, product.model_height, product.model_volume, - product.model_machining_precision, + machining_accuracy_name, product.materials_id.name), 'price_unit': product.list_price, 'product_uom_qty': item['number'], From b4fbbd48fb6be771180562e0573b5282cb251de9 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 28 Oct 2024 11:46:36 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 0476c7c7..b7aa1adb 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -894,7 +894,7 @@ class ResProductMo(models.Model): if item['machining_drawings'] and item['machining_drawings_name'] and item['machining_drawings_mimetype']: self.attachment_update(item['machining_drawings_name'], copy_product_id.product_tmpl_id.id, 'machining_drawings', item['machining_drawings_mimetype']) - if item['quality_standard'] and item['quality_standard_name'] and item['machining_drawings_mimetype']: + if item['quality_standard'] and item['quality_standard_name'] and item['quality_standard_mimetype']: self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id, 'quality_standard', item['quality_standard_mimetype']) return copy_product_id From 5c59a27a8110878e16097ac207c53f9b9b171296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 16:30:46 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=80=BB=E7=9B=91=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=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_message/security/ir.model.access.csv | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sf_message/security/ir.model.access.csv b/sf_message/security/ir.model.access.csv index 05a7366c..4aa153e6 100644 --- a/sf_message/security/ir.model.access.csv +++ b/sf_message/security/ir.model.access.csv @@ -5,24 +5,28 @@ access_jikimo_message_template_group_purchase,jikimo_message_template,jikimo_mes access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0 access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0 access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0 +access_jikimo_message_template_group_purchase_director,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_purchase_director,1,1,1,0 access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0 access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0 access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0 access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0 access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0 +access_jikimo_message_bussiness_node_group_purchase_director,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase_director,1,1,1,0 access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0 access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0 access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0 access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0 access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0 +access_jikimo_message_queue_group_purchase_director,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase_director,1,1,1,0 access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0 access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0 access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0 access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0 access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0 +access_jikimo_message_reminder_time_group_purchase_director,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase_director,1,1,1,0 From 745fd429c2dd65807cf8cd1d8084a8ec40f480f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 17:21:51 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=80=E5=94=AE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/process_status.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index 1bfdd356..07533354 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -36,6 +36,7 @@ class StatusChange(models.Model): # 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法) try: res = super(StatusChange, self).action_confirm() + logging.info(res, 'res') # 原有方法执行后,进行额外的操作(如调用外部API) process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') config = self.env['res.config.settings'].get_values() From 61339da204e6c8cb9f48e77969398fe6000c889c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 17:26:27 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=80=E5=94=AE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/process_status.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index 07533354..09fecfae 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -36,7 +36,7 @@ class StatusChange(models.Model): # 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法) try: res = super(StatusChange, self).action_confirm() - logging.info(res, 'res') + logging.info('原生方法返回结果:%s' % res) # 原有方法执行后,进行额外的操作(如调用外部API) process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') config = self.env['res.config.settings'].get_values() @@ -62,6 +62,7 @@ class StatusChange(models.Model): traceback_error = traceback.format_exc() logging.error("工厂加工同步订单状态失败:%s " % traceback_error) raise UserError(e) + logging.info('最终返回值:%s' % res) return res def action_cancel(self): From e73e9d6960df77f6bff275d5ae84d6994766a84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 28 Oct 2024 17:42:44 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/models/sf_message_sale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index 13a5f796..c0128abb 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -39,6 +39,7 @@ class SFMessageSale(models.Model): purchase_order_info.add_queue('坯料采购提醒') except Exception as e: logging.info('add_queue error:%s' % e) + logging.info('action_confirm res:%s' % res) return res # 继承并重写jikimo.message.dispatch的_get_message() From 9665cdfc8449080c42ff06af13a306b3e71284b1 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 29 Oct 2024 08:58:33 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/models/sf_message_sale.py | 12 +++++------ sf_message/models/sf_message_stock_picking.py | 20 +++++++++---------- sf_message/models/sf_message_workorder.py | 12 +++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index 9907dbc9..fa4ef86f 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -34,7 +34,7 @@ class SFMessageSale(models.Model): picking_id.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids purchase_order_id.extend(purchase_order_ids) if purchase_order_id: - purchase_order_list = self.env['purchase.order'].search([('id', 'in', purchase_order_id)]) + purchase_order_list = self.env['purchase.order'].sudo().search([('id', 'in', purchase_order_id)]) for purchase_order_info in purchase_order_list: purchase_order_info.add_queue('坯料采购提醒') except Exception as e: @@ -45,7 +45,7 @@ class SFMessageSale(models.Model): def _get_message(self, message_queue_ids): contents = [] bussiness_node = None - url = self.env['ir.config_parameter'].get_param('web.base.url') + url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S") current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf) current_time_datetime = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S') @@ -60,7 +60,7 @@ class SFMessageSale(models.Model): contents.append(content) elif item.message_template_id.bussiness_node_id.name == '确认接单': content = super(SFMessageSale, self)._get_message(item) - sale_order_line = self.env['sale.order.line'].search([('order_id', '=', int(item.res_id))]) + sale_order_line = self.env['sale.order.line'].sudo().search([('order_id', '=', int(item.res_id))]) product = sale_order_line[0].product_id.name if len(sale_order_line) == 1 else '%s...' % \ sale_order_line[ 0].product_id.name @@ -106,7 +106,7 @@ class SFMessageSale(models.Model): sale_order = self.sudo().search( [('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')]) for item in sale_order: - production = self.env['mrp.production'].search([('origin', '=', item.name)]) + production = self.env['mrp.production'].sudo().search([('origin', '=', item.name)]) production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel']) production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel'])) if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len( @@ -146,11 +146,11 @@ class SFMessageSale(models.Model): for wo in overdue_orders: business_node_id = business_node_ids.get(wo.delivery_warning) if business_node_id: - message_template = self.env["jikimo.message.template"].search([ + message_template = self.env["jikimo.message.template"].sudo().search([ ("model", "=", self._name), ("bussiness_node_id", "=", business_node_id) ], limit=1) - sale_order_has = self.env['jikimo.message.queue'].search([ + sale_order_has = self.env['jikimo.message.queue'].sudo().search([ ('res_id', '=', wo.id), ('message_status', '=', 'pending'), ('message_template_id', '=', message_template.id) diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py index 9d7c7f0e..6e80c670 100644 --- a/sf_message/models/sf_message_stock_picking.py +++ b/sf_message/models/sf_message_stock_picking.py @@ -29,14 +29,14 @@ class SFMessageStockPicking(models.Model): [('origin', '=', record.origin), ('state', '!=', 'done'), ('picking_type_id.sequence_code', '=', 'SFP')]) if not stock_picking_sfp: - stock_picking_send = self.env["jikimo.message.queue"].search([('res_id', '=', record.id)]) + stock_picking_send = self.env["jikimo.message.queue"].sudo().search([('res_id', '=', record.id)]) if not stock_picking_send: record.add_queue('订单发货提醒') def deal_stock_picking_sfp(self, message_queue_id): # 处理订单发货提醒 content = None - stock_picking = self.env['stock.picking'].search([('id', '=', int(message_queue_id.res_id))]) - stock_picking_out = self.env['stock.picking'].search( + stock_picking = self.env['stock.picking'].sudo().search([('id', '=', int(message_queue_id.res_id))]) + stock_picking_out = self.env['stock.picking'].sudo().search( [('origin', '=', stock_picking.origin), ('state', '=', 'assigned'), ('picking_type_id.sequence_code', '=', 'OUT')]) if stock_picking_out and len(stock_picking_out) > 0: @@ -54,10 +54,10 @@ class SFMessageStockPicking(models.Model): i = 0 if message_queue_id.message_template_id.name == '坯料发料提醒': content = message_queue_id.message_template_id.content - stock_picking_line = self.env['stock.picking'].search([('id', '=', int(message_queue_id.res_id))]) - mrp_production_info = self.env['mrp.production'].search( + stock_picking_line = self.env['stock.picking'].sudo().search([('id', '=', int(message_queue_id.res_id))]) + mrp_production_info = self.env['mrp.production'].sudo().search( [('name', '=', stock_picking_line.origin)]) - mrp_production_list = self.env['mrp.production'].search( + mrp_production_list = self.env['mrp.production'].sudo().search( [('product_id', '=', mrp_production_info.product_id.id)]) for mrp_production_line in mrp_production_list: picking_ids = mrp_production_line.picking_ids @@ -87,9 +87,9 @@ class SFMessageStockPicking(models.Model): return super(SFMessageStockPicking, self).get_special_url(id, tmplate_name, special_name, model_id) def request_url(self): - url = self.env['ir.config_parameter'].get_param('web.base.url') + url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') action_id = self.env.ref('stock.stock_picking_type_action').id - menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id + menu_id = self.env['ir.model.data'].sudo().search([('name', '=', 'module_theme_treehouse')]).id # 查询参数 params = {'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking', 'view_type': 'kanban'} @@ -100,9 +100,9 @@ class SFMessageStockPicking(models.Model): return full_url def request_url1(self, id): - url = self.env['ir.config_parameter'].get_param('web.base.url') + url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') action_id = self.env.ref('stock.action_picking_tree_all').id - menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id + menu_id = self.env['ir.model.data'].sudo().search([('name', '=', 'module_theme_treehouse')]).id # 查询参数 params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking', 'view_type': 'form'} diff --git a/sf_message/models/sf_message_workorder.py b/sf_message/models/sf_message_workorder.py index 4f607802..7df3ba0a 100644 --- a/sf_message/models/sf_message_workorder.py +++ b/sf_message/models/sf_message_workorder.py @@ -26,7 +26,7 @@ class SFMessageWork(models.Model): contents = [] product_id = [] bussiness_node = None - url = self.env['ir.config_parameter'].get_param('web.base.url') + url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S") current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf) current_time_datetime = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S') @@ -39,8 +39,8 @@ class SFMessageWork(models.Model): for message_queue_id in message_queue_ids: if message_queue_id.message_template_id.name == '工单已下发通知': content = message_queue_id.message_template_id.content - mrp_workorder_line = self.env['mrp.workorder'].search([('id', '=', int(message_queue_id.res_id))]) - mrp_workorder_list = self.env['mrp.workorder'].search( + mrp_workorder_line = self.env['mrp.workorder'].sudo().search([('id', '=', int(message_queue_id.res_id))]) + mrp_workorder_list = self.env['mrp.workorder'].sudo().search( [('product_id', '=', mrp_workorder_line.product_id.id), ('state', '=', 'ready'), ('routing_type', '=', '装夹预调')]) if len(mrp_workorder_list) > 0 and mrp_workorder_line.product_id.id not in product_id: @@ -84,10 +84,10 @@ class SFMessageWork(models.Model): return contents def request_url(self): - url = self.env['ir.config_parameter'].get_param('web.base.url') + url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id - menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id - active_id = self.env['mrp.workcenter'].search([('name', '=', '工件装夹中心')]).id + menu_id = self.env['ir.model.data'].sudo().search([('name', '=', 'module_stock_dropshipping')]).id + active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id # 查询参数 params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder', 'view_type': 'list', 'active_id': active_id} From c21319a127d911ff89c375ffb3629209310d0905 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 29 Oct 2024 14:28:24 +0800 Subject: [PATCH 16/19] =?UTF-8?q?rfid=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 4 ++++ sf_manufacturing/security/group_security.xml | 10 +++++++--- sf_manufacturing/views/mrp_workorder_view.xml | 13 +++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 01977926..9c6b2a5c 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -305,6 +305,7 @@ class ResMrpWorkOrder(models.Model): is_delivery = fields.Boolean('是否配送完成', default=False) rfid_code = fields.Char('RFID码') rfid_code_old = fields.Char('RFID码(已解除)') + is_test_env = fields.Boolean('测试环境', default=False) production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id', string='生产线', store=True, tracking=True) @@ -320,6 +321,9 @@ class ResMrpWorkOrder(models.Model): detailed_reason = fields.Text('详细原因') is_rework = fields.Boolean(string='是否返工', default=False) + def button_change_env(self): + self.is_test_env = not self.is_test_env + @api.constrains('blocked_by_workorder_ids') def _check_no_cyclic_dependencies(self): if self.production_id.state not in ['rework'] and self.state not in ['rework']: diff --git a/sf_manufacturing/security/group_security.xml b/sf_manufacturing/security/group_security.xml index fdbc3ae5..040e7b92 100644 --- a/sf_manufacturing/security/group_security.xml +++ b/sf_manufacturing/security/group_security.xml @@ -1,5 +1,9 @@ - - + + + 演示模式 + + - \ No newline at end of file + + diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 708a9779..143ac4ab 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -247,11 +247,24 @@ + + + + +
+
+ From 8dc3f2698b4afe001928408ce3c1f0bc5d9d2dd5 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 29 Oct 2024 14:50:00 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=94=A8=E6=88=B7=E5=90=8C=E6=97=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E7=9A=84=E4=BC=81=E5=BE=AEid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_hr/models/__init__.py | 1 + sf_hr/models/hr_employee.py | 5 ----- sf_hr/models/res_users.py | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 sf_hr/models/res_users.py diff --git a/sf_hr/models/__init__.py b/sf_hr/models/__init__.py index ffe76391..9744f0cc 100644 --- a/sf_hr/models/__init__.py +++ b/sf_hr/models/__init__.py @@ -2,3 +2,4 @@ from . import hr_employee from . import res_config_setting +from . import res_users diff --git a/sf_hr/models/hr_employee.py b/sf_hr/models/hr_employee.py index 065288de..dae2412e 100644 --- a/sf_hr/models/hr_employee.py +++ b/sf_hr/models/hr_employee.py @@ -16,16 +16,11 @@ class JkmPracticeEmployee(models.Model): for val in vals_list: if 'work_email' in val: val["we_id"] = self._get_we_id(val.get('work_email')) - if val.get('user_id'): - user = self.env['res.users'].browse(val['user_id']) - user.write({'we_employee_id': val["we_id"]}) return super(JkmPracticeEmployee, self).create(vals_list) def write(self, vals): if 'work_email' in vals: vals["we_id"] = self._get_we_id(vals.get('work_email')) - if self.user_id: - self.user_id.write({'we_employee_id': vals["we_id"]}) return super(JkmPracticeEmployee, self).write(vals) def _get_we_id(self, work_email): diff --git a/sf_hr/models/res_users.py b/sf_hr/models/res_users.py new file mode 100644 index 00000000..7ced81bc --- /dev/null +++ b/sf_hr/models/res_users.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +import random +from odoo import models, fields, api +from odoo.http import request +from odoo.exceptions import AccessDenied + +import logging + +_logger = logging.getLogger(__name__) + + +class ResUsers(models.Model): + _inherit = 'res.users' + + we_employee_id = fields.Char(string=u'企业微信账号', related='employee_id.we_id', default="") From 9d28eccd1bea1bf5b0ba34878b7fa66f56503659 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Tue, 29 Oct 2024 15:50:38 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=90=8C=E6=97=B6=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E4=BC=81=E5=BE=AEid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_hr/models/hr_employee.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sf_hr/models/hr_employee.py b/sf_hr/models/hr_employee.py index dae2412e..5d37f199 100644 --- a/sf_hr/models/hr_employee.py +++ b/sf_hr/models/hr_employee.py @@ -23,6 +23,15 @@ class JkmPracticeEmployee(models.Model): vals["we_id"] = self._get_we_id(vals.get('work_email')) return super(JkmPracticeEmployee, self).write(vals) + @api.depends('work_contact_id', 'work_contact_id.mobile', 'work_contact_id.email') + def _compute_work_contact_details(self): + for employee in self: + if employee.work_contact_id: + employee.mobile_phone = employee.work_contact_id.mobile + employee.work_email = employee.work_contact_id.email + if employee.work_contact_id.email: + employee.we_id = self._get_we_id(employee.work_contact_id.email) + def _get_we_id(self, work_email): json1 = { 'params': { From 76597f6ccb72c1f77fea59dfd85c3d8def870c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 31 Oct 2024 11:15:06 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E5=9C=A8=E4=B8=8B=E5=8F=91=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E5=8D=95=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E6=8E=92=E7=A8=8B=EF=BC=8C=E5=9C=A8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E8=B5=B7=E6=AD=A2=E6=97=B6=E9=97=B4=E6=97=B6?= =?UTF-8?q?=E5=85=88=E8=AE=BE=E7=BD=AE=E5=A4=A7=E7=9A=84=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E9=81=BF=E5=85=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=87=BA=E9=94=99?= 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 insertions(+) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index c602fd8b..571971bc 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -806,6 +806,8 @@ class MrpProduction(models.Model): 'date_to': date_planned_end, }) # work.write({'date_planned_start': date_planned_start, 'date_planned_finished': date_planned_end}) + # 设置一个较大的结束时间,防止在设置开始时间时,结束时间小于开始时间 + work.date_planned_finished = datetime.datetime.today() + datetime.timedelta(days=100) work.date_planned_start = date_planned_start work.date_planned_finished = date_planned_end routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(