Public release from ruodoo-project: 19.0 - 2026-11-01 22:52:25 UTC
This commit is contained in:
37
directive_common/models/directive_directive.py
Normal file
37
directive_common/models/directive_directive.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import logging
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.addons.directive_layer.models.directive_constants import (
|
||||
STAGE_DRAFT,
|
||||
STAGE_PLANNED,
|
||||
STAGE_IN_PROGRESS,
|
||||
STAGE_DONE,
|
||||
)
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Directive(models.Model):
|
||||
_inherit = "directive.directive"
|
||||
|
||||
@api.model
|
||||
def _cron_simulate_system_agents(self):
|
||||
"""
|
||||
Этот метод имитирует работу внешних систем (WMS, Банк, AI).
|
||||
Запускается раз в минуту.
|
||||
"""
|
||||
system_directives = self.search([
|
||||
('executor_type', 'in', ['software', 'machine']),
|
||||
('stage_code', 'in', [STAGE_DRAFT, STAGE_PLANNED, STAGE_IN_PROGRESS]),
|
||||
('stage_code', '!=', STAGE_DONE)
|
||||
], limit=50)
|
||||
|
||||
for d in system_directives:
|
||||
|
||||
if d.stage_code == STAGE_PLANNED:
|
||||
d._set_stage(STAGE_IN_PROGRESS)
|
||||
_logger.info("Agent started directive %s", d.id)
|
||||
|
||||
elif d.stage_code == STAGE_IN_PROGRESS:
|
||||
d.action_done()
|
||||
_logger.info("Agent finished directive %s", d.id)
|
||||
Reference in New Issue
Block a user