Merge lp:~vauxoo/addons-vauxoo/stock_picking_delete_dev_luis into lp:addons-vauxoo

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 386
Proposed branch: lp:~vauxoo/addons-vauxoo/stock_picking_delete_dev_luis
Merge into: lp:addons-vauxoo
Diff against target: 166 lines (+145/-0)
4 files modified
stock_inventory_delete/__init__.py (+26/-0)
stock_inventory_delete/__openerp__.py (+44/-0)
stock_inventory_delete/i18n/es.po (+34/-0)
stock_inventory_delete/stock.py (+41/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/stock_picking_delete_dev_luis
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Needs Fixing
Review via email: mp+118441@code.launchpad.net

Description of the change

Se realizo una funcion para no poder eliminar registros de stock.inventory en estado diferente a borrador

To post a comment you must log in.
387. By Luis Torres - http://www.vauxoo.com

[IMP]Change name to variable

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se cambio el nombre a la variable stock_picking

Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Excelente trabajo Luis, todo perfecto.

Nuevo requerimiento:
En una versión 2 optimiza el código, si lo haces con un search
ids_with_state_draft = self.search(cr, uid, [('id','in',ids), ('state','=','draft')], context=context, limit=1)#limit 1, para que con un id que tenga el state en draft, marque error.
if ids_with_state_draft:
   raise "error..."
return ids

Y por estándard, cambia el código:
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
a un super(...).unlink(self...)
Por favor

NOTA: En una propuesta de merge nueva

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'stock_inventory_delete'
2=== added file 'stock_inventory_delete/__init__.py'
3--- stock_inventory_delete/__init__.py 1970-01-01 00:00:00 +0000
4+++ stock_inventory_delete/__init__.py 2012-08-06 23:54:18 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
11+# All Rights Reserved.
12+# info Vauxoo (info@vauxoo.com)
13+############################################################################
14+# Coded by: Luis Torres (luis_t@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import stock
32
33=== added file 'stock_inventory_delete/__openerp__.py'
34--- stock_inventory_delete/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ stock_inventory_delete/__openerp__.py 2012-08-06 23:54:18 +0000
36@@ -0,0 +1,44 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
42+# All Rights Reserved.
43+# info Vauxoo (info@vauxoo.com)
44+############################################################################
45+# Coded by: Luis Torres (luis_t@vauxoo.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+ "name" : "Stock Picking Cancel",
64+ "version" : "1.0",
65+ "author" : "Vauxoo",
66+ "category" : "Generic Modules",
67+ "description" : """
68+ This Module review that the moment to delete a picking the state is draft
69+ """,
70+ "website" : "http://www.vauxoo.com/",
71+ "license" : "AGPL-3",
72+ "depends" : ["stock",
73+ ],
74+ "init_xml" : [],
75+ "demo_xml" : [],
76+ "update_xml" : [
77+ ],
78+ "installable" : True,
79+ "active" : False,
80+}
81
82=== added directory 'stock_inventory_delete/i18n'
83=== added file 'stock_inventory_delete/i18n/es.po'
84--- stock_inventory_delete/i18n/es.po 1970-01-01 00:00:00 +0000
85+++ stock_inventory_delete/i18n/es.po 2012-08-06 23:54:18 +0000
86@@ -0,0 +1,34 @@
87+# Translation of OpenERP Server.
88+# This file contains the translation of the following modules:
89+# * stock_inventory_delete
90+#
91+msgid ""
92+msgstr ""
93+"Project-Id-Version: OpenERP Server 6.1\n"
94+"Report-Msgid-Bugs-To: \n"
95+"POT-Creation-Date: 2012-08-06 23:32+0000\n"
96+"PO-Revision-Date: 2012-08-06 23:32+0000\n"
97+"Last-Translator: <>\n"
98+"Language-Team: \n"
99+"MIME-Version: 1.0\n"
100+"Content-Type: text/plain; charset=UTF-8\n"
101+"Content-Transfer-Encoding: \n"
102+"Plural-Forms: \n"
103+
104+#. module: stock_inventory_delete
105+#: code:addons/stock_inventory_delete/stock.py:39
106+#, python-format
107+msgid "Invalid action !"
108+msgstr "Accion Invalida !"
109+
110+#. module: stock_inventory_delete
111+#: code:addons/stock_inventory_delete/stock.py:39
112+#, python-format
113+msgid "Stocks can be removed only in draft."
114+msgstr "Solo se pueden eliminar registros en estado borrador."
115+
116+#. module: stock_inventory_delete
117+#: model:ir.model,name:stock_inventory_delete.model_stock_inventory
118+msgid "Inventory"
119+msgstr "Inventario"
120+
121
122=== added file 'stock_inventory_delete/stock.py'
123--- stock_inventory_delete/stock.py 1970-01-01 00:00:00 +0000
124+++ stock_inventory_delete/stock.py 2012-08-06 23:54:18 +0000
125@@ -0,0 +1,41 @@
126+# -*- encoding: utf-8 -*-
127+###########################################################################
128+# Module Writen to OpenERP, Open Source Management Solution
129+#
130+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
131+# All Rights Reserved.
132+# info Vauxoo (info@vauxoo.com)
133+############################################################################
134+# Coded by: Luis Torres (luis_t@vauxoo.com)
135+############################################################################
136+#
137+# This program is free software: you can redistribute it and/or modify
138+# it under the terms of the GNU Affero General Public License as
139+# published by the Free Software Foundation, either version 3 of the
140+# License, or (at your option) any later version.
141+#
142+# This program is distributed in the hope that it will be useful,
143+# but WITHOUT ANY WARRANTY; without even the implied warranty of
144+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145+# GNU Affero General Public License for more details.
146+#
147+# You should have received a copy of the GNU Affero General Public License
148+# along with this program. If not, see <http://www.gnu.org/licenses/>.
149+#
150+##############################################################################
151+from osv import osv, fields
152+from tools.translate import _
153+
154+class stock_picking(osv.osv):
155+ _inherit = 'stock.inventory'
156+
157+ def unlink(self, cr, uid, ids, context=None):
158+ stock_inventory = self.read(cr, uid, ids, ['state'], context=context)
159+ unlink_ids = []
160+ for s in stock_inventory:
161+ if s['state'] in ['draft']:
162+ unlink_ids.append(s['id'])
163+ else:
164+ raise osv.except_osv(_('Invalid action !'), _('Stocks can be removed only in draft.'))
165+
166+ return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)