[ADD] New module <stock_quant_merge> closes #693

First upload, merge quants
This commit is contained in:
oihane
2015-03-02 16:42:46 +01:00
commit aeeff89d92
5 changed files with 81 additions and 0 deletions

4
README.rst Normal file
View File

@@ -0,0 +1,4 @@
Quant merge
===========
This module allows to merge diferent quants if they meet some requirements.

6
__init__.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import models

36
__openerp__.py Normal file
View File

@@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# 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 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": "Stock - Quant merge",
"version": "1.0",
"depends": [
"stock",
],
"author": "OdooMRP team",
"website": "http://www.odoomrp.com",
"contributors": [
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <ajuaristio@gmail.com>"
],
"category": "Warehouse Management",
"summary": "",
"data": [],
"installable": True,
}

6
models/__init__.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import stock

29
models/stock.py Normal file
View File

@@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models, api
class StockQuant(models.Model):
_inherit = 'stock.quant'
@api.one
def merge_stock_quants(self):
if not self.reservation_id:
quants = self.search(
[('id', '!=', self.id),
('product_id', '=', self.product_id.id),
('lot_id', '=', self.lot_id.id),
('package_id', '=', self.package_id.id),
('location_id', '=', self.location_id.id),
('reservation_id', '=', False),
('propagated_from_id', '=', False)])
qty = cost = 0
for quant in quants:
qty += quant.qty
cost += quant.cost
quant.unlink()
self.cost += cost
self.qty += qty