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 .location import ProductCategoryLocation, Location
from .product import Category
from .stock import ShipmentOut, ShipmentIn
from .stock import ShipmentOut, ShipmentIn, ShipmentOutReturn
def register():
@ -13,4 +13,5 @@ def register():
ProductCategoryLocation,
ShipmentOut,
ShipmentIn,
ShipmentOutReturn,
module='stock_product_category_location', type_='model')

View File

@ -2,7 +2,7 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta
__all__ = ['ShipmentOut', 'ShipmentIn']
__all__ = ['ShipmentOut', 'ShipmentOutReturn', 'ShipmentIn']
class ShipmentOut:
@ -23,6 +23,26 @@ class ShipmentOut:
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:
__metaclass__ = PoolMeta
__name__ = 'stock.shipment.in'