Merge lp:~mallorymarcot/unifield-server/us-2015 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4092
Proposed branch: lp:~mallorymarcot/unifield-server/us-2015
Merge into: lp:unifield-server
Diff against target: 62 lines (+30/-1)
1 file modified
bin/addons/purchase_override/purchase.py (+30/-1)
To merge this branch: bzr merge lp:~mallorymarcot/unifield-server/us-2015
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+311929@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/purchase_override/purchase.py'
2--- bin/addons/purchase_override/purchase.py 2016-11-18 15:13:03 +0000
3+++ bin/addons/purchase_override/purchase.py 2016-11-28 13:21:39 +0000
4@@ -358,6 +358,34 @@
5
6 return res
7
8+
9+ def _src_customer_ref(self, cr, uid, obj, name, args, context=None):
10+ '''
11+ return a domain when user filter on the customer_ref field
12+ '''
13+ if not args:
14+ return []
15+
16+ pol_obj = self.pool.get('purchase.order.line')
17+ so_obj = self.pool.get('sale.order')
18+ proc_obj = self.pool.get('procurement.order')
19+
20+ po_ids = []
21+ for tu in args:
22+ if tu[1] == 'ilike' or tu[1] == 'not ilike' or tu[1] == '=' or tu[1] == '!=':
23+ so_ids = so_obj.search(cr, uid, [('client_order_ref', tu[1], tu[2])], context=context)
24+ proc_ids = proc_obj.search(cr, uid, [('sale_id', 'in', so_ids)], context=context)
25+ pol_ids = pol_obj.search(cr, uid, [('procurement_id', 'in', proc_ids)], context=context)
26+ po_ids = set()
27+ for pol in pol_obj.read(cr, uid, pol_ids, ['order_id'], context=context):
28+ if pol.get('order_id'):
29+ po_ids.add(pol['order_id'][0])
30+ else:
31+ raise osv.except_osv(_('Error'), _('Bad operator : You can only use \'=\', \'!=\', \'ilike\' or \'not ilike\' as operator'))
32+
33+ return [('id', 'in', list(po_ids))]
34+
35+
36 def _get_customer_ref(self, cr, uid, ids, field_name, args, context=None):
37 '''
38 Return a concatenation of the PO's customer references from the project (case of procurement request)
39@@ -379,6 +407,7 @@
40
41 return res
42
43+
44 def _get_line_count(self, cr, uid, ids, field_name, args, context=None):
45 '''
46 Return the number of line(s) for the PO
47@@ -402,7 +431,6 @@
48 return res
49
50
51-
52 _columns = {
53 'order_type': fields.selection([('regular', 'Regular'), ('donation_exp', 'Donation before expiry'),
54 ('donation_st', 'Standard donation'), ('loan', 'Loan'),
55@@ -487,6 +515,7 @@
56 'po_confirmed': fields.boolean('PO', readonly=True),
57 'customer_ref': fields.function(
58 _get_customer_ref,
59+ fnct_search=_src_customer_ref,
60 method=True,
61 string='Customer Ref.',
62 type='text',

Subscribers

People subscribed via source and target branches