Merge lp:~unifield-team/unifield-wm/bklg-7 into lp:unifield-wm

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/bklg-7
Merge into: lp:unifield-wm
Diff against target: 264 lines (+168/-1)
6 files modified
account_mcdb/account_analytic_line.py (+135/-0)
account_mcdb/account_mcdb.py (+4/-1)
account_mcdb/account_mcdb_view.xml (+5/-0)
account_mcdb/account_move_line.py (+20/-0)
account_mcdb/mcdb_view_end.xml (+1/-0)
analytic_distribution/analytic_line_view.xml (+3/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/bklg-7
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+248507@code.launchpad.net
To post a comment you must log in.
lp:~unifield-team/unifield-wm/bklg-7 updated
2380. By Vincent GREINER

BKLG-7 [FIX] tools translate import was missing

2381. By Vincent GREINER

BKLG-7 [FIX] AJI m2o search field partner/emp tolerated ilike operator (as is default operator in search view) (but use internally = as m2o widget will display adoc value to search

2382. By Vincent GREINER

BKLG-7 [FIX] AJI third party search: manage ilike AND '=' search

2383. By Vincent GREINER

BKLG-7 [IMP] AJI search of third-party partner/emp: at project level if no third party m2o in AJI (sync case) only search the third-party non typed via partner_txt field

2384. By Vincent GREINER

BKLG-7 [FIX] AJI third party search, allow to search in partner_txt at project level when ilike operator is used

2385. By Vincent GREINER

BKLG-7 [FIX] AJI third party search, allow to search in partner_txt at project level when ilike operator is used

Unmerged revisions

2385. By Vincent GREINER

BKLG-7 [FIX] AJI third party search, allow to search in partner_txt at project level when ilike operator is used

2384. By Vincent GREINER

BKLG-7 [FIX] AJI third party search, allow to search in partner_txt at project level when ilike operator is used

2383. By Vincent GREINER

BKLG-7 [IMP] AJI search of third-party partner/emp: at project level if no third party m2o in AJI (sync case) only search the third-party non typed via partner_txt field

2382. By Vincent GREINER

BKLG-7 [FIX] AJI third party search: manage ilike AND '=' search

2381. By Vincent GREINER

BKLG-7 [FIX] AJI m2o search field partner/emp tolerated ilike operator (as is default operator in search view) (but use internally = as m2o widget will display adoc value to search

2380. By Vincent GREINER

BKLG-7 [FIX] tools translate import was missing

2379. By Vincent GREINER

BKLG-7 [FIX] AJI search view: analytical selector no journal search as internal transfer accounts have no AD

2378. By Vincent GREINER

BKLG-7 [IMP] AJI search view: partner and employee search fields (by third-party type)

2377. By Vincent GREINER

BKLG-7 [IMP] Analytical selector: AJI employee search field (as with partner_txt field we have not the third party type)

2376. By Vincent GREINER

BKLG-7 [IMP] Analytical selector: AJI partner search field from JI (as with partner_txt field we have not the partner type)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_mcdb/account_analytic_line.py'
2--- account_mcdb/account_analytic_line.py 2014-04-15 08:35:03 +0000
3+++ account_mcdb/account_analytic_line.py 2015-02-09 14:04:19 +0000
4@@ -25,6 +25,7 @@
5 from osv import fields
6 from time import strftime
7 from lxml import etree
8+from tools.translate import _
9
10 class account_analytic_line(osv.osv):
11 _name = 'account.analytic.line'
12@@ -69,6 +70,104 @@
13 # or output_currency field
14 res[ml.id]['output_currency'] = currency_id
15 return res
16+
17+ def _get_cheque_number(self, cr, uid, ids, name, args, context=None):
18+ res = {}
19+ if not ids:
20+ return res
21+ if isinstance(ids, (int, long)):
22+ ids = [ids]
23+ for self_br in self.browse(cr, uid, ids, context=context):
24+ res[self_br.id] = self_br.move_id and \
25+ self_br.move_id.cheque_number or ''
26+ return res
27+
28+ def _search_check_args(self, args, operators):
29+ """
30+ check domain for selector search fields
31+ domain should have only 1 tuple element
32+ :param args: search field domain to check
33+ :type args: list
34+ :param operators: allowed operator(s)
35+ :type operators: str/list
36+ """
37+ if not len(args):
38+ return []
39+ if len(args) != 1:
40+ msg = _("Domain %s not suported") % (str(args), )
41+ raise osv.except_osv(_('Error'), msg)
42+ if isinstance(operators, str):
43+ operators = [operators]
44+ if args[0][1] not in operators:
45+ msg = _("Operator '%s' not suported") % (args[0][1], )
46+ raise osv.except_osv(_('Error'), msg)
47+ if not args[0][2]:
48+ return []
49+ return True
50+
51+ def _search_cheque_number(self, cr, uid, ids, name, args, context=None):
52+ operator = 'ilike'
53+ args_check = self._search_check_args(args, [operator])
54+ if not args_check:
55+ return args_check
56+ m_ids = self.pool.get('account.move.line').search(cr, uid,
57+ [('cheque_number', operator, args[0][2])], context=context)
58+ return [('move_id', 'in', m_ids)] if m_ids else [('id', 'in', [])]
59+
60+ def _get_fake(self, cr, uid, ids, name, args, context=None):
61+ res = {}
62+ if not ids:
63+ return res
64+ if isinstance(ids, (int, long)):
65+ ids = [ids]
66+ for id in ids:
67+ res[id] = False
68+ return res
69+
70+ def _search_third_party(self, cr, uid, model, foreign_key, args,
71+ context=None):
72+ args_check = self._search_check_args(args, ['ilike', '='])
73+ if not args_check:
74+ return args_check
75+
76+ operator = args[0][1]
77+ # search for matching ilike third party
78+ if operator == 'ilike':
79+ # search operand <=> text search
80+ tp_ids = self.pool.get(model).search(cr, uid,
81+ [('name', operator, args[0][2])], context=context)
82+ else:
83+ # = operator: search operand <=> third party id
84+ tp_ids = [args[0][2], ] # search operand <=> text search
85+
86+ m_ids = False
87+ if tp_ids:
88+ m_ids = self.pool.get('account.move.line').search(cr, uid,
89+ [(foreign_key, 'in', tp_ids)], context=context)
90+ if not tp_ids or not m_ids:
91+ # at project level, search by partner_txt field as AJI could have
92+ # no thirdparty m2o link by sync (only partner_txt)
93+ if self.pool.get('res.users').browse(cr, uid, [uid],
94+ context=context)[0].company_id.instance_id.level == 'project':
95+ if operator == 'ilike':
96+ name = args[0][2]
97+ else:
98+ # operator '=': get name from id
99+ model_r = self.pool.get(model).read(cr, uid, [args[0][2]],
100+ ['name'], context=context)[0]
101+ if model_r and model_r['name']:
102+ name = model_r['name']
103+ if name:
104+ return [('partner_txt', operator, name)]
105+ return [('move_id', 'in', m_ids)] if m_ids else [('id', 'in', [])]
106+
107+ def _search_partner_id(self, cr, uid, ids, name, args, context=None):
108+ return self._search_third_party(cr, uid, 'res.partner', 'partner_id',
109+ args, context=context)
110+
111+ def _search_employee_id(self, cr, uid, ids, name, args, context=None):
112+ return self._search_third_party(cr, uid, 'hr.employee', 'employee_id',
113+ args, context=context)
114
115 _columns = {
116 'output_amount': fields.function(_get_output, string="Output amount", type='float', method=True, store=False, multi="analytic_output_currency"),
117@@ -76,6 +175,20 @@
118 'output_amount_credit': fields.function(_get_output, string="Output credit", type='float', method=True, store=False, multi="analytic_output_currency"),
119 'output_currency': fields.function(_get_output, string="Output curr.", type='many2one', relation='res.currency', method=True, store=False,
120 multi="analytic_output_currency"),
121+ # BKLG-7: selector move cheque number search and value
122+ 'cheque_number': fields.function(_get_cheque_number, type='char',
123+ method=True, string='Cheque Number',
124+ fnct_search=_search_cheque_number),
125+ # BKLG-7: selector move third-party partner search
126+ 'partner_id': fields.function(_get_fake,
127+ type='many2one', relation='res.partner',
128+ method=True, string='Partner',
129+ fnct_search=_search_partner_id),
130+ # BKLG-7: selector move third-party employee search
131+ 'employee_id': fields.function(_get_fake,
132+ type='many2one', relation='hr.employee',
133+ method=True, string='Employee',
134+ fnct_search=_search_employee_id),
135 }
136
137 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
138@@ -91,6 +204,28 @@
139 for field in element_fields:
140 tree.remove(field)
141 view['arch'] = etree.tostring(tree)
142+
143+ if view_type == 'tree' and \
144+ context.get('selector_display_cheque_number', False):
145+ # BKLG-7: cheque_number used in analytic selector: display it
146+ view['fields']['cheque_number'] = {
147+ 'function': '_get_cheque_number',
148+ 'fnct_search': '_search_cheque_number',
149+ 'type': 'char',
150+ 'string': 'Cheque Number',
151+ }
152+
153+ tree = etree.fromstring(view['arch'])
154+
155+ cheque_number_node = etree.Element('field', attrib={
156+ 'name': 'cheque_number',
157+ })
158+ # insert it after entry sequence
159+ es_node = tree.find('.//field[@name="entry_sequence"]')
160+ tree.insert(es_node.getparent().index(es_node) + 1,
161+ cheque_number_node)
162+
163+ view['arch'] = etree.tostring(tree)
164 return view
165
166 def copy(self, cr, uid, id, default=None, context=None):
167
168=== modified file 'account_mcdb/account_mcdb.py'
169--- account_mcdb/account_mcdb.py 2014-04-15 08:15:35 +0000
170+++ account_mcdb/account_mcdb.py 2015-02-09 14:04:19 +0000
171@@ -103,6 +103,7 @@
172 'display_free1': fields.boolean('Display Free 1?'),
173 'display_free2': fields.boolean('Display Free 2?'),
174 'user': fields.many2one('res.users', "User"),
175+ 'cheque_number': fields.char('Cheque Number', size=120), # BKLG-7
176 }
177
178 _defaults = {
179@@ -303,9 +304,11 @@
180 domain.append((m2o[1], '=', getattr(wiz, m2o[0]).id))
181 # Finally others fields
182 # LOOKS LIKE fields
183- for ll in [('ref', 'ref'), ('name', 'name')]:
184+ for ll in [('ref', 'ref'), ('name', 'name'), ('cheque_number', 'cheque_number')]:
185 if getattr(wiz, ll[0]):
186 domain.append((ll[1], 'ilike', '%%%s%%' % getattr(wiz, ll[0])))
187+ if ll[0] == 'cheque_number':
188+ context['selector_display_cheque_number'] = True
189 # DOCUMENT CODE fields
190 if wiz.document_code and wiz.document_code != '':
191 document_code_field = 'move_id.name'
192
193=== modified file 'account_mcdb/account_mcdb_view.xml'
194--- account_mcdb/account_mcdb_view.xml 2014-04-15 08:42:57 +0000
195+++ account_mcdb/account_mcdb_view.xml 2015-02-09 14:04:19 +0000
196@@ -286,6 +286,11 @@
197 <field name="reallocated" colspan="2"/>
198 <field name="reversed" colspan="2"/>
199 &currency;
200+ <group colspan="4" col="6">
201+ <separator string="Third Party" colspan="6"/>
202+ <field name="partner_id" colspan="2"/>
203+ <field name="employee_id" colspan="2" context="{'disrupt_inactive': True}"/>
204+ </group>
205 &end;
206 </form>
207 </field>
208
209=== modified file 'account_mcdb/account_move_line.py'
210--- account_mcdb/account_move_line.py 2014-09-19 09:51:58 +0000
211+++ account_mcdb/account_move_line.py 2015-02-09 14:04:19 +0000
212@@ -122,6 +122,26 @@
213 for field in element_fields:
214 tree.remove(field)
215 view['arch'] = etree.tostring(tree)
216+
217+ if view_type == 'tree' and \
218+ context.get('selector_display_cheque_number', False):
219+ # BKLG-7: cheque_number used in G/L selector: display it
220+ view['fields']['cheque_number'] = {
221+ 'type': 'char',
222+ 'string': 'Cheque Number',
223+ }
224+
225+ tree = etree.fromstring(view['arch'])
226+
227+ cheque_number_node = etree.Element('field', attrib={
228+ 'name': 'cheque_number',
229+ })
230+ # insert it after entry sequence
231+ es_node = tree.find('.//field[@name="move_id"]')
232+ tree.insert(es_node.getparent().index(es_node) + 1,
233+ cheque_number_node)
234+
235+ view['arch'] = etree.tostring(tree)
236 return view
237
238 account_move_line()
239
240=== modified file 'account_mcdb/mcdb_view_end.xml'
241--- account_mcdb/mcdb_view_end.xml 2012-03-21 17:48:57 +0000
242+++ account_mcdb/mcdb_view_end.xml 2015-02-09 14:04:19 +0000
243@@ -1,6 +1,7 @@
244 <separator string="Others" colspan="4"/>
245 <field name="ref"/>
246 <field name="name"/>
247+ <field name="cheque_number"/>
248 <separator string=" " colspan="4"/>
249 <button name="button_clear" type="object" string="Clear" icon="gtk-clear" colspan="2"/>
250 <button name="button_validate" type="object" string="Search" icon="gtk-find" colspan="2"/>
251
252=== modified file 'analytic_distribution/analytic_line_view.xml'
253--- analytic_distribution/analytic_line_view.xml 2014-01-14 17:29:00 +0000
254+++ analytic_distribution/analytic_line_view.xml 2015-02-09 14:04:19 +0000
255@@ -37,6 +37,9 @@
256 <field name="cost_center_id" invisible="not context.get('display_fp', False)"/>
257 <field name="account_id" domain="[('category', '=', context.get('categ', False) and context.get('categ') or 'FUNDING'), ('type', '!=', 'view')]"/>
258 <field name="is_reallocated"/>
259+ <newline/>
260+ <field name="partner_id"/>
261+ <field name="employee_id"/>
262 </xpath>
263 <xpath expr="/search/group[1]/field[@name='name']" position='after'>
264 <field name="ref"/>

Subscribers

People subscribed via source and target branches