工单异常处理

This commit is contained in:
胡尧
2024-10-15 15:14:16 +08:00
parent e2bd36ca16
commit ce5cb17e31
24 changed files with 403 additions and 36 deletions

View File

@@ -1,4 +1,7 @@
from odoo import models, fields
import logging
_logger = logging.getLogger(__name__)
class MrpWorkorder(models.Model):
_inherit = 'mrp.workorder'
@@ -15,4 +18,23 @@ class MrpWorkorder(models.Model):
'completion_time': fields.Datetime.now(),
'state': 'done'
})
return super(MrpWorkorder, self).write(values)
return super(MrpWorkorder, self).write(values)
def handle_exception(self, exception_codes):
"""
处理异常
:param exception_codes: 需要处理的异常编码列表
"""
if not isinstance(exception_codes, list):
exception_codes = [exception_codes]
if self.exception_ids:
_logger.info('workorder.exception_ids:%s' % self.exception_ids)
pending_exception = self.exception_ids.filtered(
lambda exc: exc.state == 'pending' and exc.exception_code in exception_codes
)
_logger.info('pending_exception:%s' % pending_exception)
if pending_exception:
pending_exception.write({
'completion_time': fields.Datetime.now(),
'state': 'done'
})