Files
tryton/product.py
T

42 lines
1.3 KiB
Python
Raw Normal View History

2012-05-13 23:12:11 +02:00
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
2012-09-24 22:18:21 +02:00
from trytond.model import ModelSQL, fields
2012-05-13 23:12:11 +02:00
from trytond.pyson import Eval
2012-09-24 22:18:21 +02:00
from trytond.pool import PoolMeta
__all__ = ['Template', 'Product', 'TemplateLotType']
__metaclass__ = PoolMeta
2012-05-13 23:12:11 +02:00
2012-09-24 22:18:21 +02:00
class Template:
__name__ = 'product.template'
2012-05-13 23:12:11 +02:00
# TODO to replace with a Multiple Selection
lot_required = fields.Many2Many('product.template-stock.lot.type',
'template', 'type', 'Lot Required',
help='The type of location for which lot is required',
states={
'invisible': ~Eval('type').in_(['goods', 'assets']),
},
depends=['type'])
2012-09-24 22:18:21 +02:00
class Product:
__name__ = 'product.product'
2012-05-13 23:12:11 +02:00
2012-09-24 22:18:21 +02:00
def lot_is_required(self, from_, to):
2012-05-13 23:12:11 +02:00
'Is product lot required for move with "from_" and "to" location ?'
2012-09-24 22:18:21 +02:00
lot_required = [t.code for t in self.lot_required]
2012-05-13 23:12:11 +02:00
for location in (from_, to):
if location.type in lot_required:
return True
class TemplateLotType(ModelSQL):
'Template - Stock Lot Type'
2012-09-24 22:18:21 +02:00
__name__ = 'product.template-stock.lot.type'
2012-05-13 23:12:11 +02:00
template = fields.Many2One('product.template', 'Template', required=True,
select=True)
type = fields.Many2One('stock.lot.type', 'Type', required=True)