Remove stock_product_location depends

This commit is contained in:
Raimon Esteve 2017-01-05 13:25:28 +01:00
parent a77d6828fc
commit ef17b2c1a4
2 changed files with 3 additions and 39 deletions

View file

@ -1,5 +1,5 @@
#This file is part stock_relocation module for Tryton.
#The COPYRIGHT file at the top level of this repository contains
#The COPYRIGHT file at the top level of this repository contains
#the full copyright notices and license terms.
from trytond.model import ModelSQL, ModelView, fields
from trytond.pool import Pool
@ -190,25 +190,6 @@ class StockRelocation(ModelSQL, ModelView):
move.unit_price = relocation.product.list_price
return move
@classmethod
def _get_warehouse(cls, location):
if location.type == 'warehouse':
return location
if location.parent:
return cls._get_warehouse(location.parent)
return None
@classmethod
def get_product_location(cls, product, location):
ProductLocation = Pool().get('stock.product.location')
prodloc = ProductLocation()
prodloc.product = product
prodloc.warehouse = cls._get_warehouse(location)
prodloc.location = location
prodloc.sequence = 999
return prodloc
@classmethod
@ModelView.button
def confirm(cls, relocations):
@ -216,7 +197,6 @@ class StockRelocation(ModelSQL, ModelView):
Date = pool.get('ir.date')
Product = pool.get('product.product')
Move = pool.get('stock.move')
ProductLocation = pool.get('stock.product.location')
today = Date.today()
location_ids = set()
@ -225,7 +205,7 @@ class StockRelocation(ModelSQL, ModelView):
for r in relocations:
location_ids.add(r.from_location.id)
products_ids.add(r.product.id)
with Transaction().set_context(forecast=False, stock_date_end=today):
pbl = Product.products_by_location(list(location_ids),
list(products_ids), grouping=('product',))
@ -259,22 +239,6 @@ class StockRelocation(ModelSQL, ModelView):
move = cls._get_move(r)
to_create.append(move)
to_location = r.to_location
locations = [l.location for l in product.locations]
#new product location
if not to_location in locations:
prodloc = cls.get_product_location(product, to_location)
prodloc.save()
#delete from_location if same warehouse to_location
if r.quantity == qty:
from_warehouse = cls._get_warehouse(from_location)
to_warehouse = cls._get_warehouse(to_location)
if from_warehouse == to_warehouse:
loc_to_delete = [l for l in product.locations if l.location == from_location]
if loc_to_delete:
ProductLocation.delete(loc_to_delete)
if to_create:
moves = Move.create([c._save_values for c in to_create])
Move.do(moves)

View file

@ -1,7 +1,7 @@
[tryton]
version=4.1.0
depends:
stock_product_location
stock
xml:
configuration.xml
stock_relocation.xml