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
=== modified file 'stock/__openerp__.py'
--- stock/__openerp__.py 2012-12-09 10:55:27 +0000
+++ stock/__openerp__.py 2013-06-08 19:32:28 +0000
@@ -21,7 +21,7 @@
2121
22{22{
23 'name': 'Warehouse Management',23 'name': 'Warehouse Management',
24 'version': '1.1',24 'version': '1.1.1',
25 'author': 'OpenERP SA',25 'author': 'OpenERP SA',
26 'summary': 'Inventory, Logistic, Storage',26 'summary': 'Inventory, Logistic, Storage',
27 'description' : """27 'description' : """
2828
=== added directory 'stock/migrations'
=== added directory 'stock/migrations/7.0.1.1.1'
=== added file 'stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py'
--- stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py 1970-01-01 00:00:00 +0000
+++ stock/migrations/7.0.1.1.1/pre-rename_sequence_code.py 2013-06-08 19:32:28 +0000
@@ -0,0 +1,11 @@
1__name__ = ("update internal picking sequence code and sequence")
2
3def migrate(cr, version):
4 old_type = 'stock.picking'
5 new_type = 'stock.picking.internal'
6 cr.execute ("UPDATE ir_sequence_type SET code=%(newtype)s WHERE code=%(oldtype)s",
7 {'newtype': new_type,
8 'oldtype': old_type})
9 cr.execute ("UPDATE ir_sequence SET code=%(newtype)s WHERE code=%(oldtype)s",
10 {'newtype': new_type,
11 'oldtype': old_type})
012
=== modified file 'stock/stock.py'
--- stock/stock.py 2013-06-07 15:53:50 +0000
+++ stock/stock.py 2013-06-08 19:32:28 +0000
@@ -618,7 +618,7 @@
618618
619 def create(self, cr, user, vals, context=None):619 def create(self, cr, user, vals, context=None):
620 if ('name' not in vals) or (vals.get('name')=='/'):620 if ('name' not in vals) or (vals.get('name')=='/'):
621 seq_obj_name = self._name621 seq_obj_name = 'stock.picking.%s' % vals.get('type', 'internal')
622 vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)622 vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name)
623 new_id = super(stock_picking, self).create(cr, user, vals, context)623 new_id = super(stock_picking, self).create(cr, user, vals, context)
624 return new_id624 return new_id
625625
=== modified file 'stock/stock_sequence.xml'
--- stock/stock_sequence.xml 2012-11-29 22:26:45 +0000
+++ stock/stock_sequence.xml 2013-06-08 19:32:28 +0000
@@ -17,7 +17,7 @@
17 17
18 <record id="seq_type_picking_internal" model="ir.sequence.type">18 <record id="seq_type_picking_internal" model="ir.sequence.type">
19 <field name="name">Picking INT</field>19 <field name="name">Picking INT</field>
20 <field name="code">stock.picking</field>20 <field name="code">stock.picking.internal</field>
21 </record>21 </record>
2222
23 <!--23 <!--
@@ -42,7 +42,7 @@
42 42
43 <record id="seq_picking_internal" model="ir.sequence">43 <record id="seq_picking_internal" model="ir.sequence">
44 <field name="name">Picking INT</field>44 <field name="name">Picking INT</field>
45 <field name="code">stock.picking</field>45 <field name="code">stock.picking.internal</field>
46 <field name="prefix">INT/</field>46 <field name="prefix">INT/</field>
47 <field name="padding">5</field>47 <field name="padding">5</field>
48 <field name="company_id" eval="False"/>48 <field name="company_id" eval="False"/>