mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 11:52:00 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -0,0 +1,42 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.sale_timesheet.tests.test_sale_timesheet import TestSaleTimesheet
|
||||
from odoo.tests import tagged
|
||||
from odoo.fields import Command
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestPerformanceTimesheet(TestSaleTimesheet):
|
||||
|
||||
def test_performance_billable_project_change_customer(self):
|
||||
"""
|
||||
Use case: change the partner of a billable project containing many tasks having no SOL, which should trigger _compute_sale_line_id() of all tasks.
|
||||
We check if the number of queries does not increase proportionally to the number of tasks.
|
||||
"""
|
||||
project = self.env['project.project'].create({
|
||||
'name': 'Perf Project',
|
||||
'task_ids': [Command.create({'name': f'Task {i}'}) for i in range(50)]
|
||||
})
|
||||
self.assertFalse(project.task_ids.sale_line_id)
|
||||
self.env.invalidate_all()
|
||||
with self.assertQueryCount(85):
|
||||
project.write({
|
||||
'allow_billable': True,
|
||||
'partner_id': self.partner_b.id,
|
||||
})
|
||||
self.assertTrue(project.task_ids.sale_line_id)
|
||||
|
||||
# Reset all tasks's SOL to False, double the number of tasks and run it again
|
||||
project.allow_billable = False
|
||||
self.assertFalse(project.task_ids.sale_line_id)
|
||||
self.env['project.task'].create([{
|
||||
'name': f'Task {i}',
|
||||
'project_id': project.id,
|
||||
} for i in range(50, 100)])
|
||||
self.env.invalidate_all()
|
||||
with self.assertQueryCount(130):
|
||||
project.write({
|
||||
'allow_billable': True,
|
||||
'partner_id': self.partner_b.id,
|
||||
})
|
||||
self.assertTrue(project.task_ids.sale_line_id)
|
||||
Loading…
Add table
Add a link
Reference in a new issue