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

Proposed by jftempo
Status: Merged
Merged at revision: 4419
Proposed branch: lp:~julie-w/unifield-server/US-2895
Merge into: lp:unifield-server
Diff against target: 126 lines (+97/-0)
3 files modified
bin/addons/account/account_move_line.py (+64/-0)
bin/addons/account/account_view.xml (+16/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+17/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-2895
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+327107@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeff Allen (jr.allen) wrote :

Wow, beautiful code! Thanks for this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/account/account_move_line.py'
2--- bin/addons/account/account_move_line.py 2017-05-12 09:58:49 +0000
3+++ bin/addons/account/account_move_line.py 2017-07-19 13:23:24 +0000
4@@ -1312,6 +1312,70 @@
5 move_obj.button_validate(cr,uid, [vals['move_id']], context)
6 return result
7
8+ def get_related_entries(self, cr, uid, ids, context=None):
9+ """
10+ Returns a JI view with all the JIs related to the selected one, i.e.:
11+ 1) those having the same Entry Sequence as the selected JI (including the selected JI itself)
12+ 2) those having the same reference as one of the JIs found in 1)
13+ 3) those being partially or totally reconciled with one of the JIs found in 1)
14+ 4) those whose reference contains EXACTLY the Entry Sequence of the selected JI
15+ 5) those having the same Entry Sequence as one of the JIs 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 JIs
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 Journal Item.'))
25+ ir_model_obj = self.pool.get('ir.model.data')
26+ related_amls = set()
27+ selected_aml = self.browse(cr, uid, ids[0], fields_to_fetch=['move_id'], context=context)
28+ selected_entry_seq = selected_aml.move_id.name
29+
30+ # get the ids of all the related JIs
31+ # JIs having the same Entry Seq = JIs of the same JE
32+ same_seq_ji_ids = self.search(cr, uid, [('move_id', '=', selected_aml.move_id.id)], order='NO_ORDER', context=context)
33+ related_amls.update(same_seq_ji_ids)
34+
35+ # check on ref and reconciliation
36+ set_of_refs = set()
37+ set_of_reconcile_ids = set()
38+ for aml in self.browse(cr, uid, same_seq_ji_ids,
39+ fields_to_fetch=['ref', 'reconcile_id', 'reconcile_partial_id'], context=context):
40+ aml.ref and set_of_refs.add(aml.ref)
41+ aml.reconcile_id and set_of_reconcile_ids.add(aml.reconcile_id.id)
42+ aml.reconcile_partial_id and set_of_reconcile_ids.add(aml.reconcile_partial_id.id)
43+
44+ domain_related_jis = ['|', '|', '|',
45+ '&', ('ref', 'in', list(set_of_refs)), ('ref', '!=', ''),
46+ ('ref', '=', selected_entry_seq),
47+ ('reconcile_id', 'in', list(set_of_reconcile_ids)),
48+ ('reconcile_partial_id', 'in', list(set_of_reconcile_ids))]
49+ related_ji_ids = self.search(cr, uid, domain_related_jis, order='NO_ORDER', context=context)
50+ related_amls.update(related_ji_ids)
51+
52+ # check on Entry Seq. (compared with those of the related JIs found)
53+ seq_je_ids = set(am.move_id.id for am in self.browse(cr, uid, related_ji_ids, fields_to_fetch=['move_id'], context=context))
54+ same_seq_related_ji_ids = self.search(cr, uid, [('move_id', 'in', list(seq_je_ids))], order='NO_ORDER', context=context)
55+ related_amls.update(same_seq_related_ji_ids)
56+
57+ domain = [('id', 'in', list(related_amls))]
58+ search_view_id = ir_model_obj.get_object_reference(cr, uid, 'account_mcdb', 'mcdb_view_account_move_line_filter')
59+ search_view_id = search_view_id and search_view_id[1] or False
60+ return {
61+ 'name': _('Related entries: Entry Sequence %s') % selected_entry_seq,
62+ 'type': 'ir.actions.act_window',
63+ 'res_model': 'account.move.line',
64+ 'view_type': 'form',
65+ 'view_mode': 'tree,form',
66+ 'search_view_id': [search_view_id],
67+ 'context': context,
68+ 'domain': domain,
69+ 'target': 'current',
70+ }
71+
72 account_move_line()
73
74 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
75
76=== modified file 'bin/addons/account/account_view.xml'
77--- bin/addons/account/account_view.xml 2017-05-26 10:03:57 +0000
78+++ bin/addons/account/account_view.xml 2017-07-19 13:23:24 +0000
79@@ -2736,6 +2736,22 @@
80 <field name="view_id" ref="account_cash_statement_graph"/>
81 <field name="act_window_id" ref="action_view_bank_statement_tree"/>
82 </record>
83+
84+ <record id="action_aml_related_entries" model="ir.actions.server">
85+ <field name="name">Related Entries</field>
86+ <field name="model_id" ref="model_account_move_line"/>
87+ <field name="state">code</field>
88+ <field name="code">action = obj.get_related_entries(context=context)</field>
89+ </record>
90+ <record id="ir_related_entries_search" model="ir.values">
91+ <field name="key2">client_action_multi</field>
92+ <field name="model">account.move.line</field>
93+ <field name="name">Related Entries</field>
94+ <field eval="'ir.actions.server,%d'%action_aml_related_entries" name="value"/>
95+ <field eval="True" name="object"/>
96+ <field name="sequence" eval="105"/>
97+ </record>
98+
99 <menuitem action="action_view_bank_statement_tree" id="journal_cash_move_lines"
100 parent="menu_finance_bank_and_cash"/>
101
102
103=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
104--- bin/addons/msf_profile/i18n/fr_MF.po 2017-07-06 14:23:27 +0000
105+++ bin/addons/msf_profile/i18n/fr_MF.po 2017-07-19 13:23:24 +0000
106@@ -98688,3 +98688,20 @@
107 #, python-format
108 msgid "Warning, you have removed header value source location! The lines will be re-set to have 'Other Supplier' as the source location. Please check this is correct!"
109 msgstr "Attention, vous avez supprimé la zone source d'en-tête! La zone source des lignes va être réinitialisée avec la valeur 'Autre Fournisseur'. Merci de vérifier leur cohérence!"
110+
111+#. module: account
112+#: model:ir.actions.server,name:account.action_aml_related_entries
113+msgid "Related Entries"
114+msgstr "Ecritures associées"
115+
116+#. module: account
117+#: code:addons/account/account_move_line.py:1369
118+#, python-format
119+msgid "Related entries: Entry Sequence %s"
120+msgstr "Ecritures associées : Entrée Comptable %s"
121+
122+#. module: account
123+#: code:addons/account/account_move_line.py:1330
124+#, python-format
125+msgid "The related entries feature can only be used with one Journal Item."
126+msgstr "La fonctionnalité des écritures associées ne peut être utilisée qu'avec une seule ligne d'écriture comptable."

Subscribers

People subscribed via source and target branches