add setter to quality_test
This commit is contained in:
parent
3f9d2d4959
commit
71afd8848d
|
@ -173,10 +173,12 @@ class Production(metaclass=PoolMeta):
|
|||
'production.cost_price.distribution.template',
|
||||
"Cost Distribution Template",
|
||||
domain=[
|
||||
('id', 'in', Eval('production_template_cost_distribution_templates'))
|
||||
('id', 'in',
|
||||
Eval('production_template_cost_distribution_templates'))
|
||||
], states={
|
||||
'readonly': Eval('state').in_(['cancelled', 'done']),
|
||||
}, depends=['state', 'production_template_cost_distribution_templates'])
|
||||
}, depends=['state',
|
||||
'production_template_cost_distribution_templates'])
|
||||
cost_distribution_templates = fields.Function(
|
||||
fields.Many2Many('product.template',
|
||||
None, None, "Cost Product Templates"),
|
||||
|
@ -185,7 +187,6 @@ class Production(metaclass=PoolMeta):
|
|||
pass_certification = fields.Boolean('Pass Certification')
|
||||
pass_quality_sample = fields.Boolean('Pass Quality Sample')
|
||||
|
||||
|
||||
@classmethod
|
||||
def set_allowed_products(cls, productions, name, value):
|
||||
pass
|
||||
|
@ -217,8 +218,8 @@ class Production(metaclass=PoolMeta):
|
|||
products = []
|
||||
if not self.production_template:
|
||||
return []
|
||||
for x in self.production_template.inputs:
|
||||
products += x.products
|
||||
for input_ in self.production_template.inputs:
|
||||
products += input_.products
|
||||
return [x.id for x in products]
|
||||
|
||||
@fields.depends('production_template')
|
||||
|
@ -271,7 +272,7 @@ class Production(metaclass=PoolMeta):
|
|||
gettext('agronomics.msg_check_production_percentatge',
|
||||
production=self.rec_name,
|
||||
percentatge=percentatge * 100,
|
||||
))
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def wait(cls, productions):
|
||||
|
@ -417,17 +418,17 @@ class Production(metaclass=PoolMeta):
|
|||
product.vintages = list(set(vintages))
|
||||
varieties = {}
|
||||
for input in self.inputs:
|
||||
percent = round(input.quantity/total_output, 6)
|
||||
percent = round(input.quantity / total_output, 6)
|
||||
for variety in input.product.varieties:
|
||||
new_variety = varieties.get(variety.variety)
|
||||
if not new_variety:
|
||||
new_variety = Variety()
|
||||
new_variety.percent = 0
|
||||
new_variety.variety = variety.variety
|
||||
new_variety.percent += variety.percent/100.0*percent
|
||||
new_variety.percent += variety.percent / 100.0 * percent
|
||||
varieties[new_variety.variety] = new_variety
|
||||
for key, variety in varieties.items():
|
||||
variety.percent = "%.4f" % round(100.0*variety.percent, 4)
|
||||
variety.percent = "%.4f" % round(100.0 * variety.percent, 4)
|
||||
product.varieties = varieties.values()
|
||||
return product
|
||||
|
||||
|
@ -485,7 +486,8 @@ class Production(metaclass=PoolMeta):
|
|||
if output.product not in products:
|
||||
continue
|
||||
has_product = True
|
||||
cost = production_cost * (1 + cdist.percentatge) - production_cost
|
||||
cost = (production_cost * (1 + cdist.percentatge) -
|
||||
production_cost)
|
||||
output_cost += round_price(cost / Decimal(total_output))
|
||||
|
||||
output_cost = output_cost if has_product else Decimal(0)
|
||||
|
@ -560,7 +562,8 @@ class OutputDistribution(ModelSQL, ModelView):
|
|||
context = Transaction().context
|
||||
context['locations'] = [self.location.id]
|
||||
with Transaction().set_context(context):
|
||||
quantities = Product.get_quantity(self.product.products, 'quantity')
|
||||
quantities = Product.get_quantity(self.product.products,
|
||||
'quantity')
|
||||
self.initial_quantity = sum(quantities.values())
|
||||
|
||||
@fields.depends('location', methods=['on_change_product'])
|
||||
|
@ -579,7 +582,8 @@ class OutputDistribution(ModelSQL, ModelView):
|
|||
context = Transaction().context
|
||||
context['locations'] = [self.location.id]
|
||||
with Transaction().set_context(context):
|
||||
quantities = Product.get_quantity(self.product.products, 'quantity')
|
||||
quantities = Product.get_quantity(self.product.products,
|
||||
'quantity')
|
||||
return sum(quantities.values())
|
||||
|
||||
@fields.depends('final_quantity', 'initial_quantity')
|
||||
|
@ -625,7 +629,7 @@ class ProductionCostPriceDistribution(ModelSQL, ModelView):
|
|||
__name__ = 'production.cost_price.distribution'
|
||||
template = fields.Many2One('product.template', "Template", required=True,
|
||||
ondelete='RESTRICT')
|
||||
origin = fields.Reference('Origin', selection='_get_models', required=True,)
|
||||
origin = fields.Reference('Origin', selection='_get_models', required=True)
|
||||
percentatge = fields.Numeric("Percentatge", digits=(16, 4), required=True)
|
||||
|
||||
@classmethod
|
||||
|
|
15
weighing.py
15
weighing.py
|
@ -100,8 +100,11 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
|||
], "State", readonly=True, required=True)
|
||||
state_string = state.translated('state')
|
||||
all_do = fields.Function(fields.Char('All DO'), 'get_all_do')
|
||||
quality_test = fields.Function(fields.Many2One('quality.test', 'Test'),
|
||||
'get_quality_test')
|
||||
quality_test = fields.Function(fields.Many2One('quality.test', 'Test',
|
||||
states={
|
||||
'readonly': Eval('state').in_(READONLY),
|
||||
}),
|
||||
'get_quality_test', 'set_quality_test')
|
||||
product_created = fields.Many2One('product.product', 'Product Created',
|
||||
readonly=True)
|
||||
|
||||
|
@ -164,6 +167,13 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
|||
tests = self.product_created.quality_tests
|
||||
return tests and tests[0] and tests[0].id
|
||||
|
||||
@classmethod
|
||||
def set_quality_test(cls, weighings, name, value):
|
||||
Test = Pool().get('quality.test')
|
||||
if not value:
|
||||
return
|
||||
|
||||
|
||||
@fields.depends('weighing_date')
|
||||
def on_change_with_crop(self):
|
||||
Crop = Pool().get('agronomics.crop')
|
||||
|
@ -360,6 +370,7 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
|||
else:
|
||||
default = default.copy()
|
||||
default.setdefault('beneficiaries', None)
|
||||
default.setdefault('product_created', None)
|
||||
return super().copy(weighings, default=default)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue