trytond-stock_origin_sale/shipment.py

75 lines
2.4 KiB
Python
Raw Permalink Normal View History

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.
from trytond.pool import Pool, PoolMeta
2012-07-23 13:52:17 +02: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
@classmethod
def get_origin_value(cls, shipments, name):
SaleLine = Pool().get('sale.line')
origin = super(ShipmentOut, cls).get_origin_value(shipments, name)
for shipment in shipments:
if shipment.origin_cache:
origin[shipment.id] = '%s' % shipment.origin_cache
continue
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']
@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']
2018-09-15 16:02:31 +02:00
class ShipmentOutReturn(metaclass=PoolMeta):
__name__ = 'stock.shipment.out.return'
@classmethod
def get_origin_value(cls, shipments, name):
SaleLine = Pool().get('sale.line')
2018-02-21 16:12:27 +01:00
origin = super(ShipmentOutReturn, cls).get_origin_value(
shipments, name)
for shipment in shipments:
if shipment.origin_cache:
origin[shipment.id] = '%s' % shipment.origin_cache
continue
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']
@classmethod
def _get_searcher_number(cls):
2018-02-21 16:12:27 +01:00
return super(ShipmentOutReturn, cls)._get_searcher_number() + [
'sale.sale']
@classmethod
def _get_searcher_reference(cls):
2018-02-21 16:12:27 +01:00
return super(ShipmentOutReturn, cls)._get_searcher_reference() + [
'sale.sale']