mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-28 04:32:07 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,19 +1,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import functools
|
||||
import logging
|
||||
import random
|
||||
import time
|
||||
|
||||
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo
|
||||
from odoo.fields import Command
|
||||
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import users, warmup
|
||||
|
||||
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def prepare(func, /):
|
||||
"""Prepare data to remove common queries from the count.
|
||||
|
||||
Must be run after `warmup` because of the invalidations"""
|
||||
# prefetch the data linked to the company and its country code to avoid changing
|
||||
# the query count during l10n tests
|
||||
@functools.wraps(func)
|
||||
def test_func(self):
|
||||
self.env.company.country_id.code
|
||||
return func(self)
|
||||
return test_func
|
||||
|
||||
|
||||
@tagged('so_batch_perf')
|
||||
class TestPERF(TransactionCaseWithUserDemo):
|
||||
|
||||
|
|
@ -38,6 +51,7 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
|
||||
@users('admin')
|
||||
@warmup
|
||||
@prepare
|
||||
def test_empty_sale_order_creation_perf(self):
|
||||
with self.assertQueryCount(admin=34):
|
||||
self.env['sale.order'].create({
|
||||
|
|
@ -47,6 +61,7 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
|
||||
@users('admin')
|
||||
@warmup
|
||||
@prepare
|
||||
def test_empty_sales_orders_batch_creation_perf(self):
|
||||
# + 1 SO insert
|
||||
# + 1 SO sequence fetch
|
||||
|
|
@ -61,6 +76,7 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
|
||||
@users('admin')
|
||||
@warmup
|
||||
@prepare
|
||||
def test_dummy_sales_orders_batch_creation_perf(self):
|
||||
""" Dummy SOlines (notes/sections) should not add any custom queries other than their insert"""
|
||||
# + 2 SOL (batched) insert
|
||||
|
|
@ -76,12 +92,14 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
|
||||
@users('admin')
|
||||
@warmup
|
||||
@prepare
|
||||
def test_light_sales_orders_batch_creation_perf_without_taxes(self):
|
||||
self.env['res.country'].search([]).mapped('code')
|
||||
self.products[0].taxes_id = [Command.set([])]
|
||||
# + 2 SQL insert
|
||||
# + 2 queries to get analytic default tags
|
||||
# + 9 follower queries ?
|
||||
with self.assertQueryCount(admin=57):
|
||||
with self.assertQueryCount(admin=53): # com 46
|
||||
self.env['sale.order'].create([{
|
||||
'partner_id': self.partners[0].id,
|
||||
'user_id': self.salesmans[0].id,
|
||||
|
|
@ -118,16 +136,6 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
# (Seems to be a time-based problem, everytime happening around 10PM)
|
||||
self._test_complex_sales_orders_batch_creation_perf(1504)
|
||||
|
||||
@users('admin')
|
||||
@warmup
|
||||
def ___test_complex_sales_orders_batch_creation_perf_with_discount_computation(self):
|
||||
"""Cover the "complex" logic triggered inside the `_compute_discount`"""
|
||||
self.env['product.pricelist'].search([]).discount_policy = 'without_discount'
|
||||
self.env.user.groups_id += self.env.ref('product.group_discount_per_so_line')
|
||||
|
||||
# Verify any modification to this count on nightly runbot builds
|
||||
self._test_complex_sales_orders_batch_creation_perf(1546)
|
||||
|
||||
def _test_complex_sales_orders_batch_creation_perf(self, query_count):
|
||||
MSG = "Model %s, %i records, %s, time %.2f"
|
||||
|
||||
|
|
@ -155,9 +163,6 @@ class TestPERF(TransactionCaseWithUserDemo):
|
|||
"""Make sure the price and discounts computation are complexified
|
||||
and do not gain from any prefetch/batch gains during the price computation
|
||||
"""
|
||||
# Enable discounts
|
||||
self.env['product.pricelist'].search([]).discount_policy = 'without_discount'
|
||||
self.env.user.groups_id += self.env.ref('product.group_discount_per_so_line')
|
||||
|
||||
vals_list = [{
|
||||
"partner_id": self.partners[i].id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue