openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #02661
lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
Leonardo Pistone @ camptocamp has proposed merging lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-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_units-lep/+merge/200544
New module mrp_split_units. Thanks!
--
https://code.launchpad.net/~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep/+merge/200544
Your team Manufacture Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1.
=== added directory 'mrp_split_units'
=== added file 'mrp_split_units/__init__.py'
--- mrp_split_units/__init__.py 1970-01-01 00:00:00 +0000
+++ mrp_split_units/__init__.py 2014-01-06 14:58:04 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+# #
+# Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx> #
+# Copyright 2014 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 # noqa
=== added file 'mrp_split_units/__openerp__.py'
--- mrp_split_units/__openerp__.py 1970-01-01 00:00:00 +0000
+++ mrp_split_units/__openerp__.py 2014-01-06 14:58:04 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+# #
+# Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx> #
+# Copyright 2014 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 Units',
+ 'version': '0.1',
+ 'category': 'Generic Modules/Others',
+ 'license': 'AGPL-3',
+ 'description': """
+MRP Split one line into many lines with quantity one each
+in a production order.
+
+This module adds a button in each line of the Products to Finish and Finished
+Products to automatically split one line with integer quantity into many lines,
+each with quantity 1. After the split, the module performs a
+"poor man's refresh" (i.e. manually reloads the page) as a workaround for 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 directory 'mrp_split_units/i18n'
=== added file 'mrp_split_units/mrp_view.xml'
--- mrp_split_units/mrp_view.xml 1970-01-01 00:00:00 +0000
+++ mrp_split_units/mrp_view.xml 2014-01-06 14:58:04 +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_units_to_finish" string="Split Units" 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_units_finished" string="Split Units" type="object" icon="gtk-jump-to"/>
+ </xpath>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'mrp_split_units/stock.py'
--- mrp_split_units/stock.py 1970-01-01 00:00:00 +0000
+++ mrp_split_units/stock.py 2014-01-06 14:58:04 +0000
@@ -0,0 +1,94 @@
+# -*- coding: utf-8 -*-
+"""Add to the stock move the methods to split MO lines."""
+###############################################################################
+# #
+# Author: Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx> #
+# Copyright 2014 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 _
+import decimal_precision as dp
+
+
+class stock_move(osv.osv):
+
+ """Stock move. Add methods to split moves in manufacturing orders."""
+
+ _inherit = 'stock.move'
+
+ def split_units(self, cr, uid, ids, context=None):
+ """Split the current move creating moves with quantity one.
+
+ Return an action to reload the current record as a poor man's refresh.
+
+ """
+
+ def almost_integer(cr, qty, int_qty):
+ return (
+ qty - int_qty < 10 ** -dp.get_precision('Product UoM')(cr)[1]
+ )
+
+ for move in self.browse(cr, uid, ids, context=context):
+ int_qty = int(move.product_qty)
+
+ if not almost_integer(cr, move.product_qty, int_qty):
+ raise osv.except_osv(
+ _('Error'),
+ _('Quantity needs to be integer.')
+ )
+
+ if int_qty <= 1:
+ raise osv.except_osv(
+ _('Error'),
+ _('Quantity needs to be more than 1.')
+ )
+
+ self.write(cr, uid, move.id, {
+ 'product_qty': 1.0,
+ '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 moves
+ for i in xrange(int_qty - 1):
+ self.copy(cr, uid, move.id, default_val, context=context)
+
+ # poor man's refresh
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'mrp.production',
+ 'type': 'ir.actions.act_window',
+ 'target': 'current',
+ 'context': context,
+ 'res_id': move.production_id.id,
+ }
+
+ def split_units_finished(self, cr, uid, ids, context=None):
+ """Split a line in the Finished Products. Return an action."""
+ return self.split_units(cr, uid, ids, context=context)
+
+ def split_units_to_finish(self, cr, uid, ids, context=None):
+ """Split a line in the Products to Finish. Return an action."""
+ return self.split_units(cr, uid, ids, context=context)
Follow ups
-
lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: noreply, 2014-01-16
-
lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-16
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-16
-
lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-16
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-16
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-16
-
lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-15
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-15
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Leonardo Pistone @ camptocamp, 2014-01-15
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-14
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Leonardo Pistone @ camptocamp, 2014-01-14
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Yannick Vaucher @ Camptocamp, 2014-01-13
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Romain Deheele - Camptocamp, 2014-01-06
-
Re: lp:~camptocamp/openerp-manufacturing/6.1-add-mrp_split_units-lep into lp:openerp-manufacturing/6.1
From: Leonardo Pistone @ camptocamp, 2014-01-06