Merge lp:~jfb-tempo-consulting/unifield-server/US-4133 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4846
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-4133
Merge into: lp:unifield-server
Diff against target: 113 lines (+59/-24)
2 files modified
bin/addons/purchase_override/report/merged_order.py (+36/-0)
bin/addons/purchase_override/report/merged_order.rml (+23/-24)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-4133
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+340474@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/purchase_override/report/merged_order.py'
2--- bin/addons/purchase_override/report/merged_order.py 2014-03-07 10:00:41 +0000
3+++ bin/addons/purchase_override/report/merged_order.py 2018-04-16 08:13:53 +0000
4@@ -30,6 +30,7 @@
5 'to_time': self.str_to_time,
6 'enumerate': enumerate,
7 'getOrigin': self._get_origin,
8+ 'get_merged_lines': self.get_merged_lines,
9 })
10
11 def _get_origin(self, origin, number=5):
12@@ -57,6 +58,41 @@
13
14 return res
15
16+ def get_merged_lines(self, order):
17+ all_prod = {}
18+ line_obj = self.pool.get('purchase.order.line')
19+ line_ids = line_obj.search(self.cr, self.uid, [('order_id', '=', order.id), ('state', 'not in', ['cancel', 'cancel_r'])])
20+
21+ for line in line_obj.browse(self.cr, self.uid, line_ids, context=self.localcontext):
22+ if not line.product_id:
23+ p_key = line.nomenclature_description
24+ p_name = line.nomenclature_description
25+ default_code = ''
26+ else:
27+ p_key = line.product_id.id
28+ p_name = line.product_id.name
29+ default_code = line.product_id.default_code
30+
31+ key = (p_key, line.product_uom.id)
32+ if key not in all_prod:
33+ all_prod[key] = {
34+ 'default_code': default_code,
35+ 'supplier_code': line.supplier_code,
36+ 'name': p_name,
37+ 'price_unit': line.price_unit,
38+ 'price_subtotal': line.price_subtotal,
39+ 'product_uom': line.product_uom.name,
40+ 'quantity': line.product_qty,
41+ 'comment': line.comment or '',
42+ }
43+ else:
44+ all_prod[key]['price_unit'] = ((all_prod[key]['price_unit'] * all_prod[key]['quantity']) + (line.product_qty*line.price_unit)) / (line.product_qty+all_prod[key]['quantity'])
45+ all_prod[key]['quantity'] += line.product_qty
46+ all_prod[key]['price_subtotal'] += line.price_subtotal
47+ if line.comment:
48+ all_prod[key]['comment'] += ' %s' % line.comment
49+
50+ return sorted(all_prod.values(), key=lambda x: x['default_code'] or x['name'])
51
52 def str_to_time(self, time):
53 if isinstance(time, str):
54
55=== modified file 'bin/addons/purchase_override/report/merged_order.rml'
56--- bin/addons/purchase_override/report/merged_order.rml 2017-09-22 15:31:55 +0000
57+++ bin/addons/purchase_override/report/merged_order.rml 2018-04-16 08:13:53 +0000
58@@ -593,32 +593,31 @@
59
60 <section>
61 <blockTable colWidths="65.0,95.0,295.5,95.0,55.5,60.0,51.0,55.0" style="LinesTable">
62- [[repeatIn(objects[0].merged_line_ids,'line')]]
63+ [[repeatIn(get_merged_lines(objects[0]),'line')]]
64 <tr>
65 <td>
66- <para style="LinesBlue">[[ line.supplier_code ]]</para>
67- </td>
68- <td>
69- <para style="LinesBlue">[[ line.product_id.default_code ]]</para>
70- </td>
71- <td>
72- <para style="LinesBlue">[[ line.product_id and line.product_id.name or removeParentNode('para') ]]</para>
73- <para style="LinesBlue">[[ not line.product_id and line.nomen_manda_0.name or removeParentNode('para') ]] [[ line.nomen_manda_1 and '/ %s' % line.nomen_manda_1.name or '' ]] [[ line.nomen_manda_2 and '/ %s' % line.nomen_manda_2.name or '' ]] [[ line.nomen_manda_3 and '/ %s' % line.nomen_manda_3.name or '' ]] [[ line.nomen_sub_0 and '/ %s' % line.nomen_sub_0.name or '' ]] [[ line.nomen_sub_1 and '/ %s' % line.nomen_sub_1.name or '' ]] [[ line.nomen_sub_2 and '/ %s' % line.nomen_sub_2.name or '' ]] [[ line.nomen_sub_3 and '/ %s' % line.nomen_sub_3.name or '' ]] [[ line.nomen_sub_4 and '/ %s' % line.nomen_sub_4.mane or '' ]] [[ line.nomen_sub_5 and '/ %s' % line.nomen_sub_5.name or '' ]]</para>
74- </td>
75- <td>
76- <para style="LinesBlue">[[ line.comment ]]</para>
77- </td>
78- <td>
79- <para style="LinesBlue" alignment="RIGHT">[[ line.product_qty or '0.00' ]]</para>
80- </td>
81- <td>
82- <para style="LinesBlue" alignment="CENTER">[[ line.product_uom.name ]]</para>
83- </td>
84- <td>
85- <para style="LinesBlue" alignment="RIGHT">[[ line.price_unit or '0.00' ]]</para>
86- </td>
87- <td>
88- <para style="LinesBlue" alignment="RIGHT">[[ line.price_subtotal or '0.00' ]]</para>
89+ <para style="LinesBlue">[[ line['supplier_code'] ]]</para>
90+ </td>
91+ <td>
92+ <para style="LinesBlue">[[ line['default_code'] ]]</para>
93+ </td>
94+ <td>
95+ <para style="LinesBlue">[[ line['name'] ]]</para>
96+ </td>
97+ <td>
98+ <para style="LinesBlue">[[ line['comment'] ]]</para>
99+ </td>
100+ <td>
101+ <para style="LinesBlue" alignment="RIGHT">[[ line['quantity'] or '0.00' ]]</para>
102+ </td>
103+ <td>
104+ <para style="LinesBlue" alignment="CENTER">[[ line['product_uom'] ]]</para>
105+ </td>
106+ <td>
107+ <para style="LinesBlue" alignment="RIGHT">[[ round(line['price_unit'], 4) or '0.00' ]]</para>
108+ </td>
109+ <td>
110+ <para style="LinesBlue" alignment="RIGHT">[[ line['price_subtotal'] or '0.00' ]]</para>
111 </td>
112 </tr>
113 </blockTable>

Subscribers

People subscribed via source and target branches