Files
odoo_source/odoo/addons/test_performance/models/models.py
T
Thibault Delavallée 1cc1ef5058 [SPLIT] test_performance: split between base and mail performance tests
Test performance will now hold the base class for performance tests as
well as tests related to the ORM, depending only on base. A new module
test_mail is introduced at this commit that contains performance tests
related to mail module. This commit contains only code move and should
not impact anything.

Future commits will move mail tests into test_mail so that all mail
related tests are located in the same optional module. This allows
notably to avoid creating a lot of unnecessary tables when installing
mail module on production databases.
2017-11-29 10:05:01 +01:00

41 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, api
class BaseModel(models.Model):
_name = 'test_performance.base'
name = fields.Char()
value = fields.Integer()
value_pc = fields.Float(compute="_value_pc", store=True)
partner_id = fields.Many2one('res.partner', string='Customer')
line_ids = fields.One2many('test_performance.line', 'base_id')
total = fields.Integer(compute="_total", store=True)
tag_ids = fields.Many2many('test_performance.tag')
@api.depends('value')
def _value_pc(self):
for record in self:
record.value_pc = float(record.value) / 100
@api.depends('line_ids.value')
def _total(self):
for record in self:
record.total = sum(line.value for line in record.line_ids)
class LineModel(models.Model):
_name = 'test_performance.line'
base_id = fields.Many2one('test_performance.base', required=True, ondelete='cascade')
value = fields.Integer()
class TagModel(models.Model):
_name = 'test_performance.tag'
name = fields.Char()