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

Commit 3f9e1ff

Browse files
author
Ted Salmon
committed
EoD push 2017-03-07
1 parent 1444011 commit 3f9e1ff

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

clouder_metric/models/clouder_metric_interface.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ class ClouderMetricInterface(models.Model):
5252
interval_type = fields.Selection(
5353
related='cron_id.interval_type',
5454
)
55-
query_code = fields.Text(
55+
query_code = fields.Text()
56+
clouder_contract_id = fields.Many2one(
57+
string='Clouder Contract',
58+
comodel_name='clouder.contract',
59+
inverse_name='clouder_metric_ids'
5660
)
5761

62+
5863
@property
5964
@api.multi
6065
def metric_id(self):

sale_clouder/models/clouder_contract.py

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class ClouderContract(models.Model):
2323
require=True,
2424
ondelete='restrict',
2525
)
26+
clouder_metric_ids = fields.One2many(
27+
string='Clouder Metrics',
28+
comodel_name='clouder.metric.interface',
29+
inverse_name='clouder_contract_id'
30+
)
2631

2732
_sql_constraints = [
2833
('ref_contract_id_unique', 'UNIQUE(ref_contract_id)',
@@ -142,6 +147,10 @@ def _get_quantity_threshold(self, account_line, invoice):
142147
(float) Quantity to use on invoice line in the UOM defined on the
143148
``contract_line``.
144149
"""
150+
# Filter relevant metrics & return the right quanitity for the type
151+
metrics = self.clouder_metric_ids.search([
152+
('metric_start', '>=', None),
153+
])
145154
return account_line.quantity * account_line.uom_id
146155

147156
@api.multi
@@ -155,4 +164,8 @@ def _get_quantity_usage(self, account_line, invoice):
155164
(float) Quantity to use on invoice line in the UOM defined on the
156165
``contract_line``.
157166
"""
167+
# Filter relevant metrics & return the right quanitity for the type
168+
metrics = self.clouder_metric_ids.search([
169+
('metric_start', '>=', None),
170+
])
158171
return account_line.quantity * account_line.uom_id

0 commit comments

Comments
 (0)