Files
tryton/modules/stock_supply/product.py
T

31 lines
1.1 KiB
Python
Raw Normal View History

2014-12-02 12:56:15 +01: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.
2017-04-01 00:39:00 +02:00
import datetime
2012-09-24 22:18:24 +02:00
from trytond.model import fields
2021-12-11 17:58:44 +01:00
from trytond.pool import Pool, PoolMeta
2012-09-24 22:18:24 +02:00
2008-09-05 18:48:16 +02:00
2018-06-26 19:11:57 +02:00
class Product(metaclass=PoolMeta):
2012-09-24 22:18:24 +02:00
__name__ = "product.product"
2008-09-04 23:27:49 +02:00
order_points = fields.One2Many(
'stock.order_point', 'product', "Order Points", readonly=True)
@classmethod
def copy(cls, products, default=None):
default = default.copy() if default is not None else {}
default.setdefault('order_points', None)
return super().copy(products, default=default)
2016-06-21 10:11:57 +02:00
2018-06-26 19:11:57 +02:00
class ProductSupplier(metaclass=PoolMeta):
2016-06-21 10:11:57 +02:00
__name__ = 'purchase.product_supplier'
2021-04-03 14:27:10 +02:00
def get_supply_period(self):
2017-04-01 00:39:00 +02:00
'Return the supply period for the purchase request'
2016-06-21 10:11:57 +02:00
pool = Pool()
Configuration = pool.get('purchase.configuration')
2017-04-01 00:39:00 +02:00
config = Configuration(1)
2021-04-03 14:27:10 +02:00
supply_period = config.get_multivalue(
'supply_period', company=self.company.id)
2017-04-01 00:39:00 +02:00
return supply_period or datetime.timedelta(1)