2018-02-21 16:12:27 +01:00
|
|
|
# This file is part stock_origin_sale module for Tryton.
|
|
|
|
# The COPYRIGHT file at the top level of this repository contains
|
|
|
|
# the full copyright notices and license terms.
|
2013-11-30 17:46:10 +01:00
|
|
|
from trytond.pool import Pool, PoolMeta
|
2012-07-23 13:52:17 +02:00
|
|
|
|
2013-12-11 22:33:41 +01:00
|
|
|
__all__ = ['ShipmentOut', 'ShipmentOutReturn']
|
2012-07-23 13:52:17 +02:00
|
|
|
|
2013-04-26 15:24:50 +02:00
|
|
|
|
2018-09-15 16:02:31 +02:00
|
|
|
class ShipmentOut(metaclass=PoolMeta):
|
2012-10-18 13:41:45 +02:00
|
|
|
__name__ = 'stock.shipment.out'
|
2012-07-23 13:52:17 +02:00
|
|
|
|
2013-11-30 17:46:10 +01:00
|
|
|
@classmethod
|
|
|
|
def get_origin_value(cls, shipments, name):
|
|
|
|
SaleLine = Pool().get('sale.line')
|
2017-06-07 12:15:58 +02:00
|
|
|
|
2013-11-30 17:46:10 +01:00
|
|
|
origin = super(ShipmentOut, cls).get_origin_value(shipments, name)
|
|
|
|
for shipment in shipments:
|
2017-06-07 12:15:58 +02:00
|
|
|
if shipment.origin_cache:
|
|
|
|
origin[shipment.id] = '%s' % shipment.origin_cache
|
|
|
|
continue
|
|
|
|
|
2013-11-30 17:46:10 +01:00
|
|
|
for m in shipment.outgoing_moves:
|
|
|
|
if m.origin and isinstance(m.origin, SaleLine):
|
|
|
|
origin[shipment.id] = 'sale.sale,%s' % (m.origin.sale.id)
|
|
|
|
break
|
|
|
|
return origin
|
|
|
|
|
2012-10-18 13:41:45 +02:00
|
|
|
@classmethod
|
|
|
|
def _get_origin(cls):
|
|
|
|
return super(ShipmentOut, cls)._get_origin() + ['sale.sale']
|
2013-12-11 22:33:41 +01:00
|
|
|
|
2017-06-07 12:15:58 +02:00
|
|
|
@classmethod
|
|
|
|
def _get_searcher_number(cls):
|
|
|
|
return super(ShipmentOut, cls)._get_searcher_number() + ['sale.sale']
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _get_searcher_reference(cls):
|
2018-02-21 16:12:27 +01:00
|
|
|
return super(ShipmentOut, cls)._get_searcher_reference() + [
|
|
|
|
'sale.sale']
|
2017-06-07 12:15:58 +02:00
|
|
|
|
2013-12-11 22:33:41 +01:00
|
|
|
|
2018-09-15 16:02:31 +02:00
|
|
|
class ShipmentOutReturn(metaclass=PoolMeta):
|
2013-12-11 22:33:41 +01:00
|
|
|
__name__ = 'stock.shipment.out.return'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_origin_value(cls, shipments, name):
|
|
|
|
SaleLine = Pool().get('sale.line')
|
2017-06-07 12:15:58 +02:00
|
|
|
|
2018-02-21 16:12:27 +01:00
|
|
|
origin = super(ShipmentOutReturn, cls).get_origin_value(
|
|
|
|
shipments, name)
|
2013-12-11 22:33:41 +01:00
|
|
|
for shipment in shipments:
|
2017-06-07 12:15:58 +02:00
|
|
|
if shipment.origin_cache:
|
|
|
|
origin[shipment.id] = '%s' % shipment.origin_cache
|
|
|
|
continue
|
|
|
|
|
2013-12-11 22:33:41 +01:00
|
|
|
for m in shipment.incoming_moves:
|
|
|
|
if m.origin and isinstance(m.origin, SaleLine):
|
|
|
|
origin[shipment.id] = 'sale.sale,%s' % (m.origin.sale.id)
|
|
|
|
break
|
|
|
|
return origin
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _get_origin(cls):
|
|
|
|
return super(ShipmentOutReturn, cls)._get_origin() + ['sale.sale']
|
2017-06-07 12:15:58 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _get_searcher_number(cls):
|
2018-02-21 16:12:27 +01:00
|
|
|
return super(ShipmentOutReturn, cls)._get_searcher_number() + [
|
|
|
|
'sale.sale']
|
2017-06-07 12:15:58 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _get_searcher_reference(cls):
|
2018-02-21 16:12:27 +01:00
|
|
|
return super(ShipmentOutReturn, cls)._get_searcher_reference() + [
|
|
|
|
'sale.sale']
|