Files
tryton/production.py
T
Cédric Krier 96f5797da3 Add order_point argument to compute_request
The issue3257 added this argument in stock_supply_production module.

issue9279
review319341002
2020-05-01 00:19:33 +02:00

48 lines
1.6 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import PoolMeta
from trytond.model import fields
from trytond.pyson import Eval
class Production(metaclass=PoolMeta):
__name__ = 'production'
routing = fields.Many2One('production.routing', 'Routing',
domain=[
('boms', '=', Eval('bom', 0)),
],
states={
'readonly': ~Eval('state').in_(['request', 'draft']),
'invisible': ~Eval('bom'),
},
depends=['bom', 'state'])
@fields.depends('bom', 'routing')
def on_change_bom(self):
super(Production, self).on_change_bom()
if self.bom:
if self.routing:
if self.bom not in self.routing.boms:
self.routing = None
else:
self.routing = None
@fields.depends('routing')
def on_change_with_planned_start_date(self, pattern=None):
if pattern is None:
pattern = {}
pattern.setdefault(
'routing', self.routing.id if self.routing else None)
return super(Production, self).on_change_with_planned_start_date(
pattern=pattern)
@classmethod
def compute_request(
cls, product, warehouse, quantity, date, company,
order_point=None):
production = super(Production, cls).compute_request(
product, warehouse, quantity, date, company,
order_point=order_point)
production.routing = product.boms[0].routing if product.boms else None
return production