Files
tryton/trytond/tests/modelsql.py
T
Cédric Krier f911f48ed4 Delete translations only when model has translatable field
The call to Translation.delete_ids has a cost as it does search queries. So it
is better to not call it if we already know that there is nothing to delete.

issue7118
review37981003
2018-02-11 14:59:58 +01:00

71 lines
1.8 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelSQL, fields
from trytond.pool import Pool
class ModelSQLRequiredField(ModelSQL):
'model with a required field'
__name__ = 'test.modelsql'
integer = fields.Integer(string="integer", required=True)
desc = fields.Char(string="desc", required=True)
class ModelSQLTimestamp(ModelSQL):
'Model to test timestamp'
__name__ = 'test.modelsql.timestamp'
class ModelSQLFieldSet(ModelSQL):
'Model to test field set'
__name__ = 'test.modelsql.field_set'
field = fields.Function(fields.Integer('Field'),
'get_field', setter='set_field')
def get_field(self, name=None):
return
@classmethod
def set_field(cls, records, name, value):
pass
class ModelSQLOne2Many(ModelSQL):
"ModelSQL One2Many"
__name__ = 'test.modelsql.one2many'
targets = fields.One2Many(
'test.modelsql.one2many.target', 'origin', "Targets")
class ModelSQLOne2ManyTarget(ModelSQL):
"ModelSQL One2Many Target"
__name__ = 'test.modelsql.one2many.target'
name = fields.Char("Name", required=True)
origin = fields.Many2One('test.modelsql.one2many', "Origin")
class NullOrder(ModelSQL):
"Null Order"
__name__ = 'test.modelsql.null_order'
integer = fields.Integer('Integer')
class ModelTranslation(ModelSQL):
"ModelSQL with translated field"
__name__ = 'test.modelsql.translation'
name = fields.Char("Name", translate=True)
def register(module):
Pool.register(
ModelSQLRequiredField,
ModelSQLTimestamp,
ModelSQLFieldSet,
ModelSQLOne2Many,
ModelSQLOne2ManyTarget,
NullOrder,
ModelTranslation,
module=module, type_='model')