Skip to content

Commit aaae035

Browse files
dalonsodkittiu
authored andcommitted
[MIG] base_custom_info: Migration to 13.0
1 parent 52442ef commit aaae035

16 files changed

+58
-82
lines changed

base_custom_info/README.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Base Custom Info
1414
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1515
:alt: License: LGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
17-
:target: https://github.com/OCA/server-tools/tree/12.0/base_custom_info
17+
:target: https://github.com/OCA/server-tools/tree/13.0/base_custom_info
1818
:alt: OCA/server-tools
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_custom_info
20+
:target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_custom_info
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/149/12.0
23+
:target: https://runbot.odoo-community.org/runbot/149/13.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -237,7 +237,7 @@ Bug Tracker
237237
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
238238
In case of trouble, please check there if your issue has already been reported.
239239
If you spotted it first, help us smashing it by providing a detailed and welcomed
240-
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_custom_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
240+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_custom_info%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
241241

242242
Do not contact contributors directly about support or help with technical issues.
243243

@@ -261,6 +261,8 @@ Contributors
261261
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
262262
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
263263

264+
* David Alonso <david.alonso@solvos.es>
265+
264266
Maintainers
265267
~~~~~~~~~~~
266268

@@ -274,6 +276,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
274276
mission is to support the collaborative development of Odoo features and
275277
promote its widespread use.
276278

277-
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/base_custom_info>`_ project on GitHub.
279+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_custom_info>`_ project on GitHub.
278280

279281
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

base_custom_info/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"name": "Base Custom Info",
88
"summary": "Add custom field in models",
99
"category": "Tools",
10-
"version": "12.0.1.0.1",
11-
"depends": ["base_setup",],
10+
"version": "13.0.1.0.0",
11+
"depends": ["base_setup"],
1212
"data": [
1313
"security/ir.model.access.csv",
1414
"security/res_groups_security.xml",

base_custom_info/models/custom_info.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class CustomInfo(models.AbstractModel):
3434

3535
# HACK: Until https://github.com/odoo/odoo/pull/10557 is merged
3636
# https://github.com/OCA/server-tools/pull/492#issuecomment-237594285
37-
@api.multi
3837
def onchange(self, values, field_name, field_onchange): # pragma: no cover
3938
x2many_field = "custom_info_ids"
4039
if x2many_field in field_onchange:
@@ -43,7 +42,7 @@ def onchange(self, values, field_name, field_onchange): # pragma: no cover
4342
field_onchange.setdefault(
4443
u"{}.{}".format(x2many_field, subfield), u"",
4544
)
46-
return super().onchange(values, field_name, field_onchange,)
45+
return super().onchange(values, field_name, field_onchange)
4746

4847
@api.onchange("custom_info_template_id")
4948
def _onchange_custom_info_template_id(self):
@@ -71,7 +70,6 @@ def _onchange_custom_info_template_id(self):
7170
if self.all_custom_info_templates() != tmpls:
7271
self._onchange_custom_info_template_id()
7372

74-
@api.multi
7573
def unlink(self):
7674
"""Remove linked custom info this way, as can't be handled
7775
automatically.
@@ -82,7 +80,6 @@ def unlink(self):
8280
info_values.unlink()
8381
return res
8482

85-
@api.multi
8683
@api.returns("custom.info.value")
8784
def get_custom_info_value(self, properties):
8885
"""Get ``custom.info.value`` records for the given property."""
@@ -94,7 +91,6 @@ def get_custom_info_value(self, properties):
9491
]
9592
)
9693

97-
@api.multi
9894
def all_custom_info_templates(self):
9995
"""Get all custom info templates involved in these owners."""
10096
return self.mapped("custom_info_template_id") | self.mapped(

base_custom_info/models/custom_info_category.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
22
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
33

4-
from odoo import api, fields, models
4+
from odoo import fields, models
55

66

77
class CustomInfoCategory(models.Model):
@@ -18,7 +18,6 @@ class CustomInfoCategory(models.Model):
1818
help="Properties in this category.",
1919
)
2020

21-
@api.multi
2221
def check_access_rule(self, operation):
2322
"""You access a category if you access at least one property."""
2423
last_error = None

base_custom_info/models/custom_info_option.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2017 Pedro M. Baeza <pedro.baeza@tecnativa.com>
33
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
44

5-
from odoo import api, fields, models
5+
from odoo import fields, models
66

77

88
class CustomInfoOption(models.Model):
@@ -29,7 +29,6 @@ class CustomInfoOption(models.Model):
2929
"is chosen.",
3030
)
3131

32-
@api.multi
3332
def check_access_rule(self, operation):
3433
"""You access an option if you access at least one property."""
3534
last_error = None

base_custom_info/models/custom_info_property.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CustomInfoProperty(models.Model):
3737
required=True,
3838
ondelete="cascade",
3939
)
40-
model = fields.Char(related="template_id.model", readonly=True, auto_join=True,)
40+
model = fields.Char(related="template_id.model", auto_join=True)
4141
info_value_ids = fields.One2many(
4242
comodel_name="custom.info.value",
4343
inverse_name="property_id",
@@ -80,7 +80,6 @@ class CustomInfoProperty(models.Model):
8080
"options here.",
8181
)
8282

83-
@api.multi
8483
def check_access_rule(self, operation):
8584
"""You access a property if you access its template."""
8685
self.mapped("template_id").check_access_rule(operation)
@@ -107,7 +106,6 @@ def _check_default_value(self):
107106
for rec in self:
108107
rec._check_default_value_one()
109108

110-
@api.multi
111109
@api.onchange("required", "field_type")
112110
def _onchange_required_warn(self):
113111
"""Warn if the required flag implies a possible weird behavior."""

base_custom_info/models/custom_info_template.py

-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ class CustomInfoTemplate(models.Model):
3838
comodel_name="custom.info.property",
3939
inverse_name="template_id",
4040
string="Properties",
41-
oldname="info_ids",
4241
)
4342

44-
@api.multi
4543
@api.depends("model_id")
4644
def _compute_model(self):
4745
for r in self:
4846
r.model = r.model_id.model
4947

50-
@api.multi
5148
def _inverse_model(self):
5249
for r in self:
5350
r.model_id = self.env["ir.model"].search([("model", "=", r.model)])
@@ -61,7 +58,6 @@ def _search_model(self, operator, value):
6158
def _onchange_model(self):
6259
self._inverse_model()
6360

64-
@api.multi
6561
def _check_model_update_allowed(self, model_id):
6662
"""Check if the template's model can be updated.
6763
@@ -76,7 +72,6 @@ def _check_model_update_allowed(self, model_id):
7672
_("You cannot change the model because it is in use.")
7773
)
7874

