Merge lp:~vauxoo/addons-vauxoo/mrp-gbw-dev-julio into lp:addons-vauxoo

Proposed by Julio Serna-http://www.vauxoo.com
Status: Rejected
Rejected by: Moisés López - http://www.vauxoo.com
Proposed branch: lp:~vauxoo/addons-vauxoo/mrp-gbw-dev-julio
Merge into: lp:addons-vauxoo
Diff against target: 1006 lines (+927/-0)
14 files modified
sale_mrp_autosplit/__init__.py (+26/-0)
sale_mrp_autosplit/__openerp__.py (+46/-0)
sale_mrp_autosplit/mrp_production.py (+137/-0)
sale_mrp_autosplit/report/__init__.py (+29/-0)
sale_mrp_autosplit/report/mrp_lot_barcode.py (+53/-0)
sale_mrp_autosplit/report/mrp_lot_barcode.rml (+106/-0)
sale_mrp_autosplit/report/rml2pdf_OpenERP-6.bat (+6/-0)
sale_mrp_autosplit/sale.py (+113/-0)
sale_mrp_autosplit/sale_mrp.patch (+148/-0)
sale_mrp_autosplit/sale_mrp_autosplit_report.xml (+13/-0)
sale_mrp_autosplit/sale_view.xml (+59/-0)
sale_mrp_autosplit/wizard/__init__.py (+2/-0)
sale_mrp_autosplit/wizard/wizard_force_cancel.py (+141/-0)
sale_mrp_autosplit/wizard/wizard_force_cancel_view.xml (+48/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/mrp-gbw-dev-julio
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Disapprove
Review via email: mp+109392@code.launchpad.net

Description of the change

agrega la linea con many2one en la producción hacia el pedido de venta

To post a comment you must log in.
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) :
review: Approve
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Este módulo no es, era otro
 sale_mrp

review: Disapprove

Unmerged revisions

1. By Julio Serna-http://www.vauxoo.com

