~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to account_mcdb/mass_reallocation_search.py

  • Committer: jf
  • Date: 2012-11-29 13:00:27 UTC
  • mfrom: (1287.9.8 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20121129130027-564r4yns8t5d2v7d
UTP-368 [FIX] Shouldn't be possible to source a non-stockable product to stock in the order sourcing tool (fix unit test)
lp:~unifield-team/unifield-wm/utp-368

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
            context = {}
38
38
        if isinstance(ids, (int, long)):
39
39
            ids = [ids]
 
40
        # Prepare some values
 
41
        valid_ids = []
40
42
        # Only process first id
41
43
        account = self.pool.get('account.analytic.account').browse(cr, uid, ids, context=context)[0]
42
44
        if account.category != 'FUNDING':
47
49
            search.append(('date', '>=', account.date_start))
48
50
        if account.date:
49
51
            search.append(('date', '<=', account.date))
50
 
        # Search default MSF Private Fund analytic account
51
 
        try:
52
 
            fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]
53
 
        except ValueError:
54
 
            fp_id = 0
55
 
        if account.id != fp_id:
56
 
            if account.tuple_destination_account_ids:
57
 
                search.append(('is_fp_compat_with', '=', account.id))
58
 
            else:
59
 
                # trick to avoid problem with FP that have NO destination link. So we need to search a "False" Destination.
60
 
                search.append(('destination_id', '=', 0))
61
 
            if account.cost_center_ids:
62
 
                search.append(('cost_center_id', 'in', [x.id for x in account.cost_center_ids]))
63
 
            else:
64
 
                # trick to avoid problem with FP that have NO CC.
65
 
                search.append(('cost_center_id', '=', 0))
 
52
        if account.tuple_destination_account_ids:
 
53
            search.append(('is_fp_compat_with', '=', account.id))
 
54
        else:
 
55
            # trick to avoid problem with FP that have NO destination link. So we need to search a "False" Destination.
 
56
            search.append(('destination_id', '=', 0))
 
57
        if account.cost_center_ids:
 
58
            search.append(('cost_center_id', 'in', [x.id for x in account.cost_center_ids]))
 
59
        else:
 
60
            # trick to avoid problem with FP that have NO CC.
 
61
            search.append(('cost_center_id', '=', 0))
66
62
        for criterium in [('account_id', '!=', account.id), ('journal_id.type', '!=', 'engagement'), ('is_reallocated', '=', False), ('is_reversal', '=', False)]:
67
63
            search.append(criterium)
68
64
        search.append(('contract_open','=', True))