← Back to team overview

openerp-community-reviewer team mailing list archive

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

 

Leonardo Pistone @ camptocamp has proposed merging lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep into lp:openerp-manufacturing/6.1.

Requested reviews:
  Manufacture Core Editors (manufacture-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep/+merge/197474

Hi,

this is to add a new module: mrp_split_one.

Thanks!
-- 
https://code.launchpad.net/~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep/+merge/197474
Your team Manufacture Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_one-2-lep into lp:openerp-manufacturing/6.1.
=== added directory 'mrp_split_one'
=== added file 'mrp_split_one/__init__.py'
--- mrp_split_one/__init__.py	1970-01-01 00:00:00 +0000
+++ mrp_split_one/__init__.py	2013-12-03 08:51:07 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#                                                                             #
+#   Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx>                #
+#   Copyright 2013 Camptocamp SA                                              #
+#                                                                             #
+#   This program is free software: you can redistribute it and/or modify      #
+#   it under the terms of the GNU Affero General Public License as            #
+#   published by the Free Software Foundation, either version 3 of the        #
+#   License, or (at your option) any later version.                           #
+#                                                                             #
+#   This program is distributed in the hope that it will be useful,           #
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of            #
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
+#   GNU Affero General Public License for more details.                       #
+#                                                                             #
+#   You should have received a copy of the GNU Affero General Public License  #
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.     #
+#                                                                             #
+###############################################################################
+
+from . import stock

=== added file 'mrp_split_one/__openerp__.py'
--- mrp_split_one/__openerp__.py	1970-01-01 00:00:00 +0000
+++ mrp_split_one/__openerp__.py	2013-12-03 08:51:07 +0000
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#                                                                             #
+#   Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx>                #
+#   Copyright 2013 Camptocamp SA                                              #
+#                                                                             #
+#   This program is free software: you can redistribute it and/or modify      #
+#   it under the terms of the GNU Affero General Public License as            #
+#   published by the Free Software Foundation, either version 3 of the        #
+#   License, or (at your option) any later version.                           #
+#                                                                             #
+#   This program is distributed in the hope that it will be useful,           #
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of            #
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
+#   GNU Affero General Public License for more details.                       #
+#                                                                             #
+#   You should have received a copy of the GNU Affero General Public License  #
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.     #
+#                                                                             #
+###############################################################################
+
+{'name': 'MRP Split One',
+ 'version': '0.1',
+ 'category': 'Generic Modules/Others',
+ 'license': 'AGPL-3',
+ 'description': """MRP Split one unit in a prodution order.
+
+This module adds a button in each line of the Products to Finish and Finished
+Products to directly split one unit of the product in a separate line.
+After the split the page needs to be reloaded because of the bug lp:1083253.
+""",
+ 'complexity': 'easy',
+ 'author': 'Camptocamp',
+ 'website': 'http://www.camptocamp.com/',
+ 'depends': ['mrp'],
+ 'init_xml': [],
+ 'update_xml': ['mrp_view.xml'],
+ 'demo_xml': [],
+ 'installable': True,
+ 'active': False,
+ }

=== added file 'mrp_split_one/mrp_view.xml'
--- mrp_split_one/mrp_view.xml	1970-01-01 00:00:00 +0000
+++ mrp_split_one/mrp_view.xml	2013-12-03 08:51:07 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="mrp_production_form_lot_attribute_view" model="ir.ui.view">
+            <field name="name">mrp.production.lot.attribute.form</field>
+            <field name="model">mrp.production</field>
+            <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <xpath expr="/form/notebook/page[@string='Finished Products']/field[@name='move_created_ids']/tree/button[@string='Scrap Products']" position="after">
+                    <button name="split_one_to_finish" string="Split One" type="object" icon="gtk-jump-to"/>
+                </xpath>
+                <xpath expr="/form/notebook/page[@string='Finished Products']/field[@name='move_created_ids2']/tree/button[@string='Scrap Products']" position="after">
+                    <button name="split_one_finished" string="Split One" type="object" icon="gtk-jump-to"/>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'mrp_split_one/stock.py'
--- mrp_split_one/stock.py	1970-01-01 00:00:00 +0000
+++ mrp_split_one/stock.py	2013-12-03 08:51:07 +0000
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#                                                                             #
+#   Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx>                #
+#   Copyright 2013 Camptocamp SA                                              #
+#                                                                             #
+#   This program is free software: you can redistribute it and/or modify      #
+#   it under the terms of the GNU Affero General Public License as            #
+#   published by the Free Software Foundation, either version 3 of the        #
+#   License, or (at your option) any later version.                           #
+#                                                                             #
+#   This program is distributed in the hope that it will be useful,           #
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of            #
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
+#   GNU Affero General Public License for more details.                       #
+#                                                                             #
+#   You should have received a copy of the GNU Affero General Public License  #
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.     #
+#                                                                             #
+###############################################################################
+
+from osv import osv
+from tools.translate import _
+
+
+class stock_move(osv.osv):
+    _inherit = 'stock.move'
+
+    def split_one(self, cr, uid, ids, context=None):
+        """Split the current move creating one with quantity one."""
+
+        for move in self.browse(cr, uid, ids, context=context):
+            if move.product_qty <= 1.0:
+                raise osv.except_osv(
+                    _('Error'),
+                    _('Quantity needs to be more that 1.')
+                )
+
+            self.write(cr, uid, move.id, {
+                'product_qty': move.product_qty - 1.0,
+                'product_uos_qty': move.product_uos_qty - 1.0,
+            })
+            default_val = {
+                'product_qty': 1.0,
+                'product_uos_qty': 1.0,
+                'state': move.state,
+                'prodlot_id': False,
+            }
+            #create the new move
+            self.copy(cr, uid, move.id, default_val, context=context)
+
+        return True
+
+    def split_one_finished(self, cr, uid, ids, context=None):
+        return self.split_one(cr, uid, ids, context=context)
+
+    def split_one_to_finish(self, cr, uid, ids, context=None):
+        return self.split_one(cr, uid, ids, context=context)


Follow ups