add reference and origin on quality sample
This commit is contained in:
parent
75bffe9fd1
commit
4440b12df5
|
@ -34,7 +34,7 @@ def register():
|
|||
weighing.Weighing,
|
||||
weighing.WeighingPlantation,
|
||||
weighing.WeighingDo,
|
||||
# quality.QualitySample,
|
||||
quality.QualitySample,
|
||||
quality.QualityTest,
|
||||
quality.QuantitativeTestLine,
|
||||
quality.QualitativeTestLine,
|
||||
|
|
|
@ -368,10 +368,15 @@ class Production(metaclass=PoolMeta):
|
|||
def copy_quality_samples(self, new_product):
|
||||
QualitySample = Pool().get('quality.sample')
|
||||
products = [x.product for x in self.inputs if x.product.quality_samples]
|
||||
if not self.pass_certification or len(products) != 1:
|
||||
if not self.pass_quality_sample or len(products) != 1:
|
||||
return new_product
|
||||
samples = products[0].quality_samples
|
||||
new_samples = QualitySample.copy(samples, {'product':new_product})
|
||||
new_samples =[]
|
||||
for sample in samples:
|
||||
new_sample, = QualitySample.copy([sample], {'product':new_product})
|
||||
new_sample.origin = sample
|
||||
new_samples.append(new_sample)
|
||||
QualitySample.save(new_samples)
|
||||
QualitySample.done(new_samples)
|
||||
return new_product
|
||||
|
||||
|
|
23
quality.py
23
quality.py
|
@ -1,12 +1,31 @@
|
|||
# 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, Pool
|
||||
from trytond.model import fields, Model, DeactivableMixin
|
||||
from trytond.model import fields, Model
|
||||
from trytond.pyson import Eval
|
||||
from trytond.modules.agronomics.wine import _WINE_DIGITS
|
||||
|
||||
class QualitySample(DeactivableMixin, metaclass=PoolMeta):
|
||||
class QualitySample(metaclass=PoolMeta):
|
||||
__name__ = 'quality.sample'
|
||||
|
||||
reference = fields.Char('Reference')
|
||||
origin = fields.Reference('Origin', selection='get_origin', select=True,
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
depends=['state'])
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
'Return list of Model names for origin Reference'
|
||||
return [cls.__name__, 'quality.sample']
|
||||
|
||||
@classmethod
|
||||
def get_origin(cls):
|
||||
IrModel = Pool().get('ir.model')
|
||||
get_name = IrModel.get_name
|
||||
models = cls._get_origin()
|
||||
return [(None, '')] + [(m, get_name(m)) for m in models]
|
||||
|
||||
class QualityTest(metaclass=PoolMeta):
|
||||
__name__ = 'quality.test'
|
||||
|
|
|
@ -18,3 +18,4 @@ xml:
|
|||
wine.xml
|
||||
message.xml
|
||||
production.xml
|
||||
quality.xml
|
Loading…
Reference in New Issue