trytond-stock_delivery_date/sale.py

32 lines
973 B
Python
Raw Permalink Normal View History

2014-11-07 14:43:57 +01:00
# This file is part stock_delivery_date module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
2014-02-06 12:48:18 +01:00
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
2014-02-06 12:48:18 +01:00
__all__ = ['Sale']
2018-10-15 23:48:08 +02:00
class Sale(metaclass=PoolMeta):
2014-02-06 12:48:18 +01:00
__name__ = 'sale.sale'
delivery_date = fields.DateTime('Delivery Date',
states={
'readonly': ~Eval('state').in_(['draft', 'quotation']),
},
depends=['state'])
def create_shipment(self, shipment_type):
pool = Pool()
shipments = super(Sale, self).create_shipment(shipment_type)
if shipment_type != 'out' or not shipments:
return
ShipmentOut = pool.get('stock.shipment.out')
if self.delivery_date:
ShipmentOut.write(shipments, {
'delivery_date': self.delivery_date,
})
return shipments