Skip to content

Commit

Permalink
Merge branch '8.0-workflow-task-sbi' of github.com:acsone/acsone-addo…
Browse files Browse the repository at this point in the history
…ns into lis_master
  • Loading branch information
adrienpeiffer committed Feb 16, 2016
2 parents 1d4d760 + 04dad5c commit 6038fb2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion workflow_activity_action/models/activity_record_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import time

from openerp import api, fields, models
from openerp.tools import SUPERUSER_ID
from openerp.addons.base_suspend_security.base_suspend_security import\
Expand All @@ -13,10 +15,28 @@ class ActivityRecordRule(models.Model):
_inherit = 'ir.rule'
_name = 'activity.record.rule'

@api.model
def _eval_context(self):
"""Returns a dictionary to use as evaluation context for
ir.rule domains."""
return {'user': self.env.user,
'time': time}

@api.multi
def _domain_force_get(self):
eval_context = self._eval_context()
for rule in self:
if rule.domain_force:
rule.domain = expression.normalize_domain(
eval(rule.domain_force, eval_context))
else:
rule.domain = []

activity_id = fields.Many2one(comodel_name='workflow.activity',
string='Activity',
required=True)
model_id = fields.Many2one(required=False, readonly=True)
domain = fields.Binary(compute='_domain_force_get', string='Domain')

@api.model
def domain_get(self, model_name, activity_id):
Expand Down Expand Up @@ -53,7 +73,7 @@ def _compute_activity_rule_domain(self, activity_id):
for rule in self.sudo().browse(rule_ids):
# read 'domain' as UID to have the correct eval context for
# the rule.
rule_domain = rule.domain
rule_domain = rule.sudo(user=user.id).read(['domain'])[0]['domain']
dom = expression.normalize_domain(rule_domain)
for group in rule.groups:
if group in user.groups_id:
Expand Down
4 changes: 3 additions & 1 deletion workflow_activity_action/static/src/js/view_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ instance.web.form.FieldMany2ManyActionButtons = instance.web.form.AbstractField.
context['res_id'] = self.view.datarecord.id;
var model = new openerp.Model(openerp.session, self.field.relation);
model.call("do_action", [parseInt(button.dataset.id)], {"context": context}).then(function(result) {
self.view.do_action(result)
if (result) {
self.view.do_action(result);
}
self.view.reload();
});
} else {
Expand Down

0 comments on commit 6038fb2

Please sign in to comment.