[MIG] bemade_fsm to 18.0 Aside from fixing standard 17.0..18.0 stuff and fixing XML ID references: 1. **Remove `_get_closed_stage_by_project()`**: This method is obsolete - it was copied from base FSM but no longer exists in 18.0. Base system now uses `is_closed` field. 2. **Implement State Propagation**: Enhance the `write()` method to propagate done/cancelled states to child tasks using `is_closed` field logic. 3. **Test Task Creation**: Thoroughly test the custom task creation logic against base 18.0 All 56 tests are passing.
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
from .test_bemade_fsm_common import BemadeFSMBaseTest
|
|
from odoo.tests import Form
|
|
|
|
|
|
class TestTaskReport(BemadeFSMBaseTest):
|
|
def test_split_time_materials_setting(self):
|
|
with Form(self.env["res.config.settings"]) as settings:
|
|
settings.separate_time_on_work_orders = True
|
|
|
|
with Form(self.env["res.config.settings"]):
|
|
self.assertTrue(settings.separate_time_on_work_orders)
|
|
|
|
so = self._generate_sale_order()
|
|
service_product = self._generate_product()
|
|
material_product = self._generate_product(
|
|
name="Material Product",
|
|
product_type="consu",
|
|
service_tracking="no",
|
|
)
|
|
visit = self._generate_visit(sale_order=so)
|
|
self._generate_sale_order_line(sale_order=so, product=service_product)
|
|
self._generate_sale_order_line(sale_order=so, product=material_product)
|
|
so.action_confirm()
|
|
task = visit.task_id
|
|
|
|
# Add timesheet entry to make the report renderable
|
|
self.env["account.analytic.line"].create(
|
|
{
|
|
"name": "Test timesheet entry",
|
|
"task_id": task.id,
|
|
"project_id": task.project_id.id,
|
|
"unit_amount": 2.0,
|
|
"employee_id": self.env["hr.employee"]
|
|
.create(
|
|
{
|
|
"name": "Test Employee",
|
|
"user_id": self.env.user.id,
|
|
}
|
|
)
|
|
.id,
|
|
}
|
|
)
|
|
|
|
html_content = (
|
|
self.env["ir.actions.report"]
|
|
._render(
|
|
"industry_fsm.worksheet_custom", [task.id]
|
|
)[ # pyright: ignore[reportOptionalSubscript]
|
|
0
|
|
]
|
|
.decode("utf-8")
|
|
.split("\n")
|
|
)
|
|
|
|
strings_to_find = ["<h2>Materials</h2>", "<span>Material Product</span>"]
|
|
|
|
for line in strings_to_find:
|
|
line_found = False
|
|
for html_line in html_content:
|
|
if line in html_line:
|
|
line_found = True
|
|
self.assertTrue(line_found, f"{line} should be in file.")
|