[INIT]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_mrp_autosplit'
2=== added file 'sale_mrp_autosplit/__init__.py'
3--- sale_mrp_autosplit/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_mrp_autosplit/__init__.py 2012-06-08 16:18:19 +0000
5@@ -0,0 +1,26 @@
6+##############################################################################
7+#
8+# OpenERP, Open Source Management Solution
9+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as
13+# published by the Free Software Foundation, either version 3 of the
14+# License, or (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25+
26+import sale
27+import report
28+import mrp_production
29+import wizard
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31+
32
33=== added file 'sale_mrp_autosplit/__openerp__.py'
34--- sale_mrp_autosplit/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ sale_mrp_autosplit/__openerp__.py 2012-06-08 16:18:19 +0000
36@@ -0,0 +1,46 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2010 moylop260 - http://moylop.blogspot.com/
42+# All Rights Reserved.
43+# info moylop260 (moylop260@hotmail.com)
44+############################################################################
45+# Coded by: moylop260 (moylop260@hotmail.com)
46+############################################################################
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+
63+{
64+ "name" : "Sale MRP Autosplit",
65+ "version" : "1.0",
66+ "author" : "moylop260@hotmail.com",
67+ "category" : "Localization/Mexico",
68+ "description" : """This module add fields to sale_order for auto split production lot
69+ """,
70+ "website" : "http://moylop.blogspot.com/",
71+ "license" : "AGPL-3",
72+ "depends" : ["mrp", "sale", "sale_mrp"],
73+ "init_xml" : [],
74+ "demo_xml" : [],
75+ "update_xml" : [
76+ "sale_view.xml",
77+ "sale_mrp_autosplit_report.xml",
78+ "wizard/wizard_force_cancel_view.xml",
79+ ],
80+ "installable" : True,
81+ "active" : False,
82+}
83
84=== added file 'sale_mrp_autosplit/mrp_production.py'
85--- sale_mrp_autosplit/mrp_production.py 1970-01-01 00:00:00 +0000
86+++ sale_mrp_autosplit/mrp_production.py 2012-06-08 16:18:19 +0000
87@@ -0,0 +1,137 @@
88+# -*- encoding: utf-8 -*-
89+###########################################################################
90+# Module Writen to OpenERP, Open Source Management Solution
91+#
92+# Copyright (c) 2010 moylop260 - http://moylop.blogspot.com/
93+# All Rights Reserved.
94+# info moylop260 (moylop260@hotmail.com)
95+############################################################################
96+# Coded by: moylop260 (moylop260@hotmail.com)
97+############################################################################
98+#
99+# This program is free software: you can redistribute it and/or modify
100+# it under the terms of the GNU Affero General Public License as
101+# published by the Free Software Foundation, either version 3 of the
102+# License, or (at your option) any later version.
103+#
104+# This program is distributed in the hope that it will be useful,
105+# but WITHOUT ANY WARRANTY; without even the implied warranty of
106+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+# GNU Affero General Public License for more details.
108+#
109+# You should have received a copy of the GNU Affero General Public License
110+# along with this program. If not, see <http://www.gnu.org/licenses/>.
111+#
112+##############################################################################
113+
114+from osv import fields, osv
115+import netsvc
116+import time
117+
118+class mrp_production(osv.osv):
119+ _inherit = 'mrp.production'
120+ _order = 'name'
121+
122+ def _get_sale_id(self, cr, uid, ids, field_names=False):
123+ move_obj = self.pool.get('stock.move')
124+
125+ def get_parent_move(move_id):
126+ move = move_obj.browse(cr, uid, move_id)
127+ if move.move_dest_id:
128+ return get_parent_move(move.move_dest_id.id)
129+ return move_id
130+
131+ res = {}
132+ productions = self.browse(cr, uid, ids)
133+ for production in productions:
134+ res[production.id] = {}
135+ if production.move_prod_id:
136+ parent_move_line = get_parent_move(production.move_prod_id.id)
137+ if parent_move_line:
138+ move = move_obj.browse(cr, uid, parent_move_line)
139+ res[production.id]['sale_id'] = move.sale_line_id and move.sale_line_id.order_id.id or False
140+ res[production.id]['sale_line_id'] = move.sale_line_id and move.sale_line_id.id or False
141+ return res
142+
143+ def _split_production(self, cr, uid, ids):
144+ wf_service = netsvc.LocalService("workflow")
145+ sale_line_obj = self.pool.get('sale.order.line')
146+ production_id__sale_id = self._get_sale_id(cr, uid, ids)
147+ #print "action_confirm", ids
148+ for production in self.browse(cr, uid, ids):
149+ #sale_id = production_id__sale_id[id]['sale_id']
150+
151+ additional_production_ids = []
152+ #print "production.id",production.id
153+ sale_line_id = production_id__sale_id[production.id].get('sale_line_id', False)
154+ #print "sale_line_id",sale_line_id
155+ if sale_line_id:
156+ sale_line = sale_line_obj.browse(cr, uid, [sale_line_id])[0]
157+
158+ date_planned_start = sale_line.date_planned_start
159+ product_qty_split = sale_line.product_qty_split
160+ #print "date_planned_start",date_planned_start
161+ self.write(cr, uid, [production.id], {'date_planned': date_planned_start})
162+
163+ while production.product_qty > product_qty_split:
164+ new_production_id = self.copy(cr, uid, production.id, {
165+ 'product_qty': product_qty_split,
166+ 'product_uos_qty': product_qty_split,
167+ })
168+ wf_service.trg_validate(uid, 'mrp.production', new_production_id, 'button_confirm', cr)
169+ additional_production_ids.append( new_production_id )
170+ production.product_qty -= product_qty_split
171+ self.write(cr, uid, [production.id], {
172+ 'product_qty': production.product_qty,
173+ 'product_uos_qty': production.product_qty,
174+ })
175+ return additional_production_ids
176+
177+ def set_local_number(self, cr, uid, ids, context={}):
178+ """
179+ production_id__sale_id = self._get_sale_id(cr, uid, ids)
180+ sale_line_obj = self.pool.get('sale.order.line')
181+ for production in self.browse(cr, uid, ids):
182+ sale_line_id = production_id__sale_id[production.id].get('sale_line_id', False)
183+ if sale_line_id:
184+ sale_line = sale_line_obj.browse(cr, uid, [sale_line_id])[0]
185+ sale_line.
186+ """
187+ count = 0
188+ for production in self.browse(cr, uid, ids):
189+ count += 1
190+ date_obj = time.strptime(production.date_planned, '%Y-%m-%d %H:%M:%S')
191+ year = int(time.strftime('%y', date_obj))
192+ #week_of_year = int(time.strftime('%U', date_obj))+1
193+ week_of_year = int(time.strftime('%W', date_obj))+0
194+ week_of_year_str = '%%0%sd' % 2 % week_of_year
195+ day_of_week = date_obj.tm_wday + 1
196+ product_code = production.product_id.default_code or ''
197+ qty = "%%0%sd"% 2 % production.product_qty
198+ lot = '%%0%sd' % 3 % count
199+
200+ new_name = ""
201+ new_name += "%s"%(year)
202+ #new_name += "-"
203+ new_name += "%s"%(week_of_year_str)
204+ #new_name += "-"
205+ new_name += "%s"%(day_of_week)
206+ #new_name += "-"
207+ new_name += "%s"%( product_code )
208+ #new_name += "-"
209+ new_name += "%s"%( qty )
210+ #new_name += "-"
211+ new_name += lot
212+ self.write(cr, uid, [production.id], {'name': new_name})
213+ return True
214+
215+
216+ def action_confirm(self, cr, uid, ids):
217+ additional_production_ids = self._split_production(cr, uid, ids)
218+ self.action_compute(cr, uid, ids, properties=[])
219+ ret = super(mrp_production, self).action_confirm(cr, uid, ids)
220+ self.set_local_number(cr, uid, ids + additional_production_ids)
221+ return ret
222+mrp_production()
223+
224+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
225\ No newline at end of file
226
227=== added directory 'sale_mrp_autosplit/report'
228=== added file 'sale_mrp_autosplit/report/__init__.py'
229--- sale_mrp_autosplit/report/__init__.py 1970-01-01 00:00:00 +0000
230+++ sale_mrp_autosplit/report/__init__.py 2012-06-08 16:18:19 +0000
231@@ -0,0 +1,29 @@
232+# -*- encoding: utf-8 -*-
233+###########################################################################
234+# Module Writen to OpenERP, Open Source Management Solution
235+#
236+# Copyright (c) 2010 moylop260 - http://moylop.blogspot.com/
237+# All Rights Reserved.
238+# info moylop260 (moylop260@hotmail.com)
239+############################################################################
240+# Coded by: moylop260 (moylop260@hotmail.com)
241+############################################################################
242+#
243+# This program is free software: you can redistribute it and/or modify
244+# it under the terms of the GNU Affero General Public License as
245+# published by the Free Software Foundation, either version 3 of the
246+# License, or (at your option) any later version.
247+#
248+# This program is distributed in the hope that it will be useful,
249+# but WITHOUT ANY WARRANTY; without even the implied warranty of
250+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
251+# GNU Affero General Public License for more details.
252+#
253+# You should have received a copy of the GNU Affero General Public License
254+# along with this program. If not, see <http://www.gnu.org/licenses/>.
255+#
256+##############################################################################
257+
258+import mrp_lot_barcode
259+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
260+
261
262=== added file 'sale_mrp_autosplit/report/mrp_lot_barcode.py'
263--- sale_mrp_autosplit/report/mrp_lot_barcode.py 1970-01-01 00:00:00 +0000
264+++ sale_mrp_autosplit/report/mrp_lot_barcode.py 2012-06-08 16:18:19 +0000
265@@ -0,0 +1,53 @@
266+# -*- encoding: utf-8 -*-
267+###########################################################################
268+# Module Writen to OpenERP, Open Source Management Solution
269+#
270+# Copyright (c) 2010 moylop260 - http://moylop.blogspot.com/
271+# All Rights Reserved.
272+# info moylop260 (moylop260@hotmail.com)
273+############################################################################
274+# Coded by: moylop260 (moylop260@hotmail.com)
275+############################################################################
276+#
277+# This program is free software: you can redistribute it and/or modify
278+# it under the terms of the GNU Affero General Public License as
279+# published by the Free Software Foundation, either version 3 of the
280+# License, or (at your option) any later version.
281+#
282+# This program is distributed in the hope that it will be useful,
283+# but WITHOUT ANY WARRANTY; without even the implied warranty of
284+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285+# GNU Affero General Public License for more details.
286+#
287+# You should have received a copy of the GNU Affero General Public License
288+# along with this program. If not, see <http://www.gnu.org/licenses/>.
289+#
290+##############################################################################
291+from report import report_sxw
292+import pooler
293+import tools
294+
295+#DELETE FROM ir_act_report_xml WHERE report_name = 'mrp.lot.barcode';
296+
297+class mrp_lot_barcode(report_sxw.rml_parse):
298+ def __init__(self, cr, uid, name, context):
299+ super(mrp_lot_barcode, self).__init__(cr, uid, name, context=context)
300+ self.localcontext.update({
301+ 'get_count': self._get_count,
302+ })
303+
304+ def _get_count(self, count=1):
305+ try:
306+ self.count += count
307+ except:
308+ self.count = count
309+ return self.count
310+
311+report_sxw.report_sxw(
312+ 'report.mrp.lot.barcode',
313+ 'mrp.production',
314+ 'addons/sale_mrp_autosplit/report/mrp_lot_barcode.rml',
315+ header=False,
316+ parser=mrp_lot_barcode,
317+)
318+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
319
320=== added file 'sale_mrp_autosplit/report/mrp_lot_barcode.rml'
321--- sale_mrp_autosplit/report/mrp_lot_barcode.rml 1970-01-01 00:00:00 +0000
322+++ sale_mrp_autosplit/report/mrp_lot_barcode.rml 2012-06-08 16:18:19 +0000
323@@ -0,0 +1,106 @@
324+<?xml version="1.0"?>
325+<document filename="test.pdf">
326+ <template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
327+ <pageTemplate id="first">
328+ <frame id="first" x1="0.0" y1="0.0" width="612" height="792"/>
329+ </pageTemplate>
330+ </template>
331+ <stylesheet>
332+ <blockTableStyle id="Standard_Outline">
333+ <blockAlignment value="LEFT"/>
334+ <blockValign value="TOP"/>
335+ </blockTableStyle>
336+ <blockTableStyle id="Tabla2">
337+ <blockAlignment value="LEFT"/>
338+ <blockValign value="TOP"/>
339+ </blockTableStyle>
340+ <blockTableStyle id="Tabla1">
341+ <blockAlignment value="LEFT"/>
342+ <blockValign value="TOP"/>
343+ </blockTableStyle>
344+ <initialize>
345+ <paraStyle name="all" alignment="justify"/>
346+ </initialize>
347+ <paraStyle name="P1" fontName="Helvetica"/>
348+ <paraStyle name="P2" fontName="Helvetica" fontSize="6.0" leading="8"/>
349+ <paraStyle name="P3" fontName="Helvetica" fontSize="12.0" leading="15"/>
350+ <paraStyle name="P4" fontName="Helvetica" fontSize="12.0" leading="15" alignment="CENTER"/>
351+ <paraStyle name="P5" fontName="Helvetica" fontSize="12.0" leading="15" alignment="CENTER"/>
352+ <paraStyle name="Standard" fontName="Helvetica"/>
353+ <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
354+ <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
355+ <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
356+ <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
357+ <paraStyle name="Index" fontName="Helvetica"/>
358+ <paraStyle name="Table Contents" fontName="Helvetica"/>
359+ <images/>
360+ </stylesheet>
361+ <story>
362+ <section>
363+ <para style="P2">[[ repeatIn(objects,'o') ]]</para>
364+ <blockTable colWidths="50.0,36.0,29.0,323.0,54.0,59.0,62.0" style="Tabla2">
365+ <tr>
366+ <td>
367+ <para style="P3">Año</para>
368+ </td>
369+ <td>
370+ <para style="P3">Sem</para>
371+ </td>
372+ <td>
373+ <para style="P3">Día</para>
374+ </td>
375+ <td>
376+ <para style="P3">Estilo – Talla – Color</para>
377+ </td>
378+ <td>
379+ <para style="P4">Pares</para>
380+ </td>
381+ <td>
382+ <para style="P4">Lote</para>
383+ </td>
384+ <td>
385+ <para style="P4">Cliente</para>
386+ </td>
387+ </tr>
388+ <tr>
389+ <td>
390+ <para style="P3">20[[ o.name[:2] ]]</para>
391+ </td>
392+ <td>
393+ <para style="P4">[[ o.name[2:4] ]]</para>
394+ </td>
395+ <td>
396+ <para style="P4">[[ o.name[4:5] ]]</para>
397+ </td>
398+ <td>
399+ <para style="P3">[[ o.product_id.name ]] – [[ o.product_id.variants ]]</para>
400+ </td>
401+ <td>
402+ <para style="P4">[[ '%d'%(o.product_qty) ]]</para>
403+ </td>
404+ <td>
405+ <para style="P4">[[ o.name[-3:] ]]</para>
406+ </td>
407+ <td>
408+ <para style="P4">[[ o.partner_id.ref ]]</para>
409+ </td>
410+ </tr>
411+ </blockTable>
412+ <blockTable colWidths="612.0" style="Tabla1">
413+ <tr>
414+ <td>
415+ <para style="Standard">[[ o.name and setTag('para','barCode',{'barWidth':'1.5', 'code':'code128'}) ]][[ o.name ]]</para>
416+ </td>
417+ </tr>
418+ <tr>
419+ <td>
420+ <para style="Standard">............... [[ o.name ]] .......................</para>
421+ <para style="Standard">=========================================================================================</para>
422+ </td>
423+ </tr>
424+ </blockTable>
425+ <para style="P1">[[ get_count(1)%6 == 0 and get_count(0)&lt;&gt;len(objects) and setTag('para','nextPage') ]]</para>
426+ </section>
427+ </story>
428+</document>
429+
430
431=== added file 'sale_mrp_autosplit/report/mrp_lot_barcode.sxw'
432Binary files sale_mrp_autosplit/report/mrp_lot_barcode.sxw 1970-01-01 00:00:00 +0000 and sale_mrp_autosplit/report/mrp_lot_barcode.sxw 2012-06-08 16:18:19 +0000 differ
433=== added file 'sale_mrp_autosplit/report/rml2pdf_OpenERP-6.bat'
434--- sale_mrp_autosplit/report/rml2pdf_OpenERP-6.bat 1970-01-01 00:00:00 +0000
435+++ sale_mrp_autosplit/report/rml2pdf_OpenERP-6.bat 2012-06-08 16:18:19 +0000
436@@ -0,0 +1,6 @@
437+SET path=%path%;C:\python25
438+SET tiny_sxw2rml_path=../../base_report_designer/wizard/tiny_sxw2rml/tiny_sxw2rml.py
439+SET tiny_sxw2rml_path=../../../addons/base_report_designer/wizard/tiny_sxw2rml/tiny_sxw2rml.py
440+SET tiny_sxw2rml_path=../../../addons\base_report_designer\openerp_sxw2rml\openerp_sxw2rml.py
441+python %tiny_sxw2rml_path% mrp_lot_barcode.sxw > mrp_lot_barcode.rml
442+pause
443\ No newline at end of file
444
445=== added file 'sale_mrp_autosplit/sale.py'
446--- sale_mrp_autosplit/sale.py 1970-01-01 00:00:00 +0000
447+++ sale_mrp_autosplit/sale.py 2012-06-08 16:18:19 +0000
448@@ -0,0 +1,113 @@
449+# -*- encoding: utf-8 -*-
450+###########################################################################
451+# Module Writen to OpenERP, Open Source Management Solution
452+#
453+# Copyright (c) 2010 moylop260 - http://moylop.blogspot.com/
454+# All Rights Reserved.
455+# info moylop260 (moylop260@hotmail.com)
456+############################################################################
457+# Coded by: moylop260 (moylop260@hotmail.com)
458+############################################################################
459+#
460+# This program is free software: you can redistribute it and/or modify
461+# it under the terms of the GNU Affero General Public License as
462+# published by the Free Software Foundation, either version 3 of the
463+# License, or (at your option) any later version.
464+#
465+# This program is distributed in the hope that it will be useful,
466+# but WITHOUT ANY WARRANTY; without even the implied warranty of
467+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
468+# GNU Affero General Public License for more details.
469+#
470+# You should have received a copy of the GNU Affero General Public License
471+# along with this program. If not, see <http://www.gnu.org/licenses/>.
472+#
473+##############################################################################
474+
475+from osv import fields, osv
476+import netsvc
477+import time
478+
479+class sale_order_line(osv.osv):
480+ _inherit = 'sale.order.line'
481+
482+ _columns = {
483+ 'date_planned_start': fields.datetime(u'Date Planned Start'),
484+ 'product_qty_split': fields.integer(u'Quantity Split Lot'),
485+ }
486+sale_order_line()
487+
488+class sale_order(osv.osv):
489+ _inherit = "sale.order"
490+
491+ def _production_rate(self, cursor, user, ids, name, arg, context=None):
492+ res = {}
493+ production_obj = self.pool.get('mrp.production')
494+ for sale in self.browse(cursor, user, ids, context=context):
495+ production_ids = production_obj.search(cursor, user, [('sale_id', '=', sale.id)], context=context)
496+ #print "sale_id",sale.id
497+ #print "production_ids",production_ids
498+ productions = production_obj.browse(cursor, user, production_ids, context=context)
499+ #print "production_ids",production_ids
500+ if sale.produced:
501+ res[sale.id] = 100.0
502+ continue
503+ tot = 0.0
504+ for production in productions:
505+ if production.state not in ('draft', 'cancel'):
506+ tot += production.product_qty
507+ if tot:
508+ sale_total_qty = sum([sale_line.product_uom_qty for sale_line in sale.order_line])
509+ #print "sale_total_qty",sale_total_qty
510+ #print "tot",tot
511+ res[sale.id] = min(100.0, tot * 100.0 / sale_total_qty or 1.00)
512+ else:
513+ res[sale.id] = 0.0
514+ #print "********************"
515+ return res
516+
517+ def _produced(self, cursor, user, ids, name, arg, context=None):
518+ res = {}
519+ for sale in self.browse(cursor, user, ids, context=context):
520+ res[sale.id] = True
521+ for invoice in sale.invoice_ids:
522+ if invoice.state != 'paid':
523+ res[sale.id] = False
524+ break
525+ if not sale.invoice_ids:
526+ res[sale.id] = False
527+ return res
528+
529+ _columns = {
530+ 'production_rate': fields.function(_production_rate, method=True, string='Produced', type='float'),
531+ 'produced': fields.function(_produced, method=True, string='Produced',
532+ type='boolean', help="It indicates that productions are finished", ),#fnct_search=_invoiced_search),
533+ }
534+sale_order()
535+"""
536+class sale_order(osv.osv):
537+ _inherit = "sale.order"
538+ '''
539+ def action_ship_create(self, cr, uid, ids, *args):
540+ production_obj = self.pool.get('production.order')
541+ production_line_obj = self.pool.get('production.order.line')
542+
543+ ret = super(sale_order, self).action_ship_create(cr, uid, ids)
544+
545+ sales = self.browse(cr, uid, ids)
546+ for sale in sales:
547+ production_ids = []
548+
549+ for sale_line in sale.order_line:
550+ production = sale_line.procurement_id and sale_line.procurement_id.production_id or False
551+ if production:
552+ production_ids.append( production.id )
553+ data = {'ids': production_ids}
554+ print "sale",sale.id
555+ print "production_ids",production_ids
556+ return ret
557+ '''
558+sale_order()
559+"""
560+
561+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
562\ No newline at end of file
563
564=== added file 'sale_mrp_autosplit/sale_mrp.patch'
565--- sale_mrp_autosplit/sale_mrp.patch 1970-01-01 00:00:00 +0000
566+++ sale_mrp_autosplit/sale_mrp.patch 2012-06-08 16:18:19 +0000
567@@ -0,0 +1,148 @@
568+=== modified file 'base_vat/base_vat.py'
569+--- base_vat/base_vat.py 2011-01-17 20:44:55 +0000
570++++ base_vat/base_vat.py 2011-06-01 01:47:27 +0000
571+@@ -23,6 +23,9 @@
572+
573+ from osv import osv, fields
574+ from tools.translate import _
575++from tools.misc import ustr
576++import re
577++import datetime
578+
579+ _ref_vat = {
580+ 'be': 'BE0477472701', 'at': 'ATU12345675',
581+@@ -38,7 +41,9 @@
582+ 'nl': 'NL123456782B90', 'pl': 'PL1234567883',
583+ 'pt': 'PT123456789', 'ro': 'RO1234567897',
584+ 'se': 'SE123456789701', 'si': 'SI12345679',
585+- 'sk': 'SK0012345675', 'el': 'EL12345670'
586++ 'sk': 'SK0012345675', 'el': 'EL12345670',
587++ 'mx': 'MXABCD831230T1B',
588++
589+ }
590+
591+ def mult_add(i, j):
592+@@ -1064,6 +1069,36 @@
593+ return False
594+ return True
595+
596++ __check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \
597++ r"[ \-_]?" \
598++ r"(?P<ano>[0-9]{2})(?P<mes>[01][0-9])(?P<dia>[0-3][0-9])" \
599++ r"[ \-_]?" \
600++ r"(?P<code>[A-Za-z0-9&\xd1\xf1]{3})$")
601++
602++ def check_vat_mx(self, vat):
603++ ''' Mexican VAT verification
604++
605++ Verificar RFC México
606++ '''
607++ # we convert to 8-bit encoding, to help the regex parse only bytes
608++ vat = ustr(vat).encode('iso8859-1')
609++ m = self.__check_vat_mx_re.match(vat)
610++ if not m:
611++ #No valid format
612++ return False
613++ try:
614++ ano = int(m.group('ano'))
615++ if ano > 30:
616++ ano = 1900 + ano
617++ else:
618++ ano = 2000 + ano
619++ datetime.date(ano, int(m.group('mes')), int(m.group('dia')))
620++ except ValueError:
621++ return False
622++
623++ #Valid format and valid date
624++ return True
625++
626+ res_partner()
627+
628+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
629+
630+=== modified file 'sale_mrp/sale_mrp.py'
631+--- sale_mrp/sale_mrp.py 2011-01-14 00:11:01 +0000
632++++ sale_mrp/sale_mrp.py 2011-06-06 21:41:04 +0000
633+@@ -25,28 +25,12 @@
634+ class mrp_production(osv.osv):
635+ _inherit = 'mrp.production'
636+
637+- def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context=None):
638++ def _get_sale_ref(self, cr, uid, ids, field_names=None, arg=False, context=None):
639+ """ Finds reference of sales order for production order.
640+ @param field_names: Names of fields.
641+ @param arg: User defined arguments
642+ @return: Dictionary of values.
643+ """
644+- res = {}
645+- if not field_names:
646+- field_names = []
647+- for id in ids:
648+- res[id] = {}.fromkeys(field_names, False)
649+- for f in field_names:
650+- field_name = False
651+- if f == 'sale_name':
652+- field_name = 'name'
653+- if f == 'sale_ref':
654+- field_name = 'client_order_ref'
655+- for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
656+- res[key][f] = value
657+- return res
658+-
659+- def _get_sale_ref(self, cr, uid, ids, field_name=False):
660+ move_obj = self.pool.get('stock.move')
661+
662+ def get_parent_move(move_id):
663+@@ -58,20 +42,30 @@
664+ res = {}
665+ productions = self.browse(cr, uid, ids)
666+ for production in productions:
667+- res[production.id] = False
668++ res[production.id] = {}
669+ if production.move_prod_id:
670+ parent_move_line = get_parent_move(production.move_prod_id.id)
671+ if parent_move_line:
672+ move = move_obj.browse(cr, uid, parent_move_line)
673+- if field_name == 'name':
674+- res[production.id] = move.sale_line_id and move.sale_line_id.order_id.name or False
675+- if field_name == 'client_order_ref':
676+- res[production.id] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
677++ for field_name in field_names:
678++ if field_name == 'sale_name':
679++ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.name or False
680++ if field_name == 'sale_ref':
681++ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
682++ if field_name == 'sale_id':
683++ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.id or False
684++ if field_name == 'sale_line_id':
685++ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.id or False
686++ if field_name == 'partner_id':
687++ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.partner_id.id or False
688+ return res
689+
690+ _columns = {
691+- 'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sales Name', help='Indicate the name of sales order.'),
692+- 'sale_ref': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sales Reference', help='Indicate the Customer Reference from sales order.'),
693++ 'sale_name': fields.function(_get_sale_ref, method=True, multi='sale_name', type='char', string='Sales Name', help='Indicate the name of sales order.'),
694++ 'sale_ref': fields.function(_get_sale_ref, method=True, multi='sale_name', type='char', string='Sales Reference', help='Indicate the Customer Reference from sales order.'),
695++ 'sale_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='sale.order', string='Sale Order', help=''),
696++ 'sale_line_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='sale.order.line', string='Sale Line', help=''),
697++ 'partner_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='res.partner', string='Partner', help=''),
698+ }
699+
700+ mrp_production()
701+
702+=== modified file 'sale_mrp/sale_mrp_view.xml'
703+--- sale_mrp/sale_mrp_view.xml 2011-01-14 00:11:01 +0000
704++++ sale_mrp/sale_mrp_view.xml 2011-06-06 21:28:34 +0000
705+@@ -11,6 +11,9 @@
706+ <xpath expr="/form/notebook/page/field[@name='move_prod_id']" position="after">
707+ <field name="sale_name" groups="base.group_extended"/>
708+ <field name="sale_ref" groups="base.group_extended"/>
709++ <field name="sale_id" groups="base.group_extended"/>
710++ <field name="sale_line_id" groups="base.group_extended"/>
711++ <field name="partner_id" groups="base.group_extended"/>
712+ </xpath>
713+ </field>
714+ </record>
715+
716
717=== added file 'sale_mrp_autosplit/sale_mrp_autosplit_report.xml'
718--- sale_mrp_autosplit/sale_mrp_autosplit_report.xml 1970-01-01 00:00:00 +0000
719+++ sale_mrp_autosplit/sale_mrp_autosplit_report.xml 2012-06-08 16:18:19 +0000
720@@ -0,0 +1,13 @@
721+<?xml version="1.0" encoding="utf-8"?>
722+<openerp>
723+ <data>
724+
725+ <report id="mrp_lot_barcode"
726+ name="mrp.lot.barcode"
727+ string="Barcode"
728+ model="mrp.production"
729+ header="False"
730+ rml="sale_mrp_autosplit/report/mrp_lot_barcode.rml"
731+ />
732+ </data>
733+</openerp>
734\ No newline at end of file
735
736=== added file 'sale_mrp_autosplit/sale_view.xml'
737--- sale_mrp_autosplit/sale_view.xml 1970-01-01 00:00:00 +0000
738+++ sale_mrp_autosplit/sale_view.xml 2012-06-08 16:18:19 +0000
739@@ -0,0 +1,59 @@
740+<?xml version="1.0" ?>
741+<openerp>
742+ <data>
743+
744+ <record model="ir.ui.view" id="view_order_form_inh_sale_mrp_autosplit_02">
745+ <field name="name">view.order.form.inh.sale.mrp.autosplit.02</field>
746+ <field name="model">sale.order</field>
747+ <field name="type">form</field>
748+ <field name="priority" eval="20"/>
749+ <field name="inherit_id" ref="sale.view_order_form"/>
750+ <field name="arch" type="xml">
751+ <field name="product_uom_qty" position="after">
752+ <field name="product_qty_split" select="1"/>
753+ </field>
754+ </field>
755+ </record>
756+
757+ <record model="ir.ui.view" id="view_order_form_inh_sale_mrp_autosplit_01">
758+ <field name="name">view.order.form.inh.sale.mrp.autosplit.01</field>
759+ <field name="model">sale.order</field>
760+ <field name="priority" eval="10"/>
761+ <field name="type">form</field>
762+ <field name="inherit_id" ref="sale.view_order_form"/>
763+ <field name="arch" type="xml">
764+ <field name="product_uom_qty" position="after">
765+ <field name="date_planned_start" select="1"/>
766+ </field>
767+ </field>
768+ </record>
769+
770+ <record model="ir.ui.view" id="view_order_tree_inh_sale_mrp_autosplit_03">
771+ <field name="name">view.order.tree.inh.sale.mrp.autosplit.03</field>
772+ <field name="model">sale.order</field>
773+ <field name="priority" eval="10"/>
774+ <field name="type">tree</field>
775+ <field name="inherit_id" ref="sale.view_order_tree"/>
776+ <field name="arch" type="xml">
777+ <field name="picked_rate" position="after">
778+ <field name="production_rate" widget="progressbar"/>
779+ </field>
780+ </field>
781+ </record>
782+
783+ <!--
784+ <record model="ir.ui.view" id="view_order_form_inh_pricelist_date_02">
785+ <field name="name">view.order.form.inh.pricelist.date.02</field>
786+ <field name="model">sale.order</field>
787+ <field name="type">form</field>
788+ <field name="inherit_id" ref="sale_layout.view_order_form_inherit_1"/>
789+ <field name="arch" type="xml">
790+ <field name="price_unit" position="after">
791+ <field name="date_pricelist" select="1"/>
792+ </field>
793+ </field>
794+ </record>
795+ -->
796+ </data>
797+</openerp>
798+
799
800=== added directory 'sale_mrp_autosplit/wizard'
801=== added file 'sale_mrp_autosplit/wizard/__init__.py'
802--- sale_mrp_autosplit/wizard/__init__.py 1970-01-01 00:00:00 +0000
803+++ sale_mrp_autosplit/wizard/__init__.py 2012-06-08 16:18:19 +0000
804@@ -0,0 +1,2 @@
805+# -*- coding: utf-8 -*-
806+import wizard_force_cancel
807\ No newline at end of file
808
809=== added file 'sale_mrp_autosplit/wizard/wizard_force_cancel.py'
810--- sale_mrp_autosplit/wizard/wizard_force_cancel.py 1970-01-01 00:00:00 +0000
811+++ sale_mrp_autosplit/wizard/wizard_force_cancel.py 2012-06-08 16:18:19 +0000
812@@ -0,0 +1,141 @@
813+# -*- coding: utf-8 -*-
814+from osv import osv, fields
815+import netsvc
816+import time
817+from tools.translate import _
818+
819+class wizard_force_cancel(osv.osv_memory):
820+ _name = 'wizard.force.cancel'
821+ _description = 'Force at cancel the sale.order and sub-process'
822+
823+ def force_cancel(self, cr, uid, ids, context=None):
824+ if context is None:
825+ context = {}
826+ wf_service = netsvc.LocalService("workflow")
827+ sale_ids = context['active_ids']
828+ #print "sale_ids",sale_ids
829+
830+ sale_obj = self.pool.get('sale.order')
831+ sale_line_obj = self.pool.get('sale.order.line')
832+ picking_obj = self.pool.get('stock.picking')
833+ production_obj = self.pool.get('mrp.production')
834+ move_obj = self.pool.get('stock.move')
835+ workcenter_line_obj = self.pool.get('mrp.production.workcenter.line')
836+
837+ sale_filter = [('sale_id', 'in', sale_ids)]
838+
839+ production_ids = production_obj.search(cr, uid, sale_filter, context=context)
840+
841+ if not 'sale_id' in cr.query:
842+ print "No se puede forzar cancelar esta venta, porque no tiene referencias"
843+ return {}
844+ #cancel workflow
845+ #Tambien considerar mrp.production.line
846+ moves_data = production_obj.read(cr, uid, production_ids, ['move_prod_id', 'picking_id'], context=context)
847+ move_ids = []
848+ picking_ids = []
849+ for move_data in moves_data:
850+ #print "move_data",move_data
851+ picking_id = move_data['picking_id'] and move_data['picking_id'][0] or False
852+ if picking_id:
853+ picking_ids.append( picking_id )
854+ move_prod_id = move_data['move_prod_id'] and move_data['move_prod_id'][0] or False
855+ if move_prod_id:
856+ move_ids.append( move_prod_id )
857+ #break
858+
859+ #print "move_ids",move_ids
860+ #print "move_ids",move_ids
861+ #print "moves_data",moves_data
862+ ##production.move_prod_id.picking_id
863+ pickings_data = move_ids and move_obj.read(cr, uid, move_ids, ['picking_id'], context=context) or []
864+ for picking_data in pickings_data:
865+ picking_ids.append( picking_data['picking_id'][0] )
866+ #sale_filter = ['|', ('sale_id', 'in', sale_ids), ('production_id', 'in', production_ids)]
867+ picking_ids.extend( picking_obj.search(cr, uid, sale_filter, context=context) )
868+
869+ #print "picking_obj.search--cr.query",cr.query
870+ #print "picking_ids",picking_ids
871+ for picking_id in picking_ids:
872+ wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_cancel', cr)
873+ #print "picking_ids",picking_ids
874+ #############picking_obj.write(cr, uid, picking_ids, {'state': 'cancel'}, context=context)
875+
876+ move_ids.extend( move_obj.search(cr, uid, [('picking_id', 'in', picking_ids)], context=context) )
877+ #print "move_obj.search--cr.query",cr.query
878+ #print "move_ids",move_ids
879+ for move_id in move_ids:
880+ wf_service.trg_validate(uid, 'stock.move', move_id, 'button_cancel', cr)
881+
882+ workcenter_line_ids = workcenter_line_obj.search(cr, uid, [('production_id', 'in', production_ids)], context=context)
883+ #print "workcenter_line_obj.search-cr.query",cr.query
884+ #print "workcenter_line_ids",workcenter_line_ids
885+ for workcenter_line_id in workcenter_line_ids:
886+ wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line_id , 'button_cancel', cr)
887+ #########workcenter_line_obj.write(cr, uid, workcenter_line_ids, {'state': 'cancel'}, context=context)
888+
889+ #print "production_obj.search--cr.query",cr.query
890+ #print "production_ids",production_ids
891+ for production_id in production_ids:
892+ wf_service.trg_validate(uid, 'mrp.production', production_id , 'button_cancel', cr)
893+
894+ ########production_obj.write(cr, uid, production_ids, {'state': 'cancel'}, context=context)
895+ #sale_line_ids = sale_line_obj.search(cr, uid, [('order_id', 'in', sale_ids)], context=context)
896+
897+ for sale_id in sale_ids:
898+ #wf_service.trg_validate(uid, 'sale.order', sale_id, 'button_cancel', cr)
899+ #print "action_cancel"
900+ #wf_service.trg_validate(uid, 'sale.order', sale_id, 'action_cancel', cr)
901+ #print "cancel"
902+ #wf_service.trg_validate(uid, 'sale.order', sale_id, 'cancel', cr)
903+ #print "ship_cancel"
904+ wf_service.trg_validate(uid, 'sale.order', sale_id, 'ship_cancel', cr)
905+ wf_service.trg_validate(uid, 'sale.order', sale_id, 'action_cancel', cr)
906+ wf_service.trg_validate(uid, 'sale.order', sale_id, 'cancel', cr)
907+ wf_service.trg_validate(uid, 'sale.order', sale_id, 'invoice_cancel', cr)
908+
909+ #Tambien considerar mrp.procurement
910+ #tambien considerar facturas
911+ return {}
912+wizard_force_cancel()
913+"""
914+class wizard_finished_wcl(osv.osv_memory):
915+ _name = 'wizard.finished.wcl'
916+ _description = 'Finish a Work Center Line with a sequence'
917+
918+ _columns = {
919+ 'production_id': fields.many2one('mrp.production', 'Produccion', required=True),
920+ 'workcenter_line_id': fields.many2one('mrp.production.workcenter.line', 'Fraccion', required=True),
921+ #'workcenter_id': fields.many2one('mrp.workcenter', 'Departamento', required=False),
922+ #'sequence': fields.integer('Fraccion', required=False),
923+ }
924+
925+ def confirm(self, cr, uid, ids, context={}):
926+ if not context:
927+ context = {}
928+ wkl_obj = self.pool.get('mrp.production.workcenter.line')
929+ wf_service = netsvc.LocalService("workflow")
930+ data = self.read(cr, uid, ids)[0]
931+ workcenter_line_id = data['workcenter_line_id']
932+ wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line_id, 'button_start_working', cr)
933+ wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line_id, 'button_done', cr)
934+ state = wkl_obj.read(cr, uid, [workcenter_line_id], ['state'], context=context)[0]['state']
935+ if state <> 'done':
936+ raise osv.except_osv(_('UserError'), _('No se pudo finalizar esta fraccion\nSe quedo en estado [%s]'%(state)))
937+ return {}
938+
939+ def onchange_production_id(self, cr, uid, ids, production_id, context={}):
940+ production_obj = self.pool.get('mrp.production')
941+ wkl_obj = self.pool.get('mrp.production.workcenter.line')
942+ res = {}
943+ wkl_ids = wkl_obj.search(cr, uid, [
944+ ('production_id', '=', production_id),
945+ ('state', '<>', 'done'),
946+ ('name','ilike','%pase%'),
947+ ], limit=1, order='production_id, sequence', context=context)
948+ wkl_id = wkl_ids and wkl_ids[0] or False
949+ res['value'] = {'workcenter_line_id': wkl_id}
950+ return res
951+wizard_finished_wcl()
952+"""
953+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
954
955=== added file 'sale_mrp_autosplit/wizard/wizard_force_cancel_view.xml'
956--- sale_mrp_autosplit/wizard/wizard_force_cancel_view.xml 1970-01-01 00:00:00 +0000
957+++ sale_mrp_autosplit/wizard/wizard_force_cancel_view.xml 2012-06-08 16:18:19 +0000
958@@ -0,0 +1,48 @@
959+<?xml version="1.0" encoding="utf-8"?>
960+<openerp>
961+ <data>
962+
963+ <record id="view_wizard_force_cancel_form" model="ir.ui.view">
964+ <field name="name">view.wizard.force.cancel.form</field>
965+ <field name="model">wizard.force.cancel</field>
966+ <field name="type">form</field>
967+ <field name="arch" type="xml">
968+ <form string="Finalizar Fraccion">
969+ <separator string="Esta usted seguro?" colspan="4"/>
970+ <separator string="Se tardara varios minutos y no podras deshacer esta accion"/>
971+ <group colspan="4" col="6">
972+ <button special="cancel" string="_Salir" icon="gtk-cancel"/>
973+ <button name="force_cancel" string="Confir_mar Cancelacion" type="object" icon="gtk-ok"/>
974+ </group>
975+ </form>
976+ </field>
977+ </record>
978+ <record id="action_view_wizard_force_cancel_form" model="ir.actions.act_window">
979+ <field name="name">Force cancel sale</field>
980+ <field name="type">ir.actions.act_window</field>
981+ <field name="res_model">wizard.force.cancel</field>
982+ <field name="view_type">form</field>
983+ <field name="view_mode">form</field>
984+ <field name="view_id" ref="view_wizard_force_cancel_form"/>
985+ <field name="target">new</field>
986+ </record>
987+ <record model="ir.values" id="wizard_force_cancel">
988+ <field name="model_id" ref="sale.model_sale_order"/>
989+ <field name="object" eval="1" />
990+ <field name="name">Force Cancel Sale</field>
991+ <field name="key2">client_action_multi</field>
992+ <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_wizard_force_cancel_form'))" />
993+ <field name="key">action</field>
994+ <field name="model">sale.order</field>
995+ </record>
996+ <!--
997+ <menuitem id="menu_action_view_wizard_force_cancel_form"
998+ action="action_view_wizard_force_cancel_form"
999+ name="Finalizar Fraccion"
1000+ parent="mrp.menu_mrp_manufacturing"
1001+ sequence="30"
1002+ />
1003+ -->
1004+ </data>
1005+</openerp>
1006+