diff --git a/sf_base/models/ir_sequence.py b/sf_base/models/ir_sequence.py index 5a39cb5e..129728e5 100644 --- a/sf_base/models/ir_sequence.py +++ b/sf_base/models/ir_sequence.py @@ -19,7 +19,12 @@ class IrSequence(models.Model): # date mode dt = sequence_date or self._context.get('ir_sequence_date', fields.Date.today()) seq_date = self.env['ir.sequence.date_range'].search( - [('sequence_id', '=', self.id), ('date_from', '<=', dt), ('date_to', '>=', dt)], limit=1) + [ + ('sequence_id', '=', self.id), + ('date_from', '<=', dt), + ('date_to', '>=', dt), + ('date_range_period', '=', self.date_range_period) + ], limit=1) if not seq_date: if self.date_range_period: seq_date = self._create_date_range_seq_by_period(dt, self.date_range_period) diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index d0657a83..6bdda2df 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -28,24 +28,31 @@ class StatusChange(models.Model): raise UserError(_("请先至【产品】中创建【表面工艺参数】为%s的服务产品", ", ".join(server_product_none))) # 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法) - res = super(StatusChange, self).action_confirm() - - # 原有方法执行后,进行额外的操作(如调用外部API) - process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') - config = self.env['res.config.settings'].get_values() - json1 = { - 'params': { - 'model_name': 'jikimo.process.order', - 'field_name': 'name', - 'default_code': self.default_code, - 'state': '加工中', - 'process_start_time': process_start_time, - }, - } - url1 = config['bfm_url_new'] + '/api/get/state/get_order' - requests.post(url1, json=json1, data=None) - logging.info('接口已经执行=============') - + try: + res = super(StatusChange, self).action_confirm() + # 原有方法执行后,进行额外的操作(如调用外部API) + process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + config = self.env['res.config.settings'].get_values() + json1 = { + 'params': { + 'model_name': 'jikimo.process.order', + 'field_name': 'name', + 'default_code': self.default_code, + 'state': '加工中', + 'process_start_time': process_start_time, + }, + } + url1 = config['bfm_url_new'] + '/api/get/state/get_order' + ret = requests.post(url1, json=json1, data=None) + ret = ret.json() + if not ret.get('error'): + logging.info('接口已经执行=============') + else: + logging.error('工厂加工同步订单状态失败 {}'.format(ret.text)) + raise UserError('工厂加工同步订单状态失败') + except UserError as e: + logging.error('工厂加工同步订单状态失败 {}'.format(e)) + raise UserError('工厂加工同步订单状态失败') return res def action_cancel(self): diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 52dc8529..aa5c645e 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -387,9 +387,9 @@ class FunctionalToolAssemblyOrder(models.TransientModel): lot_ids = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)]) if lot_ids: for lot_id in lot_ids: - if lot_id.quant_ids[-1].location_id.name in '刀具房': + if lot_id.tool_material_status == '可用': record.handle_code_id = lot_id.id - elif lot_id.quant_ids[-1].location_id.name == '刀具组装位置': + elif lot_id.quant_ids[-1].location_id.name in ['刀具组装位置']: raise ValidationError('该刀柄已使用,请重新扫描!!!') else: raise ValidationError('该刀柄未入库,请重新扫描!!!')