Skip to content
This repository was archived by the owner on Jan 24, 2018. It is now read-only.

Commit 8c7645c

Browse files
author
Ted Salmon
committed
[IMP] clouder_metric: Fixes per PR
* Update license to AGPL * Add model `_description` * Clean up lint issues
1 parent e3a0b89 commit 8c7645c

11 files changed

+26
-24
lines changed

clouder_metric/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
2-
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
33
:alt: License: AGPL-3
44

55
==============
@@ -19,7 +19,7 @@ Bug Tracker
1919
===========
2020

2121
Bugs are tracked on `GitHub Issues
22-
<https://github.com/clouder/clouder/issues>`_.
22+
<https://github.com/clouder-community/clouder>`_.
2323

2424
Contributors
2525
------------

clouder_metric/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44

55
from . import models

clouder_metric/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44
{
55
"name": "Clouder - Metrics",
66
"summary": "Provides Usage Metric Interface for Clouder",
77
"version": "10.0.1.0.0",
88
"category": "Clouder",
99
"website": "https://github.com/clouder-community/clouder",
1010
"author": "LasLabs",
11-
"license": "LGPL-3",
11+
"license": "AGPL-3",
1212
"application": False,
1313
"installable": True,
1414
"depends": [

clouder_metric/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44

55
from . import clouder_metric_type
66
from . import clouder_metric_interface

clouder_metric/models/clouder_metric_interface.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44

55
from odoo import api, fields, models
66

@@ -12,6 +12,7 @@ class ClouderMetricInterface(models.Model):
1212
"""
1313

1414
_name = 'clouder.metric.interface'
15+
_description = 'Clouder Metric Interfaces'
1516
_inherits = {'clouder.metric.type': 'type_id'}
1617

1718
type_id = fields.Many2one(
@@ -65,5 +66,5 @@ def metric_id(self):
6566
@api.multi
6667
def name_get(self):
6768
return [
68-
(r.id, '%s - %s' % (r.type_id.name, r.metric_ref)) for r in self
69+
(r.id, '%s - %s' % (r.type_id.name, r.metric_id.id)) for r in self
6970
]

clouder_metric/models/clouder_metric_type.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44

55
from odoo import _, api, fields, models
66
from odoo.tools import safe_eval
@@ -11,6 +11,7 @@ class ClouderMetricType(models.Model):
1111
""" It provides context for usage metric types """
1212

1313
_name = 'clouder.metric.type'
14+
_description = 'Clouder Metric Types'
1415

1516
name = fields.Char()
1617
code = fields.Char()
@@ -38,19 +39,21 @@ def _default_query_code(self):
3839
return _("# Python code. \n"
3940
"Use `value = my_value` to specify the final calculated "
4041
" 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 "
4243
"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"
4347
"# 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"
4649
"# - interface: browse_record of the Metrics Interface. \n"
4750
"# - metric_model: Name of the metric model type. \n")
4851

4952
@api.model
5053
def _get_metric_models(self):
5154
""" Returns a selection of available metric models
5255
Returns:
53-
(list): Additional metric models
56+
list: Additional metric models
5457
"""
5558
return [
5659
('clouder.base', 'Base'),
@@ -63,7 +66,7 @@ def _get_query_code_context(self, interface):
6366
Args:
6467
interface (clouder.metric.interface): The interface to use
6568
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
6770
"""
6871
self.ensure_one()
6972
return {
@@ -106,6 +109,6 @@ def save_metric_value(self, metric_interfaces):
106109
'value': eval_context['value'],
107110
'date_start': eval_context.get('date_start'),
108111
'date_end': eval_context.get('date_end'),
109-
'uom_id': uom.id
112+
'uom_id': uom.id,
110113
})],
111114
})

clouder_metric/models/clouder_metric_value.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# 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).
44

55
from odoo import fields, models
66

@@ -9,6 +9,7 @@ class ClouderMetricValue(models.Model):
99
""" It provides a record of metric values used in billing. """
1010

1111
_name = 'clouder.metric.value'
12+
_description = 'Clouder Metric Values'
1213

1314
interface_id = fields.Many2one(
1415
string='Interface',

clouder_metric/tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# Copyright 2017 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).
44

55
from . import test_clouder_metric_interface
66
from . import test_clouder_metric_type

clouder_metric/tests/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# Copyright 2017 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).
44

55
from odoo.tests.common import TransactionCase
66

clouder_metric/tests/test_clouder_metric_interface.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# Copyright 2017 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).
44

55
from .common import TestCommon
66

@@ -17,6 +17,3 @@ def test_name_get(self):
1717
(self.metric_interface.id, 'Test Metric - 7')
1818
]
1919
self.assertEqual(exp, self.metric_interface.name_get())
20-
21-
def test_save_metric_value(self):
22-
""" It should verify """

clouder_metric/tests/test_clouder_metric_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# Copyright 2017 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).
44

55
from odoo.exceptions import UserError, ValidationError
66

0 commit comments

Comments
 (0)