Merge lp:~unifield-team/unifield-wm/bklg-18 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2450
Proposed branch: lp:~unifield-team/unifield-wm/bklg-18
Merge into: lp:unifield-wm
Diff against target: 187 lines (+95/-20)
2 files modified
msf_outgoing/report/picking_ticket.py (+73/-0)
msf_outgoing/report/picking_ticket.rml (+22/-20)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/bklg-18
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+253939@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 'msf_outgoing/report/picking_ticket.py'
2--- msf_outgoing/report/picking_ticket.py 2014-08-05 15:13:19 +0000
3+++ msf_outgoing/report/picking_ticket.py 2015-03-24 09:41:47 +0000
4@@ -20,11 +20,29 @@
5 ##############################################################################
6
7 import time
8+import pooler
9 from osv import osv
10 from tools.translate import _
11 from report import report_sxw
12
13
14+class BatchMoveLines(object):
15+
16+ def __init__(self, move):
17+ self.move = move
18+ self.location_id = move.location_id
19+ self.product_id = move.product_id
20+ self.line_number = move.line_number
21+ self.sale_line_id = move.sale_line_id
22+ self.product_uom = move.product_id.uom_id
23+ self.product_qty = 0.00
24+ self.prodlot_id = None
25+ self.kc_check = False
26+ self.dg_check = False
27+ self.np_check = False
28+ self.no_product = False
29+
30+
31 class picking_ticket(report_sxw.rml_parse):
32 """
33 Parser for the picking ticket report
34@@ -47,8 +65,62 @@
35 'uid': uid,
36 'getWarningMessage': self.get_warning,
37 'getStock': self.get_qty_available,
38+ 'getNbItems': self.get_nb_items,
39+ 'getLines': self.get_lines,
40 })
41
42+ def get_lines(self, picking):
43+ """
44+ Returns the move lines. For move lines with a batch number/expiry date
45+ create a first line with the whole quantity of product in stock, then
46+ one line for each batch with the quantity of batch in stock.
47+ """
48+ res = []
49+ dict_res = {}
50+ pool = pooler.get_pool(self.cr.dbname)
51+
52+ for m in picking.move_lines:
53+ dict_res.setdefault(m.line_number, [])
54+ if m.prodlot_id and not dict_res[m.line_number]:
55+ # First create a line without batch
56+ dict_res[m.line_number].append(BatchMoveLines(m))
57+ bm = BatchMoveLines(m)
58+ bm.product_uom = m.product_uom
59+ bm.product_qty = m.product_qty
60+ bm.prodlot_id = m.prodlot_id
61+ bm.kc_check = m.kc_check
62+ bm.dg_check = m.dg_check
63+ bm.np_check = m.np_check
64+ if m.prodlot_id and dict_res[m.line_number]:
65+ bm.no_product = True
66+ dict_res[m.line_number][0].product_qty += pool.get('product.uom')._compute_qty(
67+ self.cr, self.uid, bm.product_uom.id, bm.product_qty, bm.product_id.uom_id.id)
68+ dict_res[m.line_number].append(bm)
69+
70+ for key in dict_res:
71+ for m in dict_res[key]:
72+ res.append(m)
73+
74+ return res
75+
76+ def get_nb_items(self, picking):
77+ """
78+ Returns the number of different line number. If a line is split
79+ with a different product, this line count for +1
80+ """
81+ res = 0
82+ dict_res = {}
83+ for m in picking.move_lines:
84+ dict_res.setdefault(m.line_number, {})
85+ if m.product_id.id not in dict_res[m.line_number]:
86+ dict_res[m.line_number][m.product_id.id] = 1
87+
88+ for ln in dict_res.values():
89+ for p in ln.values():
90+ res += p
91+
92+ return res
93+
94 def get_warning(self, picking):
95 """
96 If the picking ticket contains heat sensitive, dangerous goods or both,
97@@ -100,6 +172,7 @@
98 context = {
99 'location': move.location_id.id,
100 'location_id': move.location_id.id,
101+ 'prodlot_id': move.prodlot_id and move.prodlot_id.id or False,
102 }
103
104 qty_available = product_obj.browse(
105
106=== modified file 'msf_outgoing/report/picking_ticket.rml'
107--- msf_outgoing/report/picking_ticket.rml 2014-10-23 15:26:10 +0000
108+++ msf_outgoing/report/picking_ticket.rml 2015-03-24 09:41:47 +0000
109@@ -11,7 +11,7 @@
110 <drawString x="20.0" y="555.0">PICKING TICKET ([[ getSel(objects[0], 'state') ]])</drawString>
111 <fill color="blue"/>
112 <drawString x="20.0" y="541.0">[[ objects[0].name ]]</drawString>
113- <image x="725.0" y="525.0" height="53.3" width="100">[[ company.logo or removeParentNode('image') ]]</image>
114+ <image x="705.0" y="525.0" height="53.3" width="100">[[ company.logo or removeParentNode('image') ]]</image>
115 <setFont name="Helvetica" size="8" />
116 <fill color="black" />
117 <drawString x="20.0" y="525.0">Page : <pageNumber /> / </drawString>
118@@ -101,6 +101,7 @@
119 <paraStyle name="LineHeaderLeft" fontName="Helvetica-Oblique" fontSize="6.0" alignment="LEFT" leading="5.0" />
120
121 <paraStyle name="LineValue" fontName="Helvetica" fontSize="6.0" alignment="CENTER" leading="5.0" textColor="blue" />
122+ <paraStyle name="LineValueBold" fontName="Helvetica-Bold" fontSize="8.0" alignment="CENTER" leading="5.0" textColor="blue" />
123 <paraStyle name="LineValueLeft" fontName="Helvetica" fontSize="6.0" alignment="LEFT" leading="5.0" textColor="blue" />
124
125
126@@ -132,7 +133,7 @@
127 <para style="HeaderInfosValue">[[ pt.sale_id and pt.sale_id.name or '-' ]]</para>
128 <para style="HeaderInfosValue">[[ pt.sale_id and pt.sale_id.client_order_ref and pt.sale_id.client_order_ref or '-' ]]</para>
129 <para style="HeaderInfosValue">[[ pt.sale_id and getSel(pt.sale_id, 'categ') or '-' ]]</para>
130- <para style="HeaderInfosValue">[[ len(pt.move_lines) or 0 ]]</para>
131+ <para style="HeaderInfosValue">[[ getNbItems(pt) ]]</para>
132 </td>
133 <td>
134 <para style="HeaderInfosTitle"></para>
135@@ -356,25 +357,26 @@
136
137 <!-- Lines -->
138 <blockTable colWidths="30.0,120.0,240.0,55.0,55.0,55.0,55.0,75.0,65.0,20.0,20.0,20.0" rowHeights="15.0" style="LinesValues">
139- [[ repeatIn(pt.move_lines, 'm', 'blockTable') ]]
140+ [[ repeatIn(getLines(pt), 'm', 'blockTable') ]]
141 <tr>
142 <td>
143- <para style="LineValue">[[ m.line_number ]]</para>
144- </td>
145- <td>
146- <para style="LineValueLeft">[[ m.sale_line_id and m.sale_line_id.product_id.default_code or m.product_id.default_code ]]</para>
147- </td>
148- <td>
149- <para style="LineValueLeft">[[ m.sale_line_id and m.sale_line_id.product_id.name or m.product_id.name ]]</para>
150- </td>
151- <td>
152- <para style="LineValue">[[ formatLang(getStock(m) or 0.00) ]]</para>
153- </td>
154- <td>
155- <para style="LineValue">[[ m.product_uom.name ]]</para>
156- </td>
157- <td>
158- <para style="LineValue">[[ m.product_qty and m.product_qty or 0.00 ]]</para>
159+ <para style="LineValue">[[ not m.no_product and m.line_number or '' ]]</para>
160+ </td>
161+ <td>
162+ <para style="LineValueLeft">[[ not m.no_product and (m.sale_line_id and m.sale_line_id.product_id.default_code or m.product_id.default_code) or '' ]]</para>
163+ </td>
164+ <td>
165+ <para style="LineValueLeft">[[ not m.no_product and (m.sale_line_id and m.sale_line_id.product_id.name or m.product_id.name) or '']]</para>
166+ </td>
167+ <td>
168+ <para style="LineValue">[[ formatLang(getStock(m) or 0.00, digits=get_digits(dp='Product UoM')) ]]</para>
169+ </td>
170+ <td>
171+ <para style="LineValue">[[ m.product_id.uom_id.name ]]</para>
172+ </td>
173+ <td>
174+ <para style="LineValue">[[ m.no_product and formatLang(m.product_qty, digits=get_digits(dp='Product UoM')) or removeParentNode('para') ]]</para>
175+ <para style="LineValueBold">[[ not m.no_product and formatLang(m.product_qty, digits=get_digits(dp='Product UoM')) or removeParentNode('para') ]]</para>
176 </td>
177 <td>
178 <para style="LineValue"> </para>
179@@ -400,7 +402,7 @@
180 <para style="LineValue"></para>
181 </td>
182 <td>
183- <para style="LineValueLeft">[[ m.sale_line_id and m.sale_line_id.note or '' ]]</para>
184+ <para style="LineValueLeft">[[ m.sale_line_id and m.sale_line_id.notes or '' ]]</para>
185 </td>
186 <td>
187 <para style="LineValueLeft">[[ m.sale_line_id and m.sale_line_id.product_id != m.product_id and '[%s] %s' % (m.product_id.default_code, m.product_id.name) or '' ]]</para>

Subscribers

People subscribed via source and target branches