3
<style type="text/css">
8
<div class="basic_header">
9
<table class="basic_table">
10
<tr><td style="text-align:center;">${helper.embed_logo_by_name('company_logo',75, 53)|n}</td>
12
<table class="basic_table">
13
<tr><td class="basic_td">${_("Company:")} ${company.name |entity}</td></tr>
14
<tr><td class="basic_td">${_("Address:")} ${company.partner_id.address and company.partner_id.address[0].street or ''|entity}</td></tr>
15
<tr><td class="basic_td">${_("Phone:")} ${company.partner_id.address and company.partner_id.address[0].phone or ''|entity}</td></tr>
16
<tr><td class="basic_td">${_("Mail:")} ${company.partner_id.address and company.partner_id.address[0].email or ''|entity}</td></tr>
17
<tr><td class="basic_td">${_("User:")} ${user.name or ''|entity}</td></tr>
24
wiz_user = this_self.pool.get('res.users').browse(cr, uid, uid, context=context)
25
company_id = context.get('company_id', wiz_user.company_id.id)
26
mrp_obj = this_self.pool.get('mrp.production')
27
product_uom_pool = this_self.pool.get('product.uom')
30
<p><h3>${_("Report of product variation group")}</h3></p>
31
${_("From:")} ${formatLang(data['form'].get('date_start'), date=True)|entity} to: ${formatLang(data['form'].get('date_finished'), date=True)|entity}
32
<br/>${_("For products:")}<br/>
33
%for line in data['form'].get('product_ids'):
34
<%product_data = this_self.pool.get('product.product').browse(cr, uid, line, context)%>
35
${product_data.name_template or ''|entity}
40
production_ids = mrp_obj.search(cr, uid , [('state', 'not in', ('draft', 'cancel')), \
41
('product_id', 'in', data['form']['product_ids']), ('date_planned', '>', data['form']['date_start']), \
42
('date_planned', '<', data['form']['date_finished']), ('company_id', '=', company_id)])
44
SELECT mrp_variation_finished_product.product_id, mrp_production.name ,standard_price * quantity AS mul, name_template FROM mrp_variation_finished_product
45
INNER JOIN mrp_production
46
ON mrp_production.id = mrp_variation_finished_product.production_id
47
INNER JOIN product_product
48
ON product_product.id = mrp_variation_finished_product.product_id
49
INNER JOIN product_template
50
ON product_template.id = product_product.product_tmpl_id
51
WHERE production_id IN
54
""", (tuple(production_ids),))
56
records = cr.fetchall()
58
<%#Obtener los totales
59
mrp_data = mrp_obj.browse(cr, uid, production_ids, context=context)
60
no_children_flag = False
62
<p><h4>${_("Productions matching your query:")}</h4></p>
63
<table class="basic_table">
65
%for line in mrp_data:
66
%if line.subproduction_ids:
69
<td class="basic_td" style="color:red">
70
<%no_children_flag = True%>
72
% if loop is UNDEFINED:
73
${line.name or ''|entity}
75
${loop.index+1 or ''|entity} - ${line.name or ''|entity}</td>
76
%if ((loop.index+1) %5 ==0):
84
%if (no_children_flag == True):
85
<p class="basic_td" style="color:red">${_("Productions marked in red don't have a subproduction children associated with them")}</p>
89
%if data['query_dict']:
90
<table class="basic_table">
92
<td class="basic_td">${_("Variation in consumed products")}</td>
93
<td class="basic_td"> </td>
94
<td class="basic_td"> </td>
95
<td class="basic_td"> </td>
99
<th class="basic_th">${_("Reference:")}</th>
100
<th class="basic_th">${_("Quantity:")}</th>
101
<th class="basic_th">${_("Unit of M:")}</th>
102
<th class="basic_th">${_("Variation cost:")}</th>
105
<%total_consumed_cost=0%>
106
%for line in data['query_dict']:
107
%if (row_count%2==0):
112
<td class="basic_td"> ${line[0] or ''|entity}</td>
113
<td class="number_td"> ${ formatLang(line[1]) }</td>
114
<td class="basic_td"> ${line[2] or ''|entity}</td>
115
<td class="number_td"> $ ${ formatLang(line[3]) }</td>
117
<%total_consumed_cost+=line[3]%>
121
<td class="lastrow"></td>
122
<td class="lastrow">${_("Total:")}</td>
123
<td class="lastrow"></td>
124
<td class="lastrow">$ ${ formatLang(total_consumed_cost) }</td>
128
<p>${_("The consulted productions don't have variations.")}</p>
132
%if data['finished_dict']:
133
<table class="basic_table">
135
<td class="basic_td">${_("Variation in finished products / details")}</td>
136
<th class="basic_th">${_("Production name")} </th>
137
<th class="basic_th">${_("Variation price")} </th>
138
<th class="basic_th">${_("Not consumed")} </th>
142
<%mrp_data = mrp_obj.browse(cr, uid, production_ids, this_context)%>
143
%for production in mrp_data:
146
if production.move_created_ids2:
147
for finished in production.move_created_ids2:
148
if (finished.product_id.id == production.product_id.id and finished.state in ('done')):
149
total_produced += product_uom_pool._compute_qty(cr, uid, finished.product_uom.id, finished.product_qty, to_uom_id=production.product_uom.id)
150
for subprods in production.subproduction_ids:
151
if subprods.move_lines2:
152
for consumed in subprods.move_lines2:
153
if (consumed.product_id.id == production.product_id.id and consumed.state in ('done')):
154
total_produced -= product_uom_pool._compute_qty(cr, uid, consumed.product_uom.id, consumed.product_qty, to_uom_id=production.product_uom.id)
156
%for variation in production.variation_finished_product_ids:
157
%if variation.quantity:
158
%if (row_count%2==0):
163
<td class="basic_td">
164
${production.product_id.name or ''|entity}
165
%if (production.product_id.name != variation.product_id.name):
166
[${variation.product_id.name or ''|entity}]
169
<td class="basic_td"> ${production.name or ''|entity} </td>
170
<td class="number_td"> $ ${ formatLang(variation.cost_variation) } </td>
171
<td class="number_td"> ${ formatLang(total_produced) } ${production.product_uom.name or ''|entity}</td>
181
<th class="basic_th">${_("Reference:")}</th>
182
<th class="basic_th">${_("Quantity:")}</th>
183
<th class="basic_th">${_("Unit of M:")}</th>
184
<th class="basic_th">${_("Variation cost:")}</th>
187
<%total_finished_cost=0%>
188
<%total_finished_qty=0%>
189
%for line in data['finished_dict']:
190
%if (row_count%2==0):
195
<td class="basic_td"> ${line[0] or ''|entity}</td>
196
<td class="number_td"> ${ formatLang(line[1]) }</td>
197
<td class="basic_td"> ${line[2] or ''|entity}</td>
198
<td class="number_td"> $ ${ formatLang(line[3]) }</td>
200
<%total_finished_cost+=line[3]%>
201
<%total_finished_qty+=line[1]%>
205
<%#Obtener los totales
208
for production in mrp_data:
209
total_res_dict.setdefault(production.product_id.name, [0, production.product_id.uom_id.name])
210
total_produced = product_uom_pool._compute_qty(cr, uid, production.product_uom.id, production.product_qty, to_uom_id=production.product_id.uom_id.id)
211
total_res_dict[production.product_id.name][0] += total_produced
215
%for key, value in dict.items(total_res_dict):
217
<td class="lastrow" style="text-align:left">${_("Product:")} ${key or ''|entity}</td>
218
<td class="lastrow">${_("Total planned to produce:")}</td>
219
<td class="lastrow">${ formatLang(value[0]) } ${value[1] or ''|entity}</td>
220
%if (len(total_res_dict) == 1):
221
<td class="lastrow">${_("Really produced:")} ${ formatLang(value[0]+total_finished_qty) } ${value[1] or ''|entity}</td>
224
<%total_produced += value[0]%>
227
<td class="lastrow" style="text-align:left">${_("Production eficiency:")} ${ formatLang(100 + (total_finished_qty*100/total_produced)) } %</td>
228
<td class="lastrow">${_("Total variation cost")}</td>
229
<td class="lastrow">$ ${ formatLang(total_finished_cost) }</td>
236
%if data['child_consumed']:
238
<table class="basic_table">
240
<td class="basic_td">${_("Variation in children consumed products")}</td>
241
<td class="basic_td"> </td>
242
<td class="basic_td"> </td>
243
<td class="basic_td"> </td>
246
<th class="basic_th">${_("Reference:")}</th>
247
<th class="basic_th">${_("Quantity:")}</th>
248
<th class="basic_th">${_("Unit of M:")}</th>
249
<th class="basic_th">${_("Variation cost:")}</th>
252
<%total_child_consumed_cost=0%>
253
%for line in data['child_consumed']:
254
%if (row_count%2==0):
259
<td class="basic_td"> ${line[0] or ''|entity}</td>
260
<td class="number_td"> ${ formatLang(line[1]) }</td>
261
<td class="basic_td"> ${line[2] or ''|entity}</td>
262
<td class="number_td"> $ ${ formatLang(line[3]) }</td>
264
<%total_child_consumed_cost+=line[3]%>
268
<td class="lastrow"></td>
269
<td class="lastrow">${_("Total:")}</td>
270
<td class="lastrow"></td>
271
<td class="lastrow">$ ${ formatLang(total_child_consumed_cost) }</td>
277
%if data['child_finished']:
278
<table class="basic_table">
280
<td class="basic_td">${_("Variation in children finished products")}</td>
281
<td class="basic_td"> </td>
282
<td class="basic_td"> </td>
283
<td class="basic_td"> </td>
286
<th class="basic_th">${_("Reference:")}</th>
287
<th class="basic_th">${_("Quantity:")}</th>
288
<th class="basic_th">${_("Unit of M:")}</th>
289
<th class="basic_th">${_("Variation cost:")}</th>
292
<%total_child_finished_cost=0%>
293
%for line in data['child_finished']:
294
%if (row_count%2==0):
299
<td class="basic_td"> ${line[0] or ''|entity}</td>
300
<td class="number_td"> ${ formatLang(line[1]) }</td>
301
<td class="basic_td"> ${line[2] or ''|entity}</td>
302
<td class="number_td"> $ ${ formatLang(line[3]) }</td>
304
<%total_child_finished_cost+=line[3]%>
308
<td class="lastrow"></td>
309
<td class="lastrow">${_("Total:")}</td>
310
<td class="lastrow"></td>
311
<td class="lastrow">$ ${ formatLang(total_child_finished_cost) }</td>
317
<p style="page-break-after:always"></p>
b'\\ No newline at end of file'