Merge lp:~unifield-team/unifield-server/us-218 into lp:unifield-server

Proposed by Quentin THEURET @Amaris
Status: Rejected
Rejected by: jftempo
Proposed branch: lp:~unifield-team/unifield-server/us-218
Merge into: lp:unifield-server
Diff against target: 232 lines (+60/-27)
4 files modified
bin/addons/msf_supply_doc_export/msf_supply_doc_export.py (+54/-23)
bin/addons/msf_supply_doc_export/report/report_po_follow_up.rml (+2/-1)
bin/addons/msf_supply_doc_export/report/report_po_follow_up_xls.mako (+1/-1)
bin/addons/msf_supply_doc_export/wizard/po_follow_up.py (+3/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-218
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+301245@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

3870. By Quentin THEURET @Amaris

US-218 [FIX] No display backorder quantities if the IN is canceled

3869. By Quentin THEURET @Amaris

US-218 [IMP] PO follow-up per supplier: The original IN with the BO qty will always be the last displayed,

3868. By Quentin THEURET @Amaris

US-218 [IMP] PO follow-up per supplier: The original IN with the BO qty will always be the last displayed,

3867. By Quentin THEURET @Amaris

US-218 [FIX] Make the report in background

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_supply_doc_export/msf_supply_doc_export.py'
2--- bin/addons/msf_supply_doc_export/msf_supply_doc_export.py 2016-03-15 06:38:29 +0000
3+++ bin/addons/msf_supply_doc_export/msf_supply_doc_export.py 2016-07-27 07:09:11 +0000
4@@ -408,8 +408,17 @@
5
6 return res
7
8+ def setTotalLines(self, po_ids):
9+ if not self.total_lines:
10+ self.total_lines = self.pool.get('purchase.order.line').search(self.cr, self.uid, [('order_id', 'in', [x.id for x in po_ids])], count=True, context=self.localcontext)
11+ return True
12+
13 def yieldPoLines(self, po_line_ids):
14 for pol_id in po_line_ids:
15+ self.processed_lines += 1
16+ if self.back_browse:
17+ percent = float(self.processed_lines) / float(self.total_lines)
18+ self.pool.get('memory.background.report').update_percent(self.cr, self.uid, [self.back_browse.id], percent)
19 yield self.pool.get('purchase.order.line').browse(self.cr, self.uid, pol_id, context=self.localcontext)
20
21 raise StopIteration
22@@ -433,7 +442,9 @@
23 same_product = []
24 other_product = []
25
26+ inl_index = 0
27 for inl in self.getAllLineIN(line.id):
28+ inl_index += 1
29 if inl.get('product_id') and inl.get('product_id') == line.product_id.id:
30 if inl.get('product_uom') and inl.get('product_uom') == line.product_uom.id:
31 same_product_same_uom.append(inl)
32@@ -442,6 +453,8 @@
33 else:
34 other_product.append(inl)
35
36+ oneline = inl_index == 1
37+ first_line_data = []
38 first_line = True
39 # Display information of the initial reception
40 if not same_product_same_uom:
41@@ -468,15 +481,17 @@
42 first_line = False
43
44 for spsul in same_product_same_uom:
45+ bo_qty = spsul.get('backorder_id') and spsul.get('state') != 'done'
46+ display_main_info = (first_line and not bo_qty) or oneline
47 report_line = {
48 'order_ref': order.name or '',
49 'order_created': order.date_order or '',
50 'order_confirmed_date': order.delivery_confirmed_date or '',
51 'order_status': self._get_states().get(order.state, ''),
52- 'item': first_line and line.line_number or '',
53- 'code': first_line and line.product_id.default_code or '',
54- 'description': first_line and line.product_id.name or '',
55- 'qty_ordered': first_line and line.product_qty or '',
56+ 'item': display_main_info and line.line_number or '',
57+ 'code': display_main_info and line.product_id.default_code or '',
58+ 'description': display_main_info and line.product_id.name or '',
59+ 'qty_ordered': display_main_info and line.product_qty or '',
60 'uom': line.product_uom.name or '',
61 'qty_received': spsul.get('state') == 'done' and spsul.get('product_qty', '') or '0.00',
62 'in': spsul.get('name', '') or '',
63@@ -487,24 +502,28 @@
64 'in_unit_price': spsul.get('price_unit'),
65 }
66
67- report_lines.append(report_line)
68-
69- if first_line:
70- if spsul.get('backorder_id') and spsul.get('state') != 'done':
71+ if first_line and not first_line_data and bo_qty:
72+ if spsul.get('state') != 'cancel':
73 report_line['qty_backordered'] = spsul.get('product_qty', '')
74- report_lines.extend(self.printAnalyticLines(analytic_lines))
75- first_line = False
76+ first_line_data.append(report_line)
77+ else:
78+ report_lines.append(report_line)
79+ if first_line:
80+ first_line = False
81+ report_lines.extend(self.printAnalyticLines(analytic_lines))
82
83 for spl in same_product:
84+ bo_qty = spl.get('backorder_id') and spl.get('state') != 'done'
85+ display_main_info = (first_line and not bo_qty) or oneline
86 report_line = {
87 'order_ref': order.name or '',
88 'order_created': order.date_order or '',
89 'order_confirmed_date': order.delivery_confirmed_date or '',
90 'order_status': self._get_states().get(order.state, ''),
91- 'item': first_line and line.line_number or '',
92- 'code': first_line and line.product_id.default_code or '',
93- 'description': first_line and line.product_id.name or '',
94- 'qty_ordered': first_line and line.product_qty or '',
95+ 'item': display_main_info and line.line_number or '',
96+ 'code': display_main_info and line.product_id.default_code or '',
97+ 'description': display_main_info and line.product_id.name or '',
98+ 'qty_ordered': display_main_info and line.product_qty or '',
99 'uom': uom_obj.read(self.cr, self.uid, spl.get('product_uom'), ['name'])['name'],
100 'qty_received': spl.get('state') == 'done' and spl.get('product_qty', '') or '0.00',
101 'in': spl.get('name', '') or '',
102@@ -514,13 +533,16 @@
103 'unit_price': line.price_unit or '',
104 'in_unit_price': spl.get('price_unit'),
105 }
106- report_lines.append(report_line)
107
108- if first_line:
109- if spl.get('backorder_id') and spl.get('state') != 'done':
110- report_line['qty_backordered'] = spl.get('product_qty', '')
111- report_lines.extend(self.printAnalyticLines(analytic_lines))
112- first_line = False
113+ if first_line and not first_line_data and bo_qty:
114+ if spl.get('state') != 'cancel':
115+ report_line['qty_backordered'] = spsul.get('product_qty', '')
116+ first_line_data.append(report_line)
117+ else:
118+ report_lines.append(report_line)
119+ if first_line:
120+ first_line = False
121+ report_lines.extend(self.printAnalyticLines(analytic_lines))
122
123 for ol in other_product:
124 prod_brw = prod_obj.browse(self.cr, self.uid, ol.get('product_id'))
125@@ -544,6 +566,9 @@
126 }
127 report_lines.append(report_line)
128
129+ if first_line_data:
130+ report_lines.extend(first_line_data)
131+
132 return report_lines
133
134 def getAnalyticLines(self,po_line):
135@@ -580,7 +605,7 @@
136
137 raise StopIteration
138
139- def getReportHeaderLine1(self):
140+ def getReportHeaderLine1(self, po_ids):
141 return self.datas.get('report_header')[0]
142
143 def getReportHeaderLine2(self):
144@@ -605,9 +630,11 @@
145 'getPOLines': self.getPOLines,
146 'getPOLineHeaders': self.getPOLineHeaders,
147 'getRunParms': self.getRunParms,
148+ 'setTotalLines': self.setTotalLines,
149 })
150-
151-
152+ self.total_lines = 0
153+ self.processed_lines = 0
154+ self.back_browse = get_back_browse(self, self.cr, self.uid, context)
155
156
157 class po_follow_up_report_xls(SpreadsheetReport):
158@@ -633,7 +660,11 @@
159 'getReportHeaderLine1': self.getReportHeaderLine1,
160 'getReportHeaderLine2': self.getReportHeaderLine2,
161 'getRunParmsRML': self.getRunParmsRML,
162+ 'setTotalLines': self.setTotalLines,
163 })
164+ self.total_lines = 0
165+ self.processed_lines = 0
166+ self.back_browse = get_back_browse(self, self.cr, self.uid, context)
167
168 report_sxw.report_sxw('report.po.follow.up_rml', 'purchase.order', 'addons/msf_supply_doc_export/report/report_po_follow_up.rml', parser=parser_po_follow_up_rml, header=False)
169
170
171=== modified file 'bin/addons/msf_supply_doc_export/report/report_po_follow_up.rml'
172--- bin/addons/msf_supply_doc_export/report/report_po_follow_up.rml 2014-11-05 16:27:19 +0000
173+++ bin/addons/msf_supply_doc_export/report/report_po_follow_up.rml 2016-07-27 07:09:11 +0000
174@@ -67,8 +67,9 @@
175
176 <para style="P2">
177 <font color="white"> </font>
178+ [[ setTotalLines(objects) ]]
179 </para>
180-
181+
182 <para>[[repeatIn(objects,'o')]]</para>
183 <blockTable colWidths="150.0,150.0,150.0,150.0,150.0,150.0" style="Tableau3">
184 <tr>
185
186=== modified file 'bin/addons/msf_supply_doc_export/report/report_po_follow_up_xls.mako'
187--- bin/addons/msf_supply_doc_export/report/report_po_follow_up_xls.mako 2015-02-20 12:56:44 +0000
188+++ bin/addons/msf_supply_doc_export/report/report_po_follow_up_xls.mako 2016-07-27 07:09:11 +0000
189@@ -114,6 +114,7 @@
190 # Cost Center
191 <Column ss:AutoFitWidth="1" ss:Width="95" />
192
193+ ${setTotalLines(objects)}
194 <Row>
195 <Cell ss:MergeAcross="11" ss:StyleID="mainheader"><Data ss:Type="String">${getRunParms()['title'] or '' |x}</Data></Cell>
196 </Row>
197@@ -130,7 +131,6 @@
198 <Cell ss:StyleID="header"><Data ss:Type="String">${header}</Data></Cell>
199 % endfor
200 </Row>
201-
202 % for o in objects:
203
204 % for line in getPOLines(o.id):
205
206=== modified file 'bin/addons/msf_supply_doc_export/wizard/po_follow_up.py'
207--- bin/addons/msf_supply_doc_export/wizard/po_follow_up.py 2016-01-29 15:34:00 +0000
208+++ bin/addons/msf_supply_doc_export/wizard/po_follow_up.py 2016-07-27 07:09:11 +0000
209@@ -54,7 +54,7 @@
210
211 _defaults = {
212 'export_format': lambda *a: 'xls',
213- 'background_time': lambda *a: 20,
214+ 'background_time': lambda *a: 5,
215 }
216
217 def button_validate(self, cr, uid, ids, context=None):
218@@ -138,6 +138,7 @@
219 background_id = self.pool.get('memory.background.report').create(cr, uid, {'file_name': report_name, 'report_name': report_name}, context=context)
220 context['background_id'] = background_id
221 context['background_time'] = wiz.background_time
222+ datas['context'] = context
223
224 return {
225 'type': 'ir.actions.report.xml',
226@@ -146,7 +147,7 @@
227 'nodestroy': True,
228 'context': context,
229 }
230-
231+
232 po_follow_up()
233
234

Subscribers

People subscribed via source and target branches

to all changes: