mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] New module <stock_quant_merge> closes #693
First upload, merge quants
This commit is contained in:
6
models/__init__.py
Normal file
6
models/__init__.py
Normal 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
29
models/stock.py
Normal 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
|
||||
Reference in New Issue
Block a user