79-
@api.multi
8075
def check_access_rule(self, operation):
8176
"""You access a template if you access its model."""
8277
for record in self:
@@ -85,7 +80,6 @@ def check_access_rule(self, operation):
8580
model.check_access_rule(operation)
8681
return super().check_access_rule(operation)
8782

88-
@api.multi
8983
def write(self, vals):
9084
if "model_id" in vals:
9185
self._check_model_update_allowed(vals["model_id"])

base_custom_info/models/custom_info_value.py

+37-47
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,21 @@ class CustomInfoValue(models.Model):
4646
readonly=True,
4747
)
4848
property_sequence = fields.Integer(
49-
related="property_id.sequence", store=True, index=True, readonly=True,
49+
related="property_id.sequence", store=True, index=True,
5050
)
5151
category_sequence = fields.Integer(
5252
string="Category Sequence",
5353
related="property_id.category_id.sequence",
5454
store=True,
55-
readonly=True,
56-
)
57-
category_id = fields.Many2one(
58-
related="property_id.category_id", store=True, readonly=True,
5955
)
60-
name = fields.Char(related="property_id.name", readonly=True)
61-
field_type = fields.Selection(related="property_id.field_type", readonly=True,)
56+
category_id = fields.Many2one(related="property_id.category_id", store=True)
57+
name = fields.Char(related="property_id.name")
58+
field_type = fields.Selection(related="property_id.field_type")
6259
field_name = fields.Char(
6360
compute="_compute_field_name",
6461
help="Technical name of the field where the value is stored.",
6562
)
66-
required = fields.Boolean(related="property_id.required", readonly=True)
63+
required = fields.Boolean(related="property_id.required")
6764
value = fields.Char(
6865
compute="_compute_value",
6966
inverse="_inverse_value",
@@ -81,7 +78,6 @@ class CustomInfoValue(models.Model):
8178
domain="[('property_ids', '=', property_id)]",
8279
)
8380

84-
@api.multi
8581
def check_access_rule(self, operation):
8682
"""You access a value if you access its owner record."""
8783
if self.env.uid != SUPERUSER_ID:
@@ -113,28 +109,24 @@ def _selection_owner_id(self):
113109
if m.model in self.env and self.env[m.model]._auto
114110
]
115111

116-
@api.multi
117112
@api.depends("property_id.field_type")
118113
def _compute_field_name(self):
119114
"""Get the technical name where the real typed value is stored."""
120115
for s in self:
121116
s.field_name = "value_{!s}".format(s.property_id.field_type)
122117

123-
@api.multi
124118
@api.depends("res_id", "model")
125119
def _compute_owner_id(self):
126120
"""Get the id from the linked record."""
127121
for record in self:
128122
record.owner_id = "{},{}".format(record.model, record.res_id)
129123

130-
@api.multi
131124
def _inverse_owner_id(self):
132125
"""Store the owner according to the model and ID."""
133126
for record in self.filtered("owner_id"):
134127
record.model = record.owner_id._name
135128
record.res_id = record.owner_id.id
136129

137-
@api.multi
138130
@api.depends(
139131
"property_id.field_type",
140132
"field_name",
@@ -154,7 +146,6 @@ def _compute_value(self):
154146
else:
155147
s.value = getattr(s, s.field_name, False)
156148

157-
@api.multi
158149
def _inverse_value(self):
159150
"""Write the value correctly converted in the typed field."""
160151
for record in self:
@@ -168,48 +159,47 @@ def _inverse_value(self):
168159
record.value, record.field_type, record.property_id,
169160
)
170161

171-
@api.one
172162
@api.constrains("property_id", "value_str", "value_int", "value_float")
173163
def _check_min_max_limits(self):
174164
"""Ensure value falls inside the property's stablished limits."""
175-
minimum, maximum = self.property_id.minimum, self.property_id.maximum
176-
if minimum <= maximum:
177-
value = self[self.field_name]
178-
if not value:
179-
# This is a job for :meth:`.~_check_required`
180-
return
181-
if self.field_type == "str":
182-
number = len(self.value_str)
183-
message = _(
184-
"Length for %(prop)s is %(val)s, but it should be "
185-
"between %(min)d and %(max)d."
186-
)
187-
elif self.field_type in {"int", "float"}:
188-
number = value
189-
if self.field_type == "int":
165+
for record in self:
166+
minimum, maximum = record.property_id.minimum, record.property_id.maximum
167+
if minimum <= maximum:
168+
value = record[record.field_name]
169+
if not value:
170+
# This is a job for :meth:`.~_check_required`
171+
continue
172+
if record.field_type == "str":
173+
number = len(self.value_str)
190174
message = _(
191-
"Value for %(prop)s is %(val)s, but it should be "
175+
"Length for %(prop)s is %(val)s, but it should be "
192176
"between %(min)d and %(max)d."
193177
)
178+
elif record.field_type in {"int", "float"}:
179+
number = value
180+
if record.field_type == "int":
181+
message = _(
182+
"Value for %(prop)s is %(val)s, but it should be "
183+
"between %(min)d and %(max)d."
184+
)
185+
else:
186+
message = _(
187+
"Value for %(prop)s is %(val)s, but it should be "
188+
"between %(min)f and %(max)f."
189+
)
194190
else:
195-
message = _(
196-
"Value for %(prop)s is %(val)s, but it should be "
197-
"between %(min)f and %(max)f."
191+
continue
192+
if not minimum <= number <= maximum:
193+
raise ValidationError(
194+
message
195+
% {
196+
"prop": record.property_id.display_name,
197+
"val": number,
198+
"min": minimum,
199+
"max": maximum,
200+
}
198201
)
199-
else:
200-
return
201-
if not minimum <= number <= maximum:
202-
raise ValidationError(
203-
message
204-
% {
205-
"prop": self.property_id.display_name,
206-
"val": number,
207-
"min": minimum,
208-
"max": maximum,
209-
}
210-
)
211202

212-
@api.multi
213203
@api.onchange("property_id")
214204
def _onchange_property_set_default_value(self):
215205
"""Load default value for this property."""

base_custom_info/readme/CONTRIBUTORS.rst

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
* Jairo Llopis <jairo.llopis@tecnativa.com>
77
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
88
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
9+
10+
* David Alonso <david.alonso@solvos.es>

base_custom_info/static/description/index.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Base Custom Info</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/base_custom_info"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_custom_info"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
370+
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_custom_info"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_custom_info"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
371371
<p>This module allows you to attach custom information to records without the need
372372
to alter the database structure too much.</p>
373373
<p>This module defines several concepts that you have to understand.</p>
@@ -556,7 +556,7 @@ <h3><a class="toc-backref" href="#id6">Bug Tracker</a></h3>
556556
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
557557
In case of trouble, please check there if your issue has already been reported.
558558
If you spotted it first, help us smashing it by providing a detailed and welcomed
559-
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_custom_info%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
559+
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_custom_info%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
560560
<p>Do not contact contributors directly about support or help with technical issues.</p>
561561
</div>
562562
<div class="section" id="credits">
@@ -581,6 +581,7 @@ <h2>Contributors</h2>
581581
<li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li>
582582
</ul>
583583
</li>
584+
<li>David Alonso &lt;<a class="reference external" href="mailto:david.alonso&#64;solvos.es">david.alonso&#64;solvos.es</a>&gt;</li>
584585
</ul>
585586
</div>
586587
<div class="section" id="maintainers">
@@ -590,7 +591,7 @@ <h2>Maintainers</h2>
590591
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
591592
mission is to support the collaborative development of Odoo features and
592593
promote its widespread use.</p>
593-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/base_custom_info">OCA/server-tools</a> project on GitHub.</p>
594+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_custom_info">OCA/server-tools</a> project on GitHub.</p>
594595
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
595596
</div>
596597
</div>

0 commit comments

Comments
 (0)