diff --git a/jikimo_work_reporting_api/controllers/main.py b/jikimo_work_reporting_api/controllers/main.py index 189c2d0a..5bdef967 100644 --- a/jikimo_work_reporting_api/controllers/main.py +++ b/jikimo_work_reporting_api/controllers/main.py @@ -6,7 +6,7 @@ from odoo.addons.sf_base.decorators.api_log import api_log class MainController(http.Controller): - @http.route('/api/manual_download_program', type='json', methods=['POST'], auth='public', cors='*') + @http.route('/api/manual_download_program', type='json', methods=['POST'], auth='wechat_token', cors='*') @api_log('人工线下加工编程文件传输', requester='报工系统') def manual_download_program(self): """ diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 60d17052..070ff404 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -513,11 +513,10 @@ class ResMrpWorkOrder(models.Model): return result def _get_surface_technics_purchase_ids(self): - domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment')] + domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment'), ('state', '!=', 'cancel')] # domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment')] # domain = [('group_id', '=', self.production_id.procurement_group_id.id), ('purchase_type', '=', 'consignment')] - purchase_orders = self.env['purchase.order'].search(domain, order='id desc', # 按创建时间降序(最新的在前) - limit=1) + purchase_orders = self.env['purchase.order'].search(domain, order='id desc') purchase_orders_id = self.env['purchase.order'] for po in purchase_orders: for line in po.order_line: diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 6061dda8..b6b657c1 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -213,11 +213,11 @@ class ReworkWizard(models.TransientModel): self.production_id.get_new_program(panel_name) if self.reprogramming_num >= 0 and self.programming_state == '已下发': # ============= 处理CNC加工加工工单的 CNC程序和cmm程序 信息============= - for cnc_work in new_work_ids.filtered(lambda wk: wk.name == 'CNC加工'): + for cnc_work in new_work_ids.filtered(lambda wk: wk.name == 'CNC加工' or wk.name == '人工线下加工'): ret = {'programming_list': []} old_cnc_rework = max(self.production_id.workorder_ids.filtered( lambda crw: crw.processing_panel == cnc_work.processing_panel - and crw.state == 'rework' and crw.routing_type == 'CNC加工'), + and crw.state == 'rework' and (crw.routing_type == 'CNC加工' or crw.routing_type == '人工线下加工')), key=lambda w: w.create_date ) # 获取当前工单的CNC程序和cmm程序 @@ -259,7 +259,7 @@ class ReworkWizard(models.TransientModel): new_cnc_workorder = self.production_id.workorder_ids.filtered( lambda ap1: ap1.processing_panel == cnc_work.processing_panel and ap1.state not in ( - 'rework', 'done') and ap1.routing_type == 'CNC加工' + 'rework', 'done') and (ap1.routing_type == 'CNC加工' or ap1.routing_type == '人工线下加工') ) if not new_cnc_workorder.cnc_ids: new_cnc_workorder.write({ @@ -303,18 +303,22 @@ class ReworkWizard(models.TransientModel): @api.onchange('production_id') def onchange_processing_panel_id(self): for item in self: + panel_ids = [] domain = [('id', '=', False)] production_id = item.production_id if production_id: if self.env.user.has_group('sf_base.group_sf_order_user'): - panel_ids = [] + panel_arr = production_id.product_id.model_processing_panel if panel_arr is False: break for p in production_id.detection_result_ids.filtered( lambda ap1: ap1.handle_result == '待处理'): if p.processing_panel is not False and p.processing_panel not in panel_arr: - panel_arr += ','.join(p.processing_panel) + if len(panel_arr)>0: + panel_arr += ','.join(p.processing_panel) + else: + panel_arr = p.processing_panel for item in panel_arr.split(','): panel = self.env['sf.processing.panel'].search( [('name', 'ilike', item)]) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index af5b387f..9e323a7f 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -228,7 +228,7 @@ class sf_production_plan(models.Model): """ 排程方法 """ - self.deal_processing_schedule(self.date_planned_start) + self.deal_processing_schedule(self[0].date_planned_start) for record in self: if not record.production_line_id: raise ValidationError("未选择生产线") diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index ea02f9ce..ced49414 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -343,10 +343,13 @@ class RePurchaseOrder(models.Model): if order_line.product_id.id in product_list: purchase.purchase_type = 'outsourcing' break - request_lines = self.order_line.mapped('purchase_request_lines') - # 检查是否存在 is_subcontract 为 True 的行 - if any(line.is_subcontract for line in request_lines): - purchase.purchase_type = 'consignment' + if purchase.order_line[0].product_id.categ_id.name == '坯料': + if purchase.order_line[0].product_id.materials_type_id.gain_way == '外协': + purchase.purchase_type = 'outsourcing' + # request_lines = self.order_line.mapped('purchase_request_lines') + # # 检查是否存在 is_subcontract 为 True 的行 + # if any(line.is_subcontract for line in request_lines): + # purchase.purchase_type = 'consignment' delivery_warning = fields.Selection([('normal', '正常'), ('warning', '预警'), ('overdue', '已逾期')],