Add keyword product to quality/quantitive lines
This commit is contained in:
parent
62626bcbb9
commit
2546478afd
|
@ -30,6 +30,8 @@ def register():
|
|||
product.ProductVariety,
|
||||
product.Template,
|
||||
quality.QualityTest,
|
||||
quality.QuantitativeTestLine,
|
||||
quality.QualitativeTestLine,
|
||||
module='agronomics', type_='model')
|
||||
Pool.register(
|
||||
module='agronomics', type_='wizard')
|
||||
|
|
31
product.xml
31
product.xml
|
@ -27,7 +27,8 @@
|
|||
<record model="ir.action.act_window" id="act_product_quality_test">
|
||||
<field name="name">Quality Test</field>
|
||||
<field name="res_model">quality.test</field>
|
||||
<field name="domain"
|
||||
<field
|
||||
name="domain"
|
||||
eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('document.id', '=', Eval('active_id'), 'product.product'), ('document.id', 'in', Eval('active_ids'), 'product.product'))]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
|
@ -37,6 +38,34 @@
|
|||
<field name="action" ref="act_product_quality_test"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_product_quantitative_test_lines">
|
||||
<field name="name">Quantitative Lines</field>
|
||||
<field name="res_model">quality.quantitative.test.line</field>
|
||||
<field
|
||||
name="domain"
|
||||
eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product', '=', Eval('active_id')), ('product', 'in', Eval('active_ids')))]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_product_quantitative_test_lines_keyword">
|
||||
<field name="keyword">form_relate</field>
|
||||
<field name="model">product.product,-1</field>
|
||||
<field name="action" ref="act_product_quantitative_test_lines"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_product_qualitative_test_lines">
|
||||
<field name="name">Qualitative Lines</field>
|
||||
<field name="res_model">quality.qualitative.test.line</field>
|
||||
<field
|
||||
name="domain"
|
||||
eval="[If(Eval('active_ids', []) == [Eval('active_id')], ('product', '=', Eval('active_id')), ('product', 'in', Eval('active_ids')))]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_product_qualitative_test_lines_keyword">
|
||||
<field name="keyword">form_relate</field>
|
||||
<field name="model">product.product,-1</field>
|
||||
<field name="action" ref="act_product_qualitative_test_lines"/>
|
||||
</record>
|
||||
|
||||
<!-- Certification -->
|
||||
<record model="ir.ui.view" id="certification_view_form">
|
||||
<field name="model">agronomics.certification</field>
|
||||
|
|
32
quality.py
32
quality.py
|
@ -1,6 +1,7 @@
|
|||
# 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
|
||||
from trytond.modules.agronomics.wine import _WINE_DIGITS
|
||||
|
||||
|
||||
|
@ -63,3 +64,34 @@ class QualityTest(metaclass=PoolMeta):
|
|||
|
||||
if to_write:
|
||||
Product.write(*to_write)
|
||||
|
||||
|
||||
class TestLineMixin(Model):
|
||||
product = fields.Function(fields.Many2One('product.product', 'Product', select=True),
|
||||
'get_product', searcher='search_product')
|
||||
|
||||
def get_product(self, name):
|
||||
Product = Pool().get('product.product')
|
||||
if isinstance(self.test.document, Product):
|
||||
return self.test.document.id
|
||||
|
||||
@classmethod
|
||||
def search_product(cls, name, clause):
|
||||
Product = Pool().get('product.product')
|
||||
|
||||
_, operator, value = clause[0:3]
|
||||
if isinstance(value, list):
|
||||
values = [('%s,%s' % ('product.product',
|
||||
v.id if isinstance(v, Product) else v)) for v in value]
|
||||
else:
|
||||
values = '%s,%s' % ('product.product',
|
||||
value.id if isinstance(value, Product) else value)
|
||||
return [('test.document', operator, values)]
|
||||
|
||||
|
||||
class QuantitativeTestLine(TestLineMixin, metaclass=PoolMeta):
|
||||
__name__ = 'quality.quantitative.test.line'
|
||||
|
||||
|
||||
class QualitativeTestLine(TestLineMixin, metaclass=PoolMeta):
|
||||
__name__ = 'quality.qualitative.test.line'
|
||||
|
|
Loading…
Reference in New Issue