From bc165ae2fb5d7b1241cb755fd4a0e57277abfed6 Mon Sep 17 00:00:00 2001 From: Mathieu Vatel Date: Wed, 7 Mar 2012 13:56:37 +0100 Subject: [PATCH] [ADD] stock_move_location --- stock_move_location/__init__.py | 25 +++ stock_move_location/__openerp__.py | 51 +++++ stock_move_location/i18n/fr.po | 143 ++++++++++++++ stock_move_location/stock.py | 182 ++++++++++++++++++ stock_move_location/stock_move_sequence.xml | 19 ++ stock_move_location/stock_view.xml | 67 +++++++ stock_move_location/wizard/__init__.py | 24 +++ stock_move_location/wizard/move_location.py | 46 +++++ .../wizard/move_location_view.xml | 34 ++++ 9 files changed, 591 insertions(+) create mode 100644 stock_move_location/__init__.py create mode 100644 stock_move_location/__openerp__.py create mode 100644 stock_move_location/i18n/fr.po create mode 100644 stock_move_location/stock.py create mode 100644 stock_move_location/stock_move_sequence.xml create mode 100755 stock_move_location/stock_view.xml create mode 100644 stock_move_location/wizard/__init__.py create mode 100644 stock_move_location/wizard/move_location.py create mode 100755 stock_move_location/wizard/move_location_view.xml diff --git a/stock_move_location/__init__.py b/stock_move_location/__init__.py new file mode 100644 index 000000000..c2c2ebef6 --- /dev/null +++ b/stock_move_location/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 Julius Network Solutions SARL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +################################################################################# + +import stock +import wizard + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/stock_move_location/__openerp__.py b/stock_move_location/__openerp__.py new file mode 100644 index 000000000..abb62f769 --- /dev/null +++ b/stock_move_location/__openerp__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 Julius Network Solutions SARL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +################################################################################# + +{ + "name" : "Move Stock Location", + "version" : "1.0", + "author" : "Julius Network Solutions,Odoo Community Association (OCA)", + "description" : """ + +Presentation: + +This module allows to move all stock in a stock location to an other one. +And adds fields and buttons to advance in Physical Inventories. + +""", + "website" : "http://www.julius.fr", + "depends" : [ + "stock", + "stock_barcode_reader", + ], + "category" : "Customs/Stock", + "init_xml" : [], + "demo_xml" : [], + "update_xml" : [ + 'stock_view.xml', + 'stock_move_sequence.xml', + 'wizard/move_location_view.xml', + ], + 'test': [], + 'installable': True, + 'active': False, + 'certificate': '', +} diff --git a/stock_move_location/i18n/fr.po b/stock_move_location/i18n/fr.po new file mode 100644 index 000000000..3c1f45c79 --- /dev/null +++ b/stock_move_location/i18n/fr.po @@ -0,0 +1,143 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_move_location +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.3\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-12-19 10:48+0000\n" +"PO-Revision-Date: 2011-12-19 10:48+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_move_location +#: field:stock.inventory,location_id:0 +msgid "Location" +msgstr "Stockage" + +#. module: stock_move_location +#: view:stock.inventory:0 +msgid "Start Acquisition" +msgstr "Demarrer la saisie" + +#. module: stock_move_location +#: view:stock.inventory:0 +msgid "Get Stock" +msgstr "Remplir" + +#. module: stock_move_location +#: view:stock.inventory:0 +msgid "Validate Move" +msgstr "Valider le transfert" + +#. module: stock_move_location +#: model:ir.model,name:stock_move_location.model_stock_fill_inventory +msgid "Import Inventory" +msgstr "Importer un inventaire" + +#. module: stock_move_location +#: code:addons/stock_move_location/stock.py:54 +#, python-format +msgid "Error !" +msgstr "Erreur !" + +#. module: stock_move_location +#: constraint:stock.move:0 +msgid "You try to assign a lot which is not from the same product" +msgstr "Vous essayez d'affecter un lot qui n'est pas pour le bon produit." + +#. module: stock_move_location +#: model:ir.model,name:stock_move_location.model_stock_move +msgid "Stock Move" +msgstr "Transfert de Stock à Stock" + +#. module: stock_move_location +#: model:ir.module.module,description:stock_move_location.module_meta_information +msgid " This module allows to move all stock in a stock location to an other one " +msgstr " Ce module permet de déplacer tout le stock situé dans un ou plusieurs emplacement vers un autre emplacement " + +#. module: stock_move_location +#: field:stock.inventory,location_dest_id:0 +msgid "Destination Location" +msgstr "Emplacement de destination" + +#. module: stock_move_location +#: model:ir.actions.act_window,name:stock_move_location.action_move_stock_form +#: model:ir.ui.menu,name:stock_move_location.menu_action_move_stock_form +msgid "Move stock" +msgstr "Transfert de Stock à Stock" + +#. module: stock_move_location +#: code:addons/stock_move_location/stock.py:70 +#, python-format +msgid "Move" +msgstr "Transfert" + +#. module: stock_move_location +#: view:stock.inventory:0 +msgid "Confirm Inventory" +msgstr "Confirmer l'inventaire" + +#. module: stock_move_location +#: field:stock.inventory,comments:0 +msgid "Comments" +msgstr "Commentaires" + +#. module: stock_move_location +#: constraint:stock.move:0 +msgid "You must assign a production lot for this product" +msgstr "Vous devez affecter un lot de fabrication pour ce produit." + +#. module: stock_move_location +#: selection:stock.inventory,type:0 +msgid "Location Move" +msgstr "Transfert de Stock à Stock" + +#. module: stock_move_location +#: view:stock.inventory:0 +msgid "Move Stock" +msgstr "Transfert de Stock à Stock" + +#. module: stock_move_location +#: model:ir.model,name:stock_move_location.model_stock_inventory +#: selection:stock.inventory,type:0 +msgid "Inventory" +msgstr "Inventaire" + +#. module: stock_move_location +#: code:addons/stock_move_location/stock.py:54 +#, python-format +msgid "Please inform the destination of your move" +msgstr "S'il vous plaît informer la destination de votre transfert" + +#. module: stock_move_location +#: code:addons/stock_move_location/stock.py:70 +#, python-format +msgid "is done." +msgstr "est fait." + +#. module: stock_move_location +#: field:stock.inventory,type:0 +msgid "Type" +msgstr "Type" + +#. module: stock_move_location +#: model:ir.module.module,shortdesc:stock_move_location.module_meta_information +msgid "Move Stock Location" +msgstr "Tranfert de stock à stock" + +#. module: stock_move_location +#: model:ir.actions.act_window,help:stock_move_location.action_move_stock_form +msgid "You can use this to move a stock from a location to an other one." +msgstr "Vous pouvez l'utiliser pour passer d'un stockage vers un autre." + +#. module: stock_move_location +#: field:stock.move,pack_history_id:0 +msgid "History pack" +msgstr "Historique du colis" + diff --git a/stock_move_location/stock.py b/stock_move_location/stock.py new file mode 100644 index 000000000..be0a5ae2e --- /dev/null +++ b/stock_move_location/stock.py @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 Julius Network Solutions SARL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +################################################################################# + +from osv import fields, osv +from tools.translate import _ + +#class stock_fill_inventory(osv.osv_memory): +# _inherit = "stock.fill.inventory" +# def fill_inventory(self, cr, uid, ids, context=None): +# res = super(stock_fill_inventory, self).fill_inventory(cr, uid, ids, context=context) +# stock_inventory_obj = self.pool.get('stock.inventory') +# fill_inventory = self.browse(cr, uid, ids[0], context=context) +# if stock_inventory_obj.browse(cr, uid, context.get('active_id', False), context).location_id: +# stock_inventory_obj.write(cr, uid, context.get('active_id', False), {'location_id': fill_inventory.location_id.id}) +# return res +#stock_fill_inventory() + +class stock_inventory(osv.osv): + _inherit = "stock.inventory" + + _columns = { + 'type': fields.selection([('normal', 'Inventory'),('move', 'Location Move')], 'Type'), + 'location_id': fields.many2one('stock.location', 'Location'), + 'location_dest_id': fields.many2one('stock.location', 'Destination Location'), + 'comments':fields.text('Comments'), + } + + def get_sequence(self, cr , uid, context): + if context.get('type', False) == 'move': + return self.pool.get('ir.sequence').get(cr, uid, 'stock.inventory.move') or '/' + else: + return self.pool.get('ir.sequence').get(cr, uid, 'stock.inventory') or '/' + + _defaults = { + 'type': lambda *a: 'normal', + 'name': lambda x, y, z, c: x.get_sequence(y,z,c), + } + + def move_stock(self, cr, uid, ids, context=None): + if context is None: + context = {} + product_context = dict(context, compute_child=False) + + location_obj = self.pool.get('stock.location') + for inv in self.browse(cr, uid, ids, context=context): + if not inv.location_dest_id: + raise osv.except_osv(_('Error !'), _('Please inform the destination of your move')) + move_ids = [] + for line in inv.inventory_line_id: + location_id = inv.location_dest_id.id + date = line.date or inv.date + value = { + 'name': 'MOVE:' + str(line.inventory_id.id) + ':' + line.inventory_id.name, + 'product_id': line.product_id.id, + 'product_uom': line.product_uom.id, + 'prodlot_id': line.prod_lot_id.id, + 'date': date, + 'product_qty': line.product_qty, + 'location_id': line.location_id.id, + 'location_dest_id': location_id, + 'note': line.note or inv.comments or False, + } + move_ids.append(self._inventory_line_hook(cr, uid, line, value)) + message = _('Move') + " '" + inv.name + "' "+ _("is done.") + self.log(cr, uid, inv.id, message) + self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]}) + return True + + def fill_inventory(self, cr, uid, ids, context=False): + res = {} + stock_fill_inventory_obj = self.pool.get('stock.fill.inventory') + inventory_data = self.browse(cr, uid, ids[0], context) + if context.get('type',[]) == 'move': + set_stock_zero = False + else: + set_stock_zero = True + if inventory_data.location_id: + context['location_id'] = inventory_data.location_id.id + fill_inventory_id = stock_fill_inventory_obj.create(cr, uid, { + 'location_id': inventory_data.location_id.id, + 'set_stock_zero': set_stock_zero}) + context_temp = context + context_temp['active_ids'] = [inventory_data.id] + context_temp['active_id'] = inventory_data.id + stock_fill_inventory_obj.fill_inventory(cr, uid, [fill_inventory_id], context_temp) + + + if context.get('type',[]) == 'move': + act = {} +# mod_obj = self.pool.get('ir.model.data') +# act_obj = self.pool.get('ir.actions.act_window') +# model_id = mod_obj.search(cr, uid, [('name', '=', 'move_stock_acquisition_link_2')])[0] +# act_id = mod_obj.read(cr, uid, model_id, ['res_id'])['res_id'] +# act = act_obj.read(cr, uid, act_id) + else: + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + model_id = mod_obj.search(cr, uid, [('name', '=', 'inventory_acquisition_link_1')])[0] + act_id = mod_obj.read(cr, uid, model_id, ['res_id'])['res_id'] + act = act_obj.read(cr, uid, act_id) + context = eval(act['context']) + context['default_inventory_id'] = inventory_data.id + context['default_name'] = inventory_data.name + act['context'] = context + return act + + +stock_inventory() + +class stock_move(osv.osv): + + _inherit = 'stock.move' + +# def _check_move(self, cr, uid, ids, context=None): +# """ Checks if the given production lot belong to a pack +# Return false if the production lot is in a pack +# """ +# production_lot_obj = self.pool.get('stock.production.lot') +# +# for move in self.browse(cr, uid, ids, context=context): +# if move.prodlot_id: +# if self.search(cr, uid, [('prodlot_id', '=', move.prodlot_id.id), ('state','not in',('cancel','done')), ('id', '!=', move.id)]): +# if move.prodlot_id.tracking_id: +# return False +# return True + + _columns = { + 'pack_history_id': fields.many2one('stock.tracking.history', 'History pack'), + } + +# _constraints =[ +# (_check_move, 'You try to assign a move to a lot which is already in a pack', ['prodlot_id']) +# ] + ''' Solution to move all pack and production lot if one in a pack is move ''' +# def move_parent(self, cr, uid, ids, context=None): +# """ Checks if the given production lot belong to a pack +# Move the pack in the same destination +# """ +# ''' variables ''' +# production_lot_obj = self.pool.get('stock.production.lot') +# move_packaging_obj = self.pool.get('stock.move.packaging') +# ''' init ''' +# if context == None: +# context = {} +# ''' process ''' +# for move in self.browse(cr, uid, ids, context=context): +# if move.prodlot_id: +# if move.prodlot_id.tracking_id: +# move_packaging_obj.move_pack(cr, uid, move.prodlot_id.tracking_id, context) +# return {} + +stock_move() + +class stock_inventory_line(osv.osv): + _inherit = "stock.inventory.line" + + _columns = { + 'date': fields.datetime('Date'), + 'note': fields.text('Notes'), + } + +stock_inventory_line() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/stock_move_location/stock_move_sequence.xml b/stock_move_location/stock_move_sequence.xml new file mode 100644 index 000000000..21d53d51a --- /dev/null +++ b/stock_move_location/stock_move_sequence.xml @@ -0,0 +1,19 @@ + + + + + + + Inventory Order + stock.inventory.move + + + + Inventory Order + stock.inventory.move + MOV + 3 + + + + diff --git a/stock_move_location/stock_view.xml b/stock_move_location/stock_view.xml new file mode 100755 index 000000000..89ad954f3 --- /dev/null +++ b/stock_move_location/stock_view.xml @@ -0,0 +1,67 @@ + + + + + + stock.inventory.tree + stock.inventory + tree + + + + + + + + + + stock.inventory.form + stock.inventory + form + + + + + + + + + + + + + + {'full':'1', 'type':'normal', 'default_type': 'normal'} + [('type', '=', 'normal')] + + + + [('state','=','draft'), ('type', '=', 'normal')] + + + + Move stock + ir.actions.act_window + stock.inventory + form + + {'full':'1', 'type':'move', 'default_type': 'move'} + [('type', '=', 'move')] + + You can use this to move a stock from a location to an other one. + + + + + + diff --git a/stock_move_location/wizard/__init__.py b/stock_move_location/wizard/__init__.py new file mode 100644 index 000000000..4096c452a --- /dev/null +++ b/stock_move_location/wizard/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 Julius Network Solutions SARL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +################################################################################# + +import move_location + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/stock_move_location/wizard/move_location.py b/stock_move_location/wizard/move_location.py new file mode 100644 index 000000000..a27155d2a --- /dev/null +++ b/stock_move_location/wizard/move_location.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +################################################################################# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 Julius Network Solutions SARL +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +################################################################################# + +from osv import fields, osv +from tools.translate import _ + +class stock_fill_inventory(osv.osv_memory): + _inherit = "stock.fill.inventory" + + def _get_location(self, cr, uid, active_id, context={}): + res = False + if active_id: + inv = self.pool.get('stock.inventory').browse(cr, uid, active_id) + if inv.location_id: + res = inv.location_id.id + return res + + _columns = { + 'location_id': fields.many2one('stock.location', 'Location', required=True), + } + + _defaults = { + 'location_id': lambda s,cr,uid,c: s._get_location(cr, uid, c.get('active_id',False), c), + } + +stock_fill_inventory() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/stock_move_location/wizard/move_location_view.xml b/stock_move_location/wizard/move_location_view.xml new file mode 100755 index 000000000..88c70a085 --- /dev/null +++ b/stock_move_location/wizard/move_location_view.xml @@ -0,0 +1,34 @@ + + + + + + + +