trytond-sale_lot/sale.py

34 lines
1.0 KiB
Python
Raw Permalink Normal View History

2018-07-27 09:35:03 +02:00
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
2014-06-05 16:24:56 +02:00
from trytond.pool import PoolMeta
from trytond.model import fields
from trytond.pyson import Eval
2019-02-26 11:03:18 +01:00
class SaleLine(metaclass=PoolMeta):
2014-06-05 16:24:56 +02:00
__name__ = 'sale.line'
product_type = fields.Function(fields.Char('Product Type'),
'on_change_with_product_type')
lot = fields.Many2One('stock.lot', 'Lot',
domain=[
('product', '=', Eval('product')),
],
states={
'invisible': ((Eval('type') != 'line')
| (Eval('product_type') == 'service')),
},
depends=['type', 'product', 'product_type'])
2023-01-24 19:39:53 +01:00
@fields.depends('product', '_parent_product.type')
2014-06-05 16:24:56 +02:00
def on_change_with_product_type(self, name=None):
if not self.product:
return
return self.product.type
def get_move(self, shipment_type):
move = super(SaleLine, self).get_move(shipment_type)
if move and self.lot:
move.lot = self.lot
return move