Public release from ruodoo-project: 19.0 - 2026-07-26 21:17:35 UTC
This commit is contained in:
27
directive_test/models/directive_directive.py
Normal file
27
directive_test/models/directive_directive.py
Normal file
@ -0,0 +1,27 @@
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
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', ['draft', 'planned', 'in_progress']),
|
||||
('stage_code', '!=', 'done')
|
||||
], limit=50)
|
||||
|
||||
for d in system_directives:
|
||||
|
||||
if d.stage_code == 'planned':
|
||||
d._set_stage('in_progress')
|
||||
print(f"Agent started directive {d.id}")
|
||||
|
||||
elif d.stage_code == 'in_progress':
|
||||
d.action_done()
|
||||
print(f"Agent finished directive {d.id}")
|
||||
Reference in New Issue
Block a user