Skip to content

Commit d6695f4

Browse files
committed
Merge pull request OCA#83 from dreispt/fix-reapply-sla
Fix bug on the Reapply of Contract SLAs. Closes OCA#93.
2 parents b7d5033 + 7b9300c commit d6695f4

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Diff for: project_sla/analytic_account.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ def _reapply_sla(self, cr, uid, ids, recalc_closed=False, context=None):
4444
ctrl_models = set([sla.control_model for sla in contract.sla_ids])
4545
for model_name in ctrl_models:
4646
model = self.pool[model_name]
47-
domain = [] if recalc_closed else [('stage_id.fold', '=', 1)]
47+
base = [] if recalc_closed else [('stage_id.fold', '=', 0)]
48+
doc_ids = []
4849
if 'analytic_account_id' in model._columns:
49-
domain.append(
50-
('analytic_account_id', '=', contract.id))
50+
domain = base + [
51+
('analytic_account_id', '=', contract.id)]
52+
doc_ids += model.search(cr, uid, domain, context=context)
5153
if 'project_id' in model._columns:
52-
domain.append(
53-
('project_id.analytic_account_id', '=', contract.id))
54-
55-
doc_ids = model.search(cr, uid, domain, context=context)
54+
domain = base + [
55+
('project_id.analytic_account_id', '=', contract.id)]
56+
doc_ids += model.search(cr, uid, domain, context=context)
5657
if doc_ids:
5758
model = self.pool[model_name]
5859
docs = model.browse(cr, uid, doc_ids, context=context)

Diff for: project_sla/test/project_sla.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
self.write(cr, uid, [ref('project.project_project_1_account_analytic_account')],
4646
{'sla_ids': [(4, ref('sla_response'))]})
4747
-
48-
Button to Reapply the SLA Definition
48+
Button to Reapply the SLA Definition on the Contract
4949
-
50-
!python {model: project.sla}: |
51-
self._reapply_slas(cr, uid, [ref('sla_resolution')], recalc_closed=True)
50+
!python {model: account.analytic.account}: |
51+
self._reapply_sla(cr, uid, [ref('project.project_project_1_account_analytic_account')], recalc_closed=True)
5252
-
5353
There should be two Service Level lines generated on the Issue
5454
-

0 commit comments

Comments
 (0)