diff --git a/addons/analytic/models/analytic.py b/addons/analytic/models/analytic.py index 925f628efcc..199ef9da00c 100644 --- a/addons/analytic/models/analytic.py +++ b/addons/analytic/models/analytic.py @@ -305,20 +305,22 @@ class account_analytic_account(osv.osv): args=[] if context is None: context={} + account_ids = [] if name: account_ids = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context) if not account_ids: dom = [] - for name2 in name.split('/'): - name = name2.strip() - account_ids = self.search(cr, uid, dom + [('name', operator, name)], limit=limit, context=context) - if not account_ids: break - dom = [('parent_id','in',account_ids)] - if account_ids and args: - # final filtering according to domain (args) - account_ids = self.search(cr, uid, [('id', 'in', account_ids)] + args, limit=limit, context=context) - else: - account_ids = self.search(cr, uid, args, limit=limit, context=context) + if '/' in name: + for name2 in name.split('/'): + # intermediate search without limit and args - could be expensive for large tables if `name` is not selective + account_ids = self.search(cr, uid, dom + [('name', operator, name2.strip())], limit=None, context=context) + if not account_ids: break + dom = [('parent_id','in',account_ids)] + if account_ids and args: + # final filtering according to domain (args)4 + account_ids = self.search(cr, uid, [('id', 'in', account_ids)] + args, limit=limit, context=context) + if not account_ids: + return super(account_analytic_account, self).name_search(cr, uid, name, args, operator=operator, context=context, limit=limit) return self.name_get(cr, uid, account_ids, context=context) class account_analytic_line(osv.osv): diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index cc5b5da7a8f..7180d305e29 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -126,15 +126,24 @@ class base_action_rule(osv.osv): ir_filter = self.pool['ir.filters'].browse(cr, uid, filter_id, context=context) return {'value': {'filter_domain': ir_filter.domain}} + def _get_eval_context(self, cr, uid, context=None): + """ Prepare the context used when evaluating python code + :returns: dict -- evaluation context given to (safe_)eval """ + return { + 'time': time, + 'user': self.pool['res.users'].browse(cr, uid, uid, context=context), + } + def _filter(self, cr, uid, action, action_filter, record_ids, domain=False, context=None): """ Filter the list record_ids that satisfy the domain or the action filter. """ if record_ids and (domain is not False or action_filter): + eval_context = self._get_eval_context(cr, uid, context=context) if domain is not False: - new_domain = [('id', 'in', record_ids)] + eval(domain) + new_domain = [('id', 'in', record_ids)] + eval(domain, eval_context) ctx = context elif action_filter: assert action.model == action_filter.model_id, "Filter model different from action rule model" - new_domain = [('id', 'in', record_ids)] + eval(action_filter.domain) + new_domain = [('id', 'in', record_ids)] + eval(action_filter.domain, eval_context) ctx = dict(context or {}) ctx.update(eval(action_filter.context)) record_ids = self.pool[action.model].search(cr, uid, new_domain, context=ctx) @@ -309,6 +318,7 @@ class base_action_rule(osv.osv): # retrieve all the action rules to run based on a timed condition action_dom = [('kind', '=', 'on_time')] action_ids = self.search(cr, uid, action_dom, context=dict(context, active_test=True)) + eval_context = self._get_eval_context(cr, uid, context=context) for action in self.browse(cr, uid, action_ids, context=context): now = datetime.now() if action.last_run: @@ -320,9 +330,9 @@ class base_action_rule(osv.osv): domain = [] ctx = dict(context) if action.filter_domain is not False: - domain = eval(action.filter_domain) + domain = eval(action.filter_domain, eval_context) elif action.filter_id: - domain = eval(action.filter_id.domain) + domain = eval(action.filter_id.domain, eval_context) ctx.update(eval(action.filter_id.context)) if 'lang' not in ctx: # Filters might be language-sensitive, attempt to reuse creator lang diff --git a/addons/claim_from_delivery/claim_delivery_view.xml b/addons/claim_from_delivery/claim_delivery_view.xml index f676b03ac47..58bc536db36 100644 --- a/addons/claim_from_delivery/claim_delivery_view.xml +++ b/addons/claim_from_delivery/claim_delivery_view.xml @@ -13,6 +13,7 @@ crm.claim.from_delivery.form stock.picking +
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 3fad50e1595..37b4a8e84b1 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -327,7 +327,7 @@
- oe_kanban_text_red + oe_kanban_text_red : diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index 844e755f953..b5740c310e8 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -41,8 +41,12 @@ class res_partner(osv.osv): } except: pass + return res + + def _phonecall_count(self, cr, uid, ids, field_name, arg, context=None): + res = {} for partner in self.browse(cr, uid, ids, context): - res[partner.id]['phonecall_count'] = len(partner.phonecall_ids) + res[partner.id] = len(partner.phonecall_ids) return res _columns = { @@ -55,7 +59,7 @@ class res_partner(osv.osv): 'Phonecalls'), 'opportunity_count': fields.function(_opportunity_meeting_phonecall_count, string="Opportunity", type='integer', multi='opp_meet'), 'meeting_count': fields.function(_opportunity_meeting_phonecall_count, string="# Meetings", type='integer', multi='opp_meet'), - 'phonecall_count': fields.function(_opportunity_meeting_phonecall_count, string="Phonecalls", type="integer", multi='opp_meet'), + 'phonecall_count': fields.function(_phonecall_count, string="Phonecalls", type="integer"), } def redirect_partner_form(self, cr, uid, partner_id, context=None): diff --git a/addons/crm/res_partner_view.xml b/addons/crm/res_partner_view.xml index cb9536a8097..72e2407179d 100644 --- a/addons/crm/res_partner_view.xml +++ b/addons/crm/res_partner_view.xml @@ -103,6 +103,21 @@ context="{'partner_id': active_id}"> + + + + + + + + view.res.partner.form.crm.inherited.calls + res.partner + + + + + +