Merge lp:~julie-w/unifield-server/US-4426 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4914
Proposed branch: lp:~julie-w/unifield-server/US-4426
Merge into: lp:unifield-server
Diff against target: 173 lines (+103/-11)
3 files modified
bin/addons/account/account_analytic_line.py (+78/-0)
bin/addons/account/account_view.xml (+17/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+8/-11)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4426
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+345488@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/account/account_analytic_line.py'
2--- bin/addons/account/account_analytic_line.py 2016-05-26 13:18:50 +0000
3+++ bin/addons/account/account_analytic_line.py 2018-05-14 07:59:09 +0000
4@@ -142,8 +142,86 @@
5 return res
6 return False
7
8+ def get_aal_related_entries(self, cr, uid, ids, context=None):
9+ """
10+ Returns a view with all the Analytic Lines related to the selected one, i.e.:
11+ 1) those having the same Entry Sequence as the selected one (including the selected line itself)
12+ 2) those having the same reference as one of the lines found in 1)
13+ 3) those having an Entry Sequence matching exactly with the reference of one of the lines found in 1)
14+ 4) those whose reference contains EXACTLY the Entry Sequence of the selected line
15+ 5) those having the same Entry Sequence as one of the lines found in 2), 3), or 4)
16+ """
17+ if context is None:
18+ context = {}
19+ if isinstance(ids, (int, long)):
20+ ids = [ids]
21+ active_ids = context.get('active_ids', []) # to detect if the user has selected several lines
22+ if len(ids) != 1 or len(active_ids) > 1:
23+ raise osv.except_osv(_('Error'),
24+ _('The related entries feature can only be used with one Analytic Line.'))
25+ ir_model_obj = self.pool.get('ir.model.data')
26+ analytic_acc_obj = self.pool.get('account.analytic.account')
27+ related_aals = set()
28+
29+ selected_aal = self.browse(cr, uid, ids[0], fields_to_fetch=['entry_sequence', 'account_id'], context=context)
30+ selected_entry_seq = selected_aal.entry_sequence or ''
31+ selected_category = selected_aal.account_id.category or ''
32+
33+ # get the ids of all the related lines
34+ analytic_account_ids = analytic_acc_obj.search(cr, uid, [('category', '=', selected_category)],
35+ order='NO_ORDER', context=context)
36+ # lines having the same Entry Sequence
37+ same_seq_domain = [('entry_sequence', '=', selected_entry_seq),
38+ ('account_id', 'in', analytic_account_ids)]
39+ same_seq_line_ids = self.search(cr, uid, same_seq_domain, order='NO_ORDER', context=context)
40+ related_aals.update(same_seq_line_ids)
41+
42+ # check on ref
43+ set_of_refs = set()
44+ for aal in self.browse(cr, uid, same_seq_line_ids, fields_to_fetch=['ref'], context=context):
45+ aal.ref and set_of_refs.add(aal.ref)
46+
47+ domain_related_lines = ['&', '|', '|',
48+ '&', ('ref', 'in', list(set_of_refs)), ('ref', '!=', ''),
49+ ('entry_sequence', 'in', list(set_of_refs)),
50+ ('ref', '=', selected_entry_seq),
51+ ('account_id', 'in', analytic_account_ids)]
52+ related_line_ids = self.search(cr, uid, domain_related_lines, order='NO_ORDER', context=context)
53+ related_aals.update(related_line_ids)
54+
55+ # check on Entry Seq. (compared with those of the related lines found)
56+ aal_seqs = set(aal.entry_sequence for aal in self.browse(cr, uid, related_line_ids,
57+ fields_to_fetch=['entry_sequence'], context=context))
58+ same_seq_related_line_domain = [('entry_sequence', 'in', list(aal_seqs)),
59+ ('account_id', 'in', analytic_account_ids)]
60+ same_seq_related_line_ids = self.search(cr, uid, same_seq_related_line_domain, order='NO_ORDER', context=context)
61+ related_aals.update(same_seq_related_line_ids)
62+
63+ domain = [('id', 'in', list(related_aals))]
64+ # same views whatever the category displayed (FP or Free1/2)
65+ view_id = ir_model_obj.get_object_reference(cr, uid, 'account', 'view_account_analytic_line_tree')
66+ view_id = view_id and view_id[1] or False
67+ search_view_id = ir_model_obj.get_object_reference(cr, uid, 'account', 'view_account_analytic_line_filter')
68+ search_view_id = search_view_id and search_view_id[1] or False
69+ if selected_category == 'FUNDING':
70+ context.update({'display_fp': True})
71+ return {
72+ 'name': _('Related entries: Entry Sequence %s') % selected_entry_seq,
73+ 'type': 'ir.actions.act_window',
74+ 'res_model': 'account.analytic.line',
75+ 'view_type': 'form',
76+ 'view_mode': 'tree,form',
77+ 'view_id': [view_id],
78+ 'search_view_id': [search_view_id],
79+ 'context': context,
80+ 'domain': domain,
81+ 'target': 'current',
82+ }
83+
84+
85 account_analytic_line()
86
87+
88 class res_partner(osv.osv):
89 """ Inherits partner and adds contract information in the partner form """
90 _inherit = 'res.partner'
91
92=== modified file 'bin/addons/account/account_view.xml'
93--- bin/addons/account/account_view.xml 2017-09-29 09:55:29 +0000
94+++ bin/addons/account/account_view.xml 2018-05-14 07:59:09 +0000
95@@ -2745,6 +2745,7 @@
96 <field name="act_window_id" ref="action_view_bank_statement_tree"/>
97 </record>
98
99+ <!-- JI RELATED ENTRIES -->
100 <record id="action_aml_related_entries" model="ir.actions.server">
101 <field name="name">Related Entries</field>
102 <field name="model_id" ref="model_account_move_line"/>
103@@ -2760,6 +2761,22 @@
104 <field name="sequence" eval="105"/>
105 </record>
106
107+ <!-- AJI RELATED ENTRIES -->
108+ <record id="action_aal_related_entries" model="ir.actions.server">
109+ <field name="name">Related Entries</field>
110+ <field name="model_id" ref="model_account_analytic_line"/>
111+ <field name="state">code</field>
112+ <field name="code">action = obj.get_aal_related_entries(context=context)</field>
113+ </record>
114+ <record id="ir_aal_related_entries_search" model="ir.values">
115+ <field name="key2">client_action_multi</field>
116+ <field name="model">account.analytic.line</field>
117+ <field name="name">related_entries</field>
118+ <field eval="'ir.actions.server,%d'%action_aal_related_entries" name="value"/>
119+ <field eval="True" name="object"/>
120+ <field name="sequence" eval="105"/>
121+ </record>
122+
123 <menuitem action="action_view_bank_statement_tree" id="journal_cash_move_lines"
124 parent="menu_finance_bank_and_cash"/>
125
126
127=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
128--- bin/addons/msf_profile/i18n/fr_MF.po 2018-04-27 09:58:55 +0000
129+++ bin/addons/msf_profile/i18n/fr_MF.po 2018-05-14 07:59:09 +0000
130@@ -18660,6 +18660,7 @@
131
132 #. module: account
133 #: model:ir.actions.server,name:account.action_aml_related_entries
134+#: model:ir.actions.server,name:account.action_aal_related_entries
135 msgid "Related Entries"
136 msgstr "Ecritures associées"
137
138@@ -47968,6 +47969,7 @@
139
140 #. module: account
141 #: code:addons/account/account_move_line.py:1366
142+#: code:addons/account/account_analytic_line.py:196
143 #, python-format
144 msgid "Related entries: Entry Sequence %s"
145 msgstr "Ecritures associées : Entrée Comptable %s"
146@@ -104687,17 +104689,6 @@
147 msgstr "Écritures ouvertes à"
148
149 #. module: account
150-#: model:ir.actions.server,name:account.action_aml_related_entries
151-msgid "Related Entries"
152-msgstr "Ecritures associées"
153-
154-#. module: account
155-#: code:addons/account/account_move_line.py:1369
156-#, python-format
157-msgid "Related entries: Entry Sequence %s"
158-msgstr "Ecritures associées : Entrée Comptable %s"
159-
160-#. module: account
161 #: code:addons/account/account_move_line.py:1330
162 #, python-format
163 msgid "The related entries feature can only be used with one Journal Item."
164@@ -107673,3 +107664,9 @@
165 #: sql_constraint:account.move.line:0
166 msgid "Wrong credit or debit value in booking currency!"
167 msgstr "Valeur de crédit ou débit erronée en devise d'enregistrement !"
168+
169+#. module: account
170+#: code:addons/account/account_analytic_line.py:161
171+#, python-format
172+msgid "The related entries feature can only be used with one Analytic Line."
173+msgstr "La fonctionnalité des écritures associées ne peut être utilisée qu'avec une seule Ligne Analytique."

Subscribers

People subscribed via source and target branches