trytond-production_quality_.../production.py

41 lines
1.4 KiB
Python
Raw Normal View History

2014-07-01 18:01:25 +02:00
#The COPYRIGHT file at the top level of this repository contains the full
#copyright notices and license terms.
2018-10-28 01:20:25 +02:00
from trytond.model import fields
2014-07-01 18:01:25 +02:00
from trytond.pool import PoolMeta
from trytond.pyson import Eval
__all__ = ['Template', 'Production']
class Template:
2018-10-28 01:20:25 +02:00
__metaclass__ = PoolMeta
2014-07-01 18:01:25 +02:00
__name__ = 'product.template'
quality_template = fields.Many2One('quality.template', 'Quality Template')
class Production:
2018-10-28 01:20:25 +02:00
__metaclass__ = PoolMeta
2014-07-01 18:01:25 +02:00
__name__ = 'production'
quality_template = fields.Many2One('quality.template', 'Quality Template')
quality_tests = fields.One2Many('quality.test', 'document', 'Quality Tests',
context={
'default_quality_template': Eval('quality_template'),
},
depends=['quality_template'])
@fields.depends('product')
def on_change_product(self):
2016-07-05 13:24:16 +02:00
super(Production, self).on_change_product()
2014-07-01 18:01:25 +02:00
if self.product and self.product.template.quality_template:
2016-07-05 13:24:16 +02:00
self.quality_template = self.product.template.quality_template
2014-07-01 18:01:25 +02:00
@classmethod
def compute_request(cls, product, warehouse, quantity, date, company):
"Inherited from stock_supply_production"
production = super(Production, cls).compute_request(product,
warehouse, quantity, date, company)
if product.template.quality_template:
production.quality_template = product.template.quality_template
return production