Replace em-dashes and en-dashes with hyphens across 789 shipped source files (py/xml/js/scss) so the delivered module reads as human-written; em-dashes had become a recognizable AI-generated tell. Internal .md dev notes are excluded. The WO-sticker mojibake strippers keep their dash search targets (now written — / –). No logic changes: comments and display strings only; validated with py_compile + lxml parse. Rewrite the 7 customer notification emails to be intake-neutral (ship-in / drop-off / pickup) and repair-aware, and fix the Shipped email documents line (packing slip vs bill of lading; certificate only when issued). Subjects use a hyphen separator. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
81 lines
2.9 KiB
Python
81 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc. - License OPL-1
|
|
"""Plan task P2.4 - _cron_autopause_stale_steps method."""
|
|
from datetime import datetime, timedelta
|
|
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged('-at_install', 'post_install', 'fp_jobs')
|
|
class TestAutopauseCron(TransactionCase):
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
self.partner = self.env['res.partner'].create({'name': 'AP'})
|
|
self.product = self.env['product.product'].create({'name': 'AP'})
|
|
self.job = self.env['fp.job'].create({
|
|
'name': 'WH/JOB/AP',
|
|
'partner_id': self.partner.id,
|
|
'product_id': self.product.id,
|
|
'qty': 1,
|
|
})
|
|
|
|
def test_stale_step_flips_to_paused(self):
|
|
step = self.env['fp.job.step'].create({
|
|
'job_id': self.job.id,
|
|
'name': 'Stale',
|
|
'sequence': 10,
|
|
'state': 'in_progress',
|
|
'date_started': datetime.now() - timedelta(hours=10),
|
|
})
|
|
paused = self.env['fp.job.step']._cron_autopause_stale_steps()
|
|
self.assertGreaterEqual(paused, 1)
|
|
step.invalidate_recordset(['state'])
|
|
self.assertEqual(step.state, 'paused')
|
|
|
|
def test_fresh_step_unchanged(self):
|
|
step = self.env['fp.job.step'].create({
|
|
'job_id': self.job.id,
|
|
'name': 'Fresh',
|
|
'sequence': 10,
|
|
'state': 'in_progress',
|
|
'date_started': datetime.now() - timedelta(hours=2),
|
|
})
|
|
self.env['fp.job.step']._cron_autopause_stale_steps()
|
|
step.invalidate_recordset(['state'])
|
|
self.assertEqual(step.state, 'in_progress')
|
|
|
|
def test_long_running_node_exempt(self):
|
|
node = self.env['fusion.plating.process.node'].create({
|
|
'name': 'Long bake',
|
|
'long_running': True,
|
|
'node_type': 'operation',
|
|
})
|
|
step = self.env['fp.job.step'].create({
|
|
'job_id': self.job.id,
|
|
'name': 'Long',
|
|
'sequence': 10,
|
|
'state': 'in_progress',
|
|
'date_started': datetime.now() - timedelta(hours=20),
|
|
'recipe_node_id': node.id,
|
|
})
|
|
self.env['fp.job.step']._cron_autopause_stale_steps()
|
|
step.invalidate_recordset(['state'])
|
|
self.assertEqual(step.state, 'in_progress')
|
|
|
|
def test_threshold_config_parameter_respected(self):
|
|
self.env['ir.config_parameter'].sudo().set_param(
|
|
'fp.shopfloor.autopause_threshold_hours', '24',
|
|
)
|
|
step = self.env['fp.job.step'].create({
|
|
'job_id': self.job.id,
|
|
'name': 'Within 24h',
|
|
'sequence': 10,
|
|
'state': 'in_progress',
|
|
'date_started': datetime.now() - timedelta(hours=10),
|
|
})
|
|
self.env['fp.job.step']._cron_autopause_stale_steps()
|
|
step.invalidate_recordset(['state'])
|
|
# 10h < 24h → still in_progress
|
|
self.assertEqual(step.state, 'in_progress')
|