Merge lp:~camptocamp/openobject-addons/7.0-fix-1088412 into lp:openobject-addons/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix-1088412
Merge into: lp:openobject-addons/7.0
Diff against target: 65 lines (+15/-4)
4 files modified
stock/__openerp__.py (+1/-1)
stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py (+11/-0)
stock/stock.py (+1/-1)
stock/stock_sequence.xml (+2/-2)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/7.0-fix-1088412
Reviewer Review Type Date Requested Status
Nicolas Bessi - Camptocamp (community) no test, code review only Approve
Olivier Dony (Odoo) Pending
OpenERP Core Team Pending
Review via email: mp+164740@code.launchpad.net

Description of the change

fix the sequence type code for internal stock pickings. Update the data for existing databases.

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Looks good to me. Using migrate function will be better than using init function.
I'm a little bit worried if an exception happens as I have not a global vision of cursor transaction management of the migrate function. If someone from OpenERP can gave more explanation about it it will be nice.

review: Approve (no test, code review only)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

setting back to "WIP" following comments on the OCB MP

Unmerged revisions

9145. By Alexandre Fayolle - camptocamp

[FIX] stock.picking: fix the case which was broken by previous change

9144. By Alexandre Fayolle - camptocamp

[IMP] set version to 1.1.1 rather than 1.2

9143. By Alexandre Fayolle - camptocamp

[FIX] added migration script to ensure the correct name of the sequence type in pre existing databases

9142. By Paramjit Singh Sahota(OpenERP)

[FIX] change the name to the sequence code for internal pickings

when a chained picking is generated, the sequence code used is "stock.picking.%s" % picking.type
so we need a sequence code "stock.picking.internal" for internal pickings (and not "stock.picking")

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/__openerp__.py'
2--- stock/__openerp__.py 2012-12-09 10:55:27 +0000
3+++ stock/__openerp__.py 2013-06-08 19:32:28 +0000
4@@ -21,7 +21,7 @@
5
6 {
7 'name': 'Warehouse Management',
8- 'version': '1.1',
9+ 'version': '1.1.1',
10 'author': 'OpenERP SA',
11 'summary': 'Inventory, Logistic, Storage',
12 'description' : """
13
14=== added directory 'stock/migrations'
15=== added directory 'stock/migrations/7.0.1.1.1'
16=== added file 'stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py'
17--- stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py 1970-01-01 00:00:00 +0000
18+++ stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py 2013-06-08 19:32:28 +0000
19@@ -0,0 +1,11 @@
20+__name__ = ("update internal picking sequence code and sequence")
21+
22+def migrate(cr, version):
23+ old_type = 'stock.picking'
24+ new_type = 'stock.picking.internal'
25+ cr.execute ("UPDATE ir_sequence_type SET code=%(newtype)s WHERE code=%(oldtype)s",
26+ {'newtype': new_type,
27+ 'oldtype': old_type})
28+ cr.execute ("UPDATE ir_sequence SET code=%(newtype)s WHERE code=%(oldtype)s",
29+ {'newtype': new_type,
30+ 'oldtype': old_type})
31
32=== modified file 'stock/stock.py'
33--- stock/stock.py 2013-06-07 15:53:50 +0000
34+++ stock/stock.py 2013-06-08 19:32:28 +0000
35@@ -618,7 +618,7 @@
36
37 def create(self, cr, user, vals, context=None):
38 if ('name' not in vals) or (vals.get('name')=='/'):
39- seq_obj_name = self._name
40+ seq_obj_name = 'stock.picking.%s' % vals.get('type', 'internal')
41 vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
42 new_id = super(stock_picking, self).create(cr, user, vals, context)
43 return new_id
44
45=== modified file 'stock/stock_sequence.xml'
46--- stock/stock_sequence.xml 2012-11-29 22:26:45 +0000
47+++ stock/stock_sequence.xml 2013-06-08 19:32:28 +0000
48@@ -17,7 +17,7 @@
49
50 <record id="seq_type_picking_internal" model="ir.sequence.type">
51 <field name="name">Picking INT</field>
52- <field name="code">stock.picking</field>
53+ <field name="code">stock.picking.internal</field>
54 </record>
55
56 <!--
57@@ -42,7 +42,7 @@
58
59 <record id="seq_picking_internal" model="ir.sequence">
60 <field name="name">Picking INT</field>
61- <field name="code">stock.picking</field>
62+ <field name="code">stock.picking.internal</field>
63 <field name="prefix">INT/</field>
64 <field name="padding">5</field>
65 <field name="company_id" eval="False"/>