File: models_import.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (128 lines) | stat: -rw-r--r-- 3,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from odoo import fields, models


class Char(models.Model):
    _name = 'import.char'
    _description = 'Tests: Base Import Model, Character'

    value = fields.Char()


class CharRequired(models.Model):
    _name = 'import.char.required'
    _description = 'Tests: Base Import Model, Character required'

    value = fields.Char(required=True)


class CharReadonly(models.Model):
    _name = 'import.char.readonly'
    _description = 'Tests: Base Import Model, Character readonly'

    value = fields.Char(readonly=True)


class CharNoreadonly(models.Model):
    _name = 'import.char.noreadonly'
    _description = 'Tests: Base Import Model, Character No readonly'

    value = fields.Char(readonly=True)


class CharStillreadonly(models.Model):
    _name = 'import.char.stillreadonly'
    _description = 'Tests: Base Import Model, Character still readonly'

    value = fields.Char(readonly=True)


# TODO: complex field (m2m, o2m, m2o)
class M2o(models.Model):
    _name = 'import.m2o'
    _description = 'Tests: Base Import Model, Many to One'

    value = fields.Many2one('import.m2o.related')


class M2oRelated(models.Model):
    _name = 'import.m2o.related'
    _description = 'Tests: Base Import Model, Many to One related'

    value = fields.Integer(default=42)


class M2oRequired(models.Model):
    _name = 'import.m2o.required'
    _description = 'Tests: Base Import Model, Many to One required'

    value = fields.Many2one('import.m2o.required.related', required=True)


class M2oRequiredRelated(models.Model):
    _name = 'import.m2o.required.related'
    _description = 'Tests: Base Import Model, Many to One required related'

    value = fields.Integer(default=42)


class O2m(models.Model):
    _name = 'import.o2m'
    _description = 'Tests: Base Import Model, One to Many'

    name = fields.Char()
    value = fields.One2many('import.o2m.child', 'parent_id')


class O2mChild(models.Model):
    _name = 'import.o2m.child'
    _description = 'Tests: Base Import Model, One to Many child'

    parent_id = fields.Many2one('import.o2m')
    value = fields.Integer()


class Preview(models.Model):
    _name = 'import.preview'
    _description = 'Tests: Base Import Model Preview'

    name = fields.Char('Name')
    somevalue = fields.Integer(string='Some Value', required=True)
    othervalue = fields.Integer(string='Other Variable')


class Float(models.Model):
    _name = 'import.float'
    _description = 'Tests: Base Import Model Float'

    value = fields.Float()
    value2 = fields.Monetary()
    currency_id = fields.Many2one('res.currency')


class Complex(models.Model):
    _name = 'import.complex'
    _description = 'Tests: Base Import Model Complex'

    f = fields.Float()
    m = fields.Monetary()
    c = fields.Char()
    currency_id = fields.Many2one('res.currency')
    d = fields.Date()
    dt = fields.Datetime()
    parent_id = fields.Many2one('import.complex')


class PropertyDefinition(models.Model):
    _name = _description = 'import.properties.definition'
    _rec_name = 'id'

    properties_definition = fields.PropertiesDefinition()
    record_properties_ids = fields.One2many('import.properties', 'record_definition_id')
    main_properties_record_id = fields.Many2one('import.properties', 'record_definition_id')


class Property(models.Model):
    _name = _description = 'import.properties'

    properties = fields.Properties(definition='record_definition_id.properties_definition')
    record_definition_id = fields.Many2one('import.properties.definition')