Merge lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep into lp:openerp-manufacturing/6.1

Proposed by Leonardo Pistone
Status: Merged
Merged at revision: 9
Proposed branch: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep
Merge into: lp:openerp-manufacturing/6.1
Diff against target: 302 lines (+271/-0)
6 files modified
mrp_split_one/__init__.py (+22/-0)
mrp_split_one/__openerp__.py (+41/-0)
mrp_split_one/i18n/fr.po (+54/-0)
mrp_split_one/i18n/mrp_split_one.pot (+54/-0)
mrp_split_one/mrp_view.xml (+21/-0)
mrp_split_one/stock.py (+79/-0)
To merge this branch: bzr merge lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Yannick Vaucher @ Camptocamp code review, no tests Needs Fixing
Sandy Carter (http://www.savoirfairelinux.com) code review, no test Approve
Review via email: mp+197474@code.launchpad.net

Description of the change

Hi,

this is to add a new module: mrp_split_one.

Thanks!

To post a comment you must log in.
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

__openerp__.py:
The 1 space indentation doesn't meet pep8 criteria.
l.58 Spelling mistake of 'prodution' in description

stock.py:
l.126-127 Should be importing from openerp.osv, openerp.tools... (see mrp_bom_product_details/mrp_bom_product_details.py)

review: Needs Fixing (code review)
9. By Leonardo Pistone

[fix] typo

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Sandy,
thanks for your review.

1. I think that case falls under the "Aligned with opening delimiter" rule, which should be fine. The pep8 tool indeed likes it.

2. fixed.

3. I think this is 7.0 style, while all but one of the 6.1 standard modules do "from osv".

Best

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

1. Technically, you are correct, while I don't personally like that style, as most __openerp__.py files won't start the item list on the same line as opening brace, I don't see this as reason to block the MP.

LGTM

review: Approve (code review, no test)
10. By Leonardo Pistone

[imp] poor man's refresh

Revision history for this message
Leonardo Pistone (lepistone) wrote :

I added a "poor man's refresh" so that the whole MO is refreshed when my button is pressed, and we can see the new line we created as well.

This seems to work, but please let me know if it makes sense to you.

Thanks!

11. By Leonardo Pistone

[add] i18n

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

l265 missing context propagation

fr po file should be named fr.po instead of fr_FR.po otherwise I suspect that fr translation won't be loaded

Could you can also translate those terms:

msgid "Quantity needs to be more that 1."
msgstr "La quantité doit être plus grande que 1."

msgid "You can not move products from or to a location of the type view."
msgstr "Vous ne pouvez pas déplacer un produit vers ou depuis un emplacement de type vue."

msgid "Error"

l249 orm.Model instead of osv.osv (already deprecated in 6.1)

review: Needs Fixing (code review, no tests)
12. By Leonardo Pistone

[imp] context propagation, new-style model, docstrings

13. By Leonardo Pistone

[imp] split one: translations

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks for your review Yannick. Fixed.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Please use full path for import

from openerp.osv import orm

review: Needs Fixing (code review, no tests)
14. By Leonardo Pistone

[fix] import

15. By Leonardo Pistone

[imp] noqa

Revision history for this message
Leonardo Pistone (lepistone) wrote :

fixed, thanks

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

Thanks for the contribs ! LGTM

Joël

review: Approve (code review, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'mrp_split_one'
2=== added file 'mrp_split_one/__init__.py'
3--- mrp_split_one/__init__.py 1970-01-01 00:00:00 +0000
4+++ mrp_split_one/__init__.py 2014-01-17 11:03:38 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+###############################################################################
8+# #
9+# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
10+# Copyright 2013 Camptocamp SA #
11+# #
12+# This program is free software: you can redistribute it and/or modify #
13+# it under the terms of the GNU Affero General Public License as #
14+# published by the Free Software Foundation, either version 3 of the #
15+# License, or (at your option) any later version. #
16+# #
17+# This program is distributed in the hope that it will be useful, #
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20+# GNU Affero General Public License for more details. #
21+# #
22+# You should have received a copy of the GNU Affero General Public License #
23+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24+# #
25+###############################################################################
26+
27+from . import stock # noqa
28
29=== added file 'mrp_split_one/__openerp__.py'
30--- mrp_split_one/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ mrp_split_one/__openerp__.py 2014-01-17 11:03:38 +0000
32@@ -0,0 +1,41 @@
33+# -*- coding: utf-8 -*-
34+###############################################################################
35+# #
36+# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
37+# Copyright 2013 Camptocamp SA #
38+# #
39+# This program is free software: you can redistribute it and/or modify #
40+# it under the terms of the GNU Affero General Public License as #
41+# published by the Free Software Foundation, either version 3 of the #
42+# License, or (at your option) any later version. #
43+# #
44+# This program is distributed in the hope that it will be useful, #
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
47+# GNU Affero General Public License for more details. #
48+# #
49+# You should have received a copy of the GNU Affero General Public License #
50+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
51+# #
52+###############################################################################
53+
54+{'name': 'MRP Split One',
55+ 'version': '0.1',
56+ 'category': 'Generic Modules/Others',
57+ 'license': 'AGPL-3',
58+ 'description': """MRP Split one unit in a production order.
59+
60+This module adds a button in each line of the Products to Finish and Finished
61+Products to directly split one unit of the product in a separate line.
62+After the split the page needs to be reloaded because of the bug lp:1083253.
63+""",
64+ 'complexity': 'easy',
65+ 'author': 'Camptocamp',
66+ 'website': 'http://www.camptocamp.com/',
67+ 'depends': ['mrp'],
68+ 'init_xml': [],
69+ 'update_xml': ['mrp_view.xml'],
70+ 'demo_xml': [],
71+ 'installable': True,
72+ 'active': False,
73+ }
74
75=== added directory 'mrp_split_one/i18n'
76=== added file 'mrp_split_one/i18n/fr.po'
77--- mrp_split_one/i18n/fr.po 1970-01-01 00:00:00 +0000
78+++ mrp_split_one/i18n/fr.po 2014-01-17 11:03:38 +0000
79@@ -0,0 +1,54 @@
80+# Translation of OpenERP Server.
81+# This file contains the translation of the following modules:
82+# * mrp_split_one
83+#
84+msgid ""
85+msgstr ""
86+"Project-Id-Version: OpenERP Server 6.1\n"
87+"Report-Msgid-Bugs-To: \n"
88+"POT-Creation-Date: 2013-12-16 15:40+0000\n"
89+"PO-Revision-Date: 2013-12-16 15:40+0000\n"
90+"Last-Translator: <>\n"
91+"Language-Team: \n"
92+"MIME-Version: 1.0\n"
93+"Content-Type: text/plain; charset=UTF-8\n"
94+"Content-Transfer-Encoding: \n"
95+"Plural-Forms: \n"
96+
97+#. module: mrp_split_one
98+#: model:ir.model,name:mrp_split_one.model_stock_move
99+msgid "Stock Move"
100+msgstr "Mouvement de stock"
101+
102+#. module: mrp_split_one
103+#: code:addons/mrp_split_one/stock.py:36
104+#, python-format
105+msgid "Quantity needs to be more that 1."
106+msgstr "La quantité doit être plus grande que 1."
107+
108+#. module: mrp_split_one
109+#: constraint:stock.move:0
110+msgid "You can not move products from or to a location of the type view."
111+msgstr "Vous ne pouvez pas déplacer un produit vers ou depuis un emplacement de type vue."
112+
113+#. module: mrp_split_one
114+#: constraint:stock.move:0
115+msgid "You must assign a production lot for this product"
116+msgstr "Vous devez affecter un lot de fabrication pour ce produit."
117+
118+#. module: mrp_split_one
119+#: constraint:stock.move:0
120+msgid "You try to assign a lot which is not from the same product"
121+msgstr "Vous essayez d'affecter un lot qui n'est pas pour ce produit."
122+
123+#. module: mrp_split_one
124+#: view:mrp.production:0
125+msgid "Split One"
126+msgstr "Split One"
127+
128+#. module: mrp_split_one
129+#: code:addons/mrp_split_one/stock.py:35
130+#, python-format
131+msgid "Error"
132+msgstr "Erreur"
133+
134
135=== added file 'mrp_split_one/i18n/mrp_split_one.pot'
136--- mrp_split_one/i18n/mrp_split_one.pot 1970-01-01 00:00:00 +0000
137+++ mrp_split_one/i18n/mrp_split_one.pot 2014-01-17 11:03:38 +0000
138@@ -0,0 +1,54 @@
139+# Translation of OpenERP Server.
140+# This file contains the translation of the following modules:
141+# * mrp_split_one
142+#
143+msgid ""
144+msgstr ""
145+"Project-Id-Version: OpenERP Server 6.1\n"
146+"Report-Msgid-Bugs-To: \n"
147+"POT-Creation-Date: 2013-12-16 15:36+0000\n"
148+"PO-Revision-Date: 2013-12-16 15:36+0000\n"
149+"Last-Translator: <>\n"
150+"Language-Team: \n"
151+"MIME-Version: 1.0\n"
152+"Content-Type: text/plain; charset=UTF-8\n"
153+"Content-Transfer-Encoding: \n"
154+"Plural-Forms: \n"
155+
156+#. module: mrp_split_one
157+#: model:ir.model,name:mrp_split_one.model_stock_move
158+msgid "Stock Move"
159+msgstr ""
160+
161+#. module: mrp_split_one
162+#: code:addons/mrp_split_one/stock.py:36
163+#, python-format
164+msgid "Quantity needs to be more that 1."
165+msgstr ""
166+
167+#. module: mrp_split_one
168+#: constraint:stock.move:0
169+msgid "You can not move products from or to a location of the type view."
170+msgstr ""
171+
172+#. module: mrp_split_one
173+#: constraint:stock.move:0
174+msgid "You must assign a production lot for this product"
175+msgstr ""
176+
177+#. module: mrp_split_one
178+#: constraint:stock.move:0
179+msgid "You try to assign a lot which is not from the same product"
180+msgstr ""
181+
182+#. module: mrp_split_one
183+#: view:mrp.production:0
184+msgid "Split One"
185+msgstr ""
186+
187+#. module: mrp_split_one
188+#: code:addons/mrp_split_one/stock.py:35
189+#, python-format
190+msgid "Error"
191+msgstr ""
192+
193
194=== added file 'mrp_split_one/mrp_view.xml'
195--- mrp_split_one/mrp_view.xml 1970-01-01 00:00:00 +0000
196+++ mrp_split_one/mrp_view.xml 2014-01-17 11:03:38 +0000
197@@ -0,0 +1,21 @@
198+<?xml version="1.0" encoding="utf-8"?>
199+<openerp>
200+ <data>
201+
202+ <record id="mrp_production_form_lot_attribute_view" model="ir.ui.view">
203+ <field name="name">mrp.production.lot.attribute.form</field>
204+ <field name="model">mrp.production</field>
205+ <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
206+ <field name="type">form</field>
207+ <field name="arch" type="xml">
208+ <xpath expr="/form/notebook/page[@string='Finished Products']/field[@name='move_created_ids']/tree/button[@string='Scrap Products']" position="after">
209+ <button name="split_one_to_finish" string="Split One" type="object" icon="gtk-jump-to"/>
210+ </xpath>
211+ <xpath expr="/form/notebook/page[@string='Finished Products']/field[@name='move_created_ids2']/tree/button[@string='Scrap Products']" position="after">
212+ <button name="split_one_finished" string="Split One" type="object" icon="gtk-jump-to"/>
213+ </xpath>
214+ </field>
215+ </record>
216+
217+ </data>
218+</openerp>
219
220=== added file 'mrp_split_one/stock.py'
221--- mrp_split_one/stock.py 1970-01-01 00:00:00 +0000
222+++ mrp_split_one/stock.py 2014-01-17 11:03:38 +0000
223@@ -0,0 +1,79 @@
224+# -*- coding: utf-8 -*-
225+###############################################################################
226+# #
227+# Author: Leonardo Pistone <leonardo.pistone@camptocamp.com> #
228+# Copyright 2013 Camptocamp SA #
229+# #
230+# This program is free software: you can redistribute it and/or modify #
231+# it under the terms of the GNU Affero General Public License as #
232+# published by the Free Software Foundation, either version 3 of the #
233+# License, or (at your option) any later version. #
234+# #
235+# This program is distributed in the hope that it will be useful, #
236+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
237+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
238+# GNU Affero General Public License for more details. #
239+# #
240+# You should have received a copy of the GNU Affero General Public License #
241+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
242+# #
243+###############################################################################
244+"""MRP Split one unit in a production order."""
245+from openerp.osv import orm
246+from tools.translate import _
247+
248+
249+class stock_move(orm.Model):
250+
251+ """We add to the stock.move methods for the split one button."""
252+
253+ _inherit = 'stock.move'
254+
255+ def split_one(self, cr, uid, ids, context=None):
256+ """Split the current move creating one with quantity one.
257+
258+ Return action.
259+
260+ """
261+
262+ if context is None:
263+ context = {}
264+
265+ for move in self.browse(cr, uid, ids, context=context):
266+ if move.product_qty <= 1.0:
267+ raise orm.except_orm(
268+ _('Error'),
269+ _('Quantity needs to be more that 1.')
270+ )
271+
272+ self.write(cr, uid, move.id, {
273+ 'product_qty': move.product_qty - 1.0,
274+ 'product_uos_qty': move.product_uos_qty - 1.0,
275+ }, context=context)
276+ default_val = {
277+ 'product_qty': 1.0,
278+ 'product_uos_qty': 1.0,
279+ 'state': move.state,
280+ 'prodlot_id': False,
281+ }
282+ #create the new move
283+ self.copy(cr, uid, move.id, default_val, context=context)
284+
285+ # poor man's refresh
286+ return {
287+ 'view_type': 'form',
288+ 'view_mode': 'form',
289+ 'res_model': 'mrp.production',
290+ 'type': 'ir.actions.act_window',
291+ 'target': 'current',
292+ 'context': context,
293+ 'res_id': move.production_id.id,
294+ }
295+
296+ def split_one_finished(self, cr, uid, ids, context=None):
297+ """Split one unit from the finished products. Return action."""
298+ return self.split_one(cr, uid, ids, context=context)
299+
300+ def split_one_to_finish(self, cr, uid, ids, context=None):
301+ """Split one unit from the products to finish. Return action."""
302+ return self.split_one(cr, uid, ids, context=context)

Subscribers

People subscribed via source and target branches