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

Proposed by jftempo
Status: Merged
Merged at revision: 3746
Proposed branch: lp:~julie-w/unifield-server/US-970
Merge into: lp:unifield-server
Diff against target: 271 lines (+143/-6)
3 files modified
bin/addons/register_accounting/account_bank_statement.py (+18/-0)
bin/addons/register_accounting/report/fully_report_xls.mako (+102/-6)
bin/addons/register_accounting/report/report_fully_report.py (+23/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-970
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+293503@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/register_accounting/account_bank_statement.py'
2--- bin/addons/register_accounting/account_bank_statement.py 2016-04-04 07:54:49 +0000
3+++ bin/addons/register_accounting/account_bank_statement.py 2016-05-02 07:55:26 +0000
4@@ -1020,6 +1020,23 @@
5 res[absl.id] = aal_obj.get_corrections_history(cr, uid, aal_ids, context=context)
6 return res
7
8+ def _get_free_analytic_lines(self, cr, uid, ids, field_name=None, args=None, context=None):
9+ """
10+ Get analytic lines Free 1 and Free 2 linked to the given register lines
11+ """
12+ if not context:
13+ context = {}
14+ res = {}
15+ aal_obj = self.pool.get('account.analytic.line')
16+ for absl in self.browse(cr, uid, ids, context=context):
17+ # UTP-1055: In case of Cash Advance register line, we don't need to see all other advance lines allocation (analytic lines).
18+ # So we keep only analytic lines with the same "name" than register line
19+ aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('move_id.move_id', 'in', self._get_move_ids(cr, uid, [absl.id], context=context)),
20+ ('account_id.category', 'in', ['FREE1', 'FREE2']), ('name', '=ilike', '%%%s' % absl.name)])
21+ # Then retrieve all corrections/reversals from them
22+ res[absl.id] = aal_obj.get_corrections_history(cr, uid, aal_ids, context=context)
23+ return res
24+
25 def _check_red_on_supplier(self, cr, uid, ids, name, arg, context=None):
26 result = {}
27 for id in ids:
28@@ -1076,6 +1093,7 @@
29 ('transfer', 'Internal Transfer'), ('transfer_same', 'Internal Transfer (same currency)'), ('advance', 'Operational Advance'),
30 ('payroll', 'Third party required - Payroll'), ('down_payment', 'Down payment'), ('donation', 'Donation')] , readonly=True),
31 'fp_analytic_lines': fields.function(_get_fp_analytic_lines, type="one2many", obj="account.analytic.line", method=True, string="Analytic lines linked to the given register line(s). Correction(s) included."),
32+ 'free_analytic_lines': fields.function(_get_free_analytic_lines, type="one2many", obj="account.analytic.line", method=True, string="Analytic lines Free 1 and Free 2 linked to the given register line(s). Correction(s) included."),
33 'red_on_supplier': fields.function(_check_red_on_supplier, method=True, type="boolean", string="Supplier flag", store=False, readonly=True, multi="m"),
34 'journal_id': fields.related('statement_id','journal_id', string="Journal", type='many2one', relation='account.journal', readonly=True),
35 'direct_invoice_move_id': fields.many2one('account.move', 'Direct Invoice Move', readonly=True, help="This field have been added to get the move that comes from the direct invoice because after synchronization some lines lost the direct invoice link. And so we can't see which move have been linked to the invoice in case the register line is temp posted."),
36
37=== modified file 'bin/addons/register_accounting/report/fully_report_xls.mako'
38--- bin/addons/register_accounting/report/fully_report_xls.mako 2015-08-28 15:38:30 +0000
39+++ bin/addons/register_accounting/report/fully_report_xls.mako 2016-05-02 07:55:26 +0000
40@@ -377,11 +377,12 @@
41 <Column ss:Width="155"/>
42 <Column ss:Width="135"/>
43 <Column ss:Width="170"/>
44+ <Column ss:Width="170"/>
45 <Column ss:Width="55"/>
46 <Column ss:Width="65"/>
47 <Column ss:Width="60"/>
48 <Column ss:Width="66"/>
49- <Column ss:Width="72" ss:Span="2"/>
50+ <Column ss:Width="72" ss:Span="4"/>
51 <Column ss:Width="36" ss:Span="1"/>
52 <Row ss:Height="19.3039">
53 <Cell ss:MergeAcross="3" ss:StyleID="title">
54@@ -467,6 +468,9 @@
55 <Cell ss:StyleID="column_headers">
56 <Data ss:Type="String">Ref</Data>
57 </Cell>
58+ <Cell ss:StyleID="column_headers">
59+ <Data ss:Type="String">Free Ref</Data>
60+ </Cell>
61 % if o.journal_id.type == 'cheque':
62 <Cell ss:StyleID="column_headers">
63 <Data ss:Type="String">Chk num</Data>
64@@ -494,6 +498,12 @@
65 <Data ss:Type="String">FP</Data>
66 </Cell>
67 <Cell ss:StyleID="column_headers">
68+ <Data ss:Type="String">Free 1</Data>
69+ </Cell>
70+ <Cell ss:StyleID="column_headers">
71+ <Data ss:Type="String">Free 2</Data>
72+ </Cell>
73+ <Cell ss:StyleID="column_headers">
74 <Data ss:Type="String">Rec?</Data>
75 </Cell>
76 <Cell ss:StyleID="column_headers">
77@@ -520,6 +530,9 @@
78 <Cell ss:StyleID="centre">
79 <Data ss:Type="String">${getRegRef(line) or ''|x}</Data>
80 </Cell>
81+ <Cell ss:StyleID="centre">
82+ <Data ss:Type="String"></Data>
83+ </Cell>
84 % if o.journal_id.type == 'cheque':
85 <Cell ss:StyleID="centre">
86 <Data ss:Type="String">${line.cheque_number}</Data>
87@@ -547,6 +560,12 @@
88 <Data ss:Type="String"></Data>
89 </Cell>
90 <Cell ss:StyleID="centre">
91+ <Data ss:Type="String"></Data>
92+ </Cell>
93+ <Cell ss:StyleID="centre">
94+ <Data ss:Type="String"></Data>
95+ </Cell>
96+ <Cell ss:StyleID="centre">
97 <Data ss:Type="String">${line.reconciled and 'X' or ''|x}</Data>
98 </Cell>
99 <Cell ss:StyleID="centre">
100@@ -575,6 +594,9 @@
101 <Cell ss:StyleID="left">
102 <Data ss:Type="String">${inv_line.move_id and inv_line.move_id.name or hasattr(inv_line, 'reference') and inv_line.reference or ''|x}</Data>
103 </Cell>
104+ <Cell ss:StyleID="left">
105+ <Data ss:Type="String">${getFreeRef(inv_line) or ''|x}</Data>
106+ </Cell>
107 % if o.journal_id.type == 'cheque':
108 <Cell ss:StyleID="left">
109 <Data ss:Type="String"></Data>
110@@ -607,9 +629,9 @@
111 %>
112 <Row>
113 % if o.journal_id.type == 'cheque':
114+ <Cell ss:Index="9" ss:StyleID="${line_color}_ana_left">
115+ % else:
116 <Cell ss:Index="8" ss:StyleID="${line_color}_ana_left">
117- % else:
118- <Cell ss:Index="7" ss:StyleID="${line_color}_ana_left">
119 % endif
120 <Data ss:Type="String">${ana_line.general_account_id.code + ' ' + ana_line.general_account_id.name|x}</Data>
121 </Cell>
122@@ -629,7 +651,15 @@
123 <Data ss:Type="String">${ana_line.cost_center_id and ana_line.cost_center_id.code or ''|x}</Data>
124 </Cell>
125 <Cell ss:StyleID="${line_color}_ana_left">
126- <Data ss:Type="String">${ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
127+ <Data ss:Type="String">${not ana_line.free_account and ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
128+ </Cell>
129+ <Cell ss:StyleID="${line_color}_ana_left">
130+ <Data ss:Type="String">${ana_line.distrib_line_id and ana_line.distrib_line_id._name == 'free.1.distribution.line' and \
131+ ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
132+ </Cell>
133+ <Cell ss:StyleID="${line_color}_ana_left">
134+ <Data ss:Type="String">${ana_line.distrib_line_id and ana_line.distrib_line_id._name == 'free.2.distribution.line' and \
135+ ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
136 </Cell>
137 <Cell ss:StyleID="${line_color}_ana_left">
138 <Data ss:Type="String">${(ana_line.is_reallocated and _('Corrected')) or (ana_line.is_reversal and _('Reversal')) or ''}</Data>
139@@ -657,11 +687,12 @@
140 line_color = 'red'
141 endif
142 %>
143+% if not ana_line.free_account:
144 <Row>
145 % if o.journal_id.type == 'cheque':
146+ <Cell ss:Index="9" ss:StyleID="${line_color}_ana_left">
147+ % else:
148 <Cell ss:Index="8" ss:StyleID="${line_color}_ana_left">
149- % else:
150- <Cell ss:Index="7" ss:StyleID="${line_color}_ana_left">
151 % endif
152 <Data ss:Type="String">${ana_line.general_account_id.code + ' ' + ana_line.general_account_id.name|x}</Data>
153 </Cell>
154@@ -684,12 +715,77 @@
155 <Data ss:Type="String">${ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
156 </Cell>
157 <Cell ss:StyleID="${line_color}_ana_left">
158+ <Data ss:Type="String"></Data>
159+ </Cell>
160+ <Cell ss:StyleID="${line_color}_ana_left">
161+ <Data ss:Type="String"></Data>
162+ </Cell>
163+ <Cell ss:StyleID="${line_color}_ana_left">
164 <Data ss:Type="String">${(ana_line.is_reallocated and _('Corrected')) or (ana_line.is_reversal and _('Reversal')) or ''}</Data>
165 </Cell>
166 </Row>
167+% endif
168 % endfor
169 % endif
170
171+<!-- Display analytic lines Free 1 and Free 2 linked to this register line -->
172+<%
173+a_lines = False
174+if line.free_analytic_lines and not line.invoice_id and not line.imported_invoice_line_ids:
175+ a_lines = line.free_analytic_lines
176+%>
177+% if a_lines:
178+% for ana_line in sorted(a_lines, key=lambda x: x.id):
179+<%
180+line_color = 'blue'
181+if ana_line.is_reallocated:
182+ line_color = 'darkblue'
183+elif ana_line.is_reversal:
184+ line_color = 'green'
185+elif ana_line.last_corrected_id:
186+ line_color = 'red'
187+endif
188+%>
189+ <Row>
190+ % if o.journal_id.type == 'cheque':
191+ <Cell ss:Index="9" ss:StyleID="${line_color}_ana_left">
192+ % else:
193+ <Cell ss:Index="8" ss:StyleID="${line_color}_ana_left">
194+ % endif
195+ <Data ss:Type="String">${ana_line.general_account_id.code + ' ' + ana_line.general_account_id.name|x}</Data>
196+ </Cell>
197+ <Cell>
198+ <Data ss:Type="String"></Data>
199+ </Cell>
200+ <Cell>
201+ <Data ss:Type="String"></Data>
202+ </Cell>
203+ <Cell ss:StyleID="${line_color}_ana_amount">
204+ <Data ss:Type="Number">${ana_line.amount_currency}</Data>
205+ </Cell>
206+ <Cell ss:StyleID="${line_color}_ana_left">
207+ <Data ss:Type="String"></Data>
208+ </Cell>
209+ <Cell ss:StyleID="${line_color}_ana_left">
210+ <Data ss:Type="String"></Data>
211+ </Cell>
212+ <Cell ss:StyleID="${line_color}_ana_left">
213+ <Data ss:Type="String"></Data>
214+ </Cell>
215+ <Cell ss:StyleID="${line_color}_ana_left">
216+ <Data ss:Type="String">${ana_line.distrib_line_id and ana_line.distrib_line_id._name == 'free.1.distribution.line' and \
217+ ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
218+ </Cell>
219+ <Cell ss:StyleID="${line_color}_ana_left">
220+ <Data ss:Type="String">${ana_line.distrib_line_id and ana_line.distrib_line_id._name == 'free.2.distribution.line' and \
221+ ana_line.account_id and ana_line.account_id.code or ''|x}</Data>
222+ </Cell>
223+ <Cell ss:StyleID="${line_color}_ana_left">
224+ <Data ss:Type="String">${(ana_line.is_reallocated and _('Corrected')) or (ana_line.is_reversal and _('Reversal')) or ''}</Data>
225+ </Cell>
226+ </Row>
227+% endfor
228+% endif
229
230 % endfor
231 </Table>
232
233=== modified file 'bin/addons/register_accounting/report/report_fully_report.py'
234--- bin/addons/register_accounting/report/report_fully_report.py 2015-08-24 08:38:51 +0000
235+++ bin/addons/register_accounting/report/report_fully_report.py 2016-05-02 07:55:26 +0000
236@@ -31,6 +31,7 @@
237 'getAnalyticLines': self.getAnalyticLines,
238 'getImportedMoveLines': self.getImportedMoveLines,
239 'getRegRef': self.getRegRef,
240+ 'getFreeRef': self.getFreeRef,
241 })
242
243 def getRegRef(self, reg_line):
244@@ -137,5 +138,27 @@
245 res = al_obj.browse(self.cr, self.uid, al_ids)
246 return res
247
248+ def getFreeRef(self, acc_move_line):
249+ '''
250+ Return the "manual" invoice reference associated with the account move line if it exists
251+ (field Reference in DI and Free Reference in SI)
252+ Note: for Supplier Refund and SI with Source Doc that are synched from Project to Coordo,
253+ the free ref will appear in Project only (US-970)
254+ '''
255+ db = pooler.get_pool(self.cr.dbname)
256+ acc_inv = db.get('account.invoice')
257+ free_ref = False
258+ if acc_move_line:
259+ acc_move = acc_move_line.move_id
260+ inv_id = acc_inv.search(self.cr, self.uid, [('move_id', '=', acc_move.id)])
261+ if inv_id:
262+ inv = acc_inv.browse(self.cr, self.uid, inv_id)
263+ free_ref = inv and inv[0].reference
264+ if not free_ref:
265+ # display the free ref if it is different from the "standard" ref
266+ if acc_move.name != acc_move.ref:
267+ free_ref = acc_move.ref
268+ return free_ref or ''
269+
270 SpreadsheetReport('report.fully.report','account.bank.statement','addons/register_accounting/report/fully_report_xls.mako', parser=report_fully_report)
271 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches