1
1
# -*- coding: utf-8 -*-
2
2
# Copyright 2016 LasLabs Inc.
3
- # License LGPL -3.0 or later (http://www.gnu.org/licenses/lgpl ).
3
+ # License AGPL -3.0 or later (http://www.gnu.org/licenses/agpl ).
4
4
5
5
from odoo import _ , api , fields , models
6
6
from odoo .tools import safe_eval
@@ -11,6 +11,7 @@ class ClouderMetricType(models.Model):
11
11
""" It provides context for usage metric types """
12
12
13
13
_name = 'clouder.metric.type'
14
+ _description = 'Clouder Metric Types'
14
15
15
16
name = fields .Char ()
16
17
code = fields .Char ()
@@ -38,19 +39,21 @@ def _default_query_code(self):
38
39
return _ ("# Python code. \n "
39
40
"Use `value = my_value` to specify the final calculated "
40
41
" metric value. This is required. \n "
41
- "Optionally use ``uom == product_uom_record`` to change the "
42
+ "Optionally use ``uom = product_uom_record`` to change the "
42
43
"units that the metric is being measured in. \n "
44
+ "You should also add `date_start` and `date_end`, which "
45
+ "are `datetime` values to signify the date of occurrence of "
46
+ "the metric value in question. \n "
43
47
"# You can use the following variables: \n "
44
- "# - self: browse_record of the current ID Category "
45
- "browse_record. \n "
48
+ "# - self: browse_record of the current ID Category \n "
46
49
"# - interface: browse_record of the Metrics Interface. \n "
47
50
"# - metric_model: Name of the metric model type. \n " )
48
51
49
52
@api .model
50
53
def _get_metric_models (self ):
51
54
""" Returns a selection of available metric models
52
55
Returns:
53
- ( list) : Additional metric models
56
+ list: Additional metric models
54
57
"""
55
58
return [
56
59
('clouder.base' , 'Base' ),
@@ -63,7 +66,7 @@ def _get_query_code_context(self, interface):
63
66
Args:
64
67
interface (clouder.metric.interface): The interface to use
65
68
Returns:
66
- ( dict) : Dict with the context for the given iface and model
69
+ dict: Dict with the context for the given iface and model
67
70
"""
68
71
self .ensure_one ()
69
72
return {
@@ -106,6 +109,6 @@ def save_metric_value(self, metric_interfaces):
106
109
'value' : eval_context ['value' ],
107
110
'date_start' : eval_context .get ('date_start' ),
108
111
'date_end' : eval_context .get ('date_end' ),
109
- 'uom_id' : uom .id
112
+ 'uom_id' : uom .id ,
110
113
})],
111
114
})
0 commit comments