Add default location in shipment out return.

This commit is contained in:
Sergio Morillo 2016-11-30 19:21:13 +01:00
parent 7d81b90194
commit 90e1454bf3
2 changed files with 23 additions and 2 deletions

View file

@ -3,7 +3,7 @@
from trytond.pool import Pool from trytond.pool import Pool
from .location import ProductCategoryLocation, Location from .location import ProductCategoryLocation, Location
from .product import Category from .product import Category
from .stock import ShipmentOut, ShipmentIn from .stock import ShipmentOut, ShipmentIn, ShipmentOutReturn
def register(): def register():
@ -13,4 +13,5 @@ def register():
ProductCategoryLocation, ProductCategoryLocation,
ShipmentOut, ShipmentOut,
ShipmentIn, ShipmentIn,
ShipmentOutReturn,
module='stock_product_category_location', type_='model') module='stock_product_category_location', type_='model')

View file

@ -2,7 +2,7 @@
# this repository contains the full copyright notices and license terms. # this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta from trytond.pool import PoolMeta
__all__ = ['ShipmentOut', 'ShipmentIn'] __all__ = ['ShipmentOut', 'ShipmentOutReturn', 'ShipmentIn']
class ShipmentOut: class ShipmentOut:
@ -23,6 +23,26 @@ class ShipmentOut:
return {'warehouse': self.warehouse} return {'warehouse': self.warehouse}
class ShipmentOutReturn:
__metaclass__ = PoolMeta
__name__ = 'stock.shipment.out.return'
@classmethod
def _get_inventory_moves(cls, incoming_move):
res = super(ShipmentOutReturn, cls)._get_inventory_moves(incoming_move)
for c in res.product.categories:
_to_location = c.get_default_location(
**cls._get_default_location_params(incoming_move))
if _to_location:
res.to_location = _to_location
break
return res
@classmethod
def _get_default_location_params(cls, incoming_move):
return {'warehouse': incoming_move.shipment.warehouse}
class ShipmentIn: class ShipmentIn:
__metaclass__ = PoolMeta __metaclass__ = PoolMeta
__name__ = 'stock.shipment.in' __name__ = 'stock.shipment.in'