Quality wine control

#044796
This commit is contained in:
Raimon Esteve 2021-07-14 12:23:05 +02:00
parent fb8f0222a3
commit 2f1936ba36
11 changed files with 616 additions and 24 deletions

View File

@ -5,6 +5,7 @@ from trytond.pool import Pool
from . import party
from . import plot
from . import product
from . import quality
def register():
@ -28,6 +29,7 @@ def register():
product.ProductEcological,
product.ProductVariety,
product.Template,
quality.QualityTest,
module='agronomics', type_='model')
Pool.register(
module='agronomics', type_='wizard')

View File

@ -139,8 +139,8 @@ msgid "Irrigation"
msgstr "Irrigació"
msgctxt "field:agronomics.parcel,max_production:"
msgid "Max Production"
msgstr "Producció Màxima"
msgid "Max. Production"
msgstr "Max. producció"
msgctxt "field:agronomics.parcel,plant_number:"
msgid "Plant number"
@ -348,7 +348,7 @@ msgstr "Parcel·la"
msgctxt "model:agronomics.parcel-agronomics.do,name:"
msgid "Parcel - Denomination Origin"
msgstr ""
msgstr "Parcel·la - Denominació d'origen"
msgctxt "model:agronomics.plantation,name:"
msgid "Plantation"
@ -492,12 +492,20 @@ msgstr "Administració Agronomics"
msgctxt "selection:product.product,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vi Embotellat"
msgstr "Vi embotellat"
msgctxt "selection:product.product,agronomic_type:"
msgid "Clarified Wine"
msgstr "Vi clarificat"
msgctxt "selection:product.product,agronomic_type:"
msgid "DO Wort"
msgstr "Most DO"
msgctxt "selection:product.product,agronomic_type:"
msgid "Filtered Wine"
msgstr "Vi filtrat"
msgctxt "selection:product.product,agronomic_type:"
msgid "Grape"
msgstr "Raïm"
@ -506,18 +514,30 @@ msgctxt "selection:product.product,agronomic_type:"
msgid "Not DO Wort"
msgstr "Most no DO"
msgctxt "selection:product.product,agronomic_type:"
msgid "Unfiltered Wine"
msgstr "Vi en rama"
msgctxt "selection:product.product,agronomic_type:"
msgid "Wine"
msgstr "Vi"
msgctxt "selection:product.template,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vi Embotellat"
msgstr "Vi embotellat"
msgctxt "selection:product.template,agronomic_type:"
msgid "Clarified Wine"
msgstr "Vi clarificat"
msgctxt "selection:product.template,agronomic_type:"
msgid "DO Wort"
msgstr "Most DO"
msgctxt "selection:product.template,agronomic_type:"
msgid "Filtered Wine"
msgstr "Vi filtrat"
msgctxt "selection:product.template,agronomic_type:"
msgid "Grape"
msgstr "Raïm"
@ -526,6 +546,10 @@ msgctxt "selection:product.template,agronomic_type:"
msgid "Not DO Wort"
msgstr "Most no DO"
msgctxt "selection:product.template,agronomic_type:"
msgid "Unfiltered Wine"
msgstr "Vi en rama"
msgctxt "selection:product.template,agronomic_type:"
msgid "Wine"
msgstr "Vi"

View File

@ -139,8 +139,8 @@ msgid "Irrigation"
msgstr "Irrigación"
msgctxt "field:agronomics.parcel,max_production:"
msgid "Max Production"
msgstr "Producción Máxima"
msgid "Max. Production"
msgstr "Max. producción"
msgctxt "field:agronomics.parcel,plant_number:"
msgid "Plant number"
@ -348,7 +348,7 @@ msgstr "Parcela"
msgctxt "model:agronomics.parcel-agronomics.do,name:"
msgid "Parcel - Denomination Origin"
msgstr ""
msgstr "Parecela - Denominación de origen"
msgctxt "model:agronomics.plantation,name:"
msgid "Plantation"
@ -492,12 +492,20 @@ msgstr "Agronomics Administración"
msgctxt "selection:product.product,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vino Embotellado"
msgstr "Vino embotellado"
msgctxt "selection:product.product,agronomic_type:"
msgid "Clarified Wine"
msgstr "Vino clarificado"
msgctxt "selection:product.product,agronomic_type:"
msgid "DO Wort"
msgstr "Mosto DO"
msgctxt "selection:product.product,agronomic_type:"
msgid "Filtered Wine"
msgstr "Vino filtrado"
msgctxt "selection:product.product,agronomic_type:"
msgid "Grape"
msgstr "Uva"
@ -506,18 +514,30 @@ msgctxt "selection:product.product,agronomic_type:"
msgid "Not DO Wort"
msgstr "Mosto no DO"
msgctxt "selection:product.product,agronomic_type:"
msgid "Unfiltered Wine"
msgstr "Vino en rama"
msgctxt "selection:product.product,agronomic_type:"
msgid "Wine"
msgstr "Vino"
msgctxt "selection:product.template,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vino Embotellado"
msgstr "Vino embotellado"
msgctxt "selection:product.template,agronomic_type:"
msgid "Clarified Wine"
msgstr "Vino clarificado"
msgctxt "selection:product.template,agronomic_type:"
msgid "DO Wort"
msgstr "Mosto DO"
msgctxt "selection:product.template,agronomic_type:"
msgid "Filtered Wine"
msgstr "Vino filtrado"
msgctxt "selection:product.template,agronomic_type:"
msgid "Grape"
msgstr "Uva"
@ -526,6 +546,10 @@ msgctxt "selection:product.template,agronomic_type:"
msgid "Not DO Wort"
msgstr "Mosto no DO"
msgctxt "selection:product.template,agronomic_type:"
msgid "Unfiltered Wine"
msgstr "Vino en rama"
msgctxt "selection:product.template,agronomic_type:"
msgid "Wine"
msgstr "Vino"

View File

@ -1,10 +1,11 @@
# 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.model import ModelSQL, ModelView, fields
from trytond.pool import PoolMeta, Pool
from trytond.pool import PoolMeta
from trytond.pyson import Eval
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.modules.agronomics.wine import WineMixin
class Certification(ModelSQL, ModelView):
@ -35,6 +36,9 @@ class Template(metaclass=PoolMeta):
('grape', "Grape"),
('do-wort', "DO Wort"),
('not-do-wort', "Not DO Wort"),
('unfiltered-wine', 'Unfiltered Wine'),
('filtered-wine', 'Filtered Wine'),
('clarified-wine', 'Clarified Wine'),
('wine', "Wine"),
('bottled-wine', "Bottled Wine"),
], "Agronomic Type", select=True)
@ -57,7 +61,7 @@ class Template(metaclass=PoolMeta):
return [('container.capacity',) + tuple(clause[1:])]
class Product(metaclass=PoolMeta):
class Product(WineMixin, metaclass=PoolMeta):
__name__ = 'product.product'
vintages = fields.Many2Many('product.product-agronomics.crop', 'product',
@ -77,18 +81,21 @@ class Product(metaclass=PoolMeta):
quality_sample = fields.Many2One('quality.sample', 'Quality Sample',
states={
'invisible': ~ Eval('agronomic_type').in_(
['wine', 'bottled-wine']
['wine', 'unfiltered-wine', 'filtered-wine', 'clarified-wine',
'bottled-wine']
)
}, depends=['agronomic_type'])
certification = fields.Many2One('agronomics.certification',
'Certification', states={
'invisible': ~ Eval('agronomic_type').in_(
['wine', 'bottled-wine']
['wine', 'unfiltered-wine', 'filtered-wine', 'clarified-wine',
'bottled-wine']
)
}, depends=['agronomic_type'])
alcohol_volume = fields.Numeric('Alcohol Volume', digits=(16, 2), states={
'invisible': ~ Eval('agronomic_type').in_(
['wine', 'bottled-wine']
['wine', 'unfiltered-wine', 'filtered-wine', 'clarified-wine',
'bottled-wine']
)}, depends=['agronomic_type'])
@classmethod
@ -139,4 +146,4 @@ class ProductEcological(ModelSQL):
product = fields.Many2One('product.product', 'Product',
ondelete='CASCADE', select=True, required=True)
ecological = fields.Many2One('agronomics.ecological', 'Ecological',
ondelete='CASCADE', select=True, required=True)
ondelete='CASCADE', select=True, required=True)

View File

@ -11,6 +11,7 @@
<field name="name">template_list</field>
<field name="inherit" ref="product.template_view_tree"/>
</record>
<!-- Product Variant-->
<record model="ir.ui.view" id="product_view_form">
<field name="model">product.product</field>
@ -22,6 +23,20 @@
<field name="name">product_list</field>
<field name="inherit" ref="product.product_view_tree"/>
</record>
<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"
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>
<record model="ir.action.keyword" id="act_product_quality_test_keyword">
<field name="keyword">form_relate</field>
<field name="model">product.product,-1</field>
<field name="action" ref="act_product_quality_test"/>
</record>
<!-- Certification -->
<record model="ir.ui.view" id="certification_view_form">
<field name="model">agronomics.certification</field>
@ -130,15 +145,14 @@
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_container">
<record model="ir.model.access" id="access_container">
<field name="model" search="[('model', '=', 'agronomics.container')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_container_agronomics_admin">
<record model="ir.model.access" id="access_container_agronomics_admin">
<field name="model" search="[('model', '=', 'agronomics.container')]"/>
<field name="group" ref="agronomics.group_agronomics_admin"/>
<field name="perm_read" eval="True"/>
@ -146,7 +160,7 @@
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_container_product_admin">
<record model="ir.model.access" id="access_container_product_admin">
<field name="model" search="[('model', '=', 'agronomics.container')]"/>
<field name="group" ref="product.group_product_admin"/>
<field name="perm_read" eval="True"/>
@ -154,6 +168,5 @@
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
</data>
</tryton>
</tryton>

61
quality.py Normal file
View File

@ -0,0 +1,61 @@
# 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.modules.agronomics.wine import _WINE_DIGITS
class QualityTest(metaclass=PoolMeta):
__name__ = 'quality.test'
@classmethod
def confirmed(cls, tests):
pool = Pool()
Product = pool.get('product.product')
ModelData = pool.get('ir.model.data')
Date = pool.get('ir.date')
super(QualityTest, cls).confirmed(tests)
# get all key from ir.model.data
to_write = []
proof_templates = []
for test in tests:
if not test.document or test.document.__name__ != 'product.product':
continue
proof_templates += [line.proof.template
for line in test.quantitative_lines
if line.proof and line.proof.template]
datas = ModelData.search([
('module', '=', 'agronomics'),
('db_id', 'in', [pt.id for pt in proof_templates]),
('model', '=', 'quality.proof.template')
])
data_key = dict((x.db_id, x.fs_id) for x in datas)
# check all quantitative lines has key and update the product
for test in tests:
if not test.document or test.document.__name__ != 'product.product':
continue
values = {}
for line in test.quantitative_lines:
if not line.proof.template:
continue
key = data_key.get(line.proof.template.id)
if not key:
continue
values[key] = round(line.value, _WINE_DIGITS)
values[key + '_comment'] = line.internal_description
if values:
values['wine_quality_confirm'] = Date.today()
values['wine_quality_success'] = test.success
to_write.extend(([test.document], values))
if to_write:
Product.write(*to_write)

View File

@ -1,6 +1,8 @@
[tryton]
version=6.0.0
depends:
ir
res
party
product_classification
product_classification_taxonomic
@ -8,5 +10,6 @@ depends:
xml:
plot.xml
party.xml
message.xml
product.xml
wine.xml
message.xml

View File

@ -1,6 +1,6 @@
<data>
<xpath expr="/form/notebook" position="inside">
<page string="Agronomics" id="agrnomics">
<page string="Agronomics" id="agronomics">
<field name="vintages" colspan="2"/>
<field name="varieties" colspan="2"/>
<field name="denominations_of_origin" colspan="2"/>
@ -17,4 +17,60 @@
<field name="capacity"/>
</page>
</xpath>
<xpath expr="/form/notebook" position="inside">
<page string="Quality" id="agronomics-quality">
<label name="wine_quality_confirm"/>
<field name="wine_quality_confirm"/>
<label name="wine_quality_success"/>
<field name="wine_quality_success"/>
<label name="wine_likely_alcohol_content"/>
<field name="wine_likely_alcohol_content"/>
<label name="wine_botrytis"/>
<field name="wine_botrytis"/>
<label name="wine_alcohol_content"/>
<field name="wine_alcohol_content"/>
<label name="wine_density"/>
<field name="wine_density"/>
<label name="wine_temperature"/>
<field name="wine_temperature"/>
<label name="wine_ph"/>
<field name="wine_ph"/>
<label name="wine_free_sulphur"/>
<field name="wine_free_sulphur"/>
<label name="wine_total_sulphur"/>
<field name="wine_total_sulphur"/>
<label name="wine_tartaric_acidity"/>
<field name="wine_tartaric_acidity"/>
<label name="wine_volatility"/>
<field name="wine_volatility"/>
<label name="wine_malic_acid"/>
<field name="wine_malic_acid"/>
<label name="wine_lactic_acid"/>
<field name="wine_lactic_acid"/>
<label name="wine_protein_stability"/>
<field name="wine_protein_stability"/>
<label name="wine_tartaric_stability"/>
<field name="wine_tartaric_stability"/>
<label name="wine_turbidity"/>
<field name="wine_turbidity"/>
<label name="wine_glucose_fructose"/>
<field name="wine_glucose_fructose"/>
<label name="wine_color_intensity"/>
<field name="wine_color_intensity"/>
<label name="wine_tone"/>
<field name="wine_tone"/>
<label name="wine_clogging"/>
<field name="wine_clogging"/>
<label name="wine_overall_impression"/>
<field name="wine_overall_impression"/>
<label name="wine_observing_phase"/>
<field name="wine_observing_phase"/>
<label name="wine_smelling_phase"/>
<field name="wine_smelling_phase"/>
<label name="wine_tasting_phase"/>
<field name="wine_tasting_phase"/>
<separator name="wine_comment" colspan="4"/>
<field name="wine_comment" widget="richtext" toolbar="0" yexpand="1" yfill="1" colspan="4"/>
</page>
</xpath>
</data>

View File

@ -9,5 +9,30 @@
<field name="alcohol_volume" tree_invisible="1"/>
<field name="container" tree_invisible="1"/>
<field name="capacity" tree_invisible="1"/>
<field name="wine_likely_alcohol_content" tree_invisible="1"/>
<field name="wine_botrytis" tree_invisible="1"/>
<field name="wine_alcohol_content" tree_invisible="1"/>
<field name="wine_density" tree_invisible="1"/>
<field name="wine_temperature" tree_invisible="1"/>
<field name="wine_ph" tree_invisible="1"/>
<field name="wine_free_sulphur" tree_invisible="1"/>
<field name="wine_total_sulphur" tree_invisible="1"/>
<field name="wine_tartaric_acidity" tree_invisible="1"/>
<field name="wine_volatility" tree_invisible="1"/>
<field name="wine_malic_acid" tree_invisible="1"/>
<field name="wine_lactic_acid" tree_invisible="1"/>
<field name="wine_protein_stability" tree_invisible="1"/>
<field name="wine_tartaric_stability" tree_invisible="1"/>
<field name="wine_turbidity" tree_invisible="1"/>
<field name="wine_glucose_fructose" tree_invisible="1"/>
<field name="wine_color_intensity" tree_invisible="1"/>
<field name="wine_tone" tree_invisible="1"/>
<field name="wine_clogging" tree_invisible="1"/>
<field name="wine_overall_impression" tree_invisible="1"/>
<field name="wine_observing_phase" tree_invisible="1"/>
<field name="wine_smelling_phase" tree_invisible="1"/>
<field name="wine_tasting_phase" tree_invisible="1"/>
<field name="wine_quality_confirm" tree_invisible="1"/>
<field name="wine_quality_success" tree_invisible="1"/>
</xpath>
</data>

276
wine.py Normal file
View File

@ -0,0 +1,276 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import fields, Model
from trytond.pool import Pool
from trytond.pyson import Bool, Eval
from trytond.transaction import Transaction
__all__ = ['WineMixin']
_DEPENDS = ['agronomic_type']
_WINE_DIGITS = 4
class WineMixin(Model):
wine_quality_confirm = fields.Date('Quality Confirm', readonly=True)
wine_quality_success = fields.Boolean('Quality success', readonly=True, states={
'invisible': ~Bool(Eval('wine_quality_confirm', None)),
}, depends=['wine_quality_confirm'])
wine_likely_alcohol_content = fields.Float('Likely Alcohol Content',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort']
)}, depends=_DEPENDS)
wine_likely_alcohol_content_comment = fields.Text('Likely Alcohol Content Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort']
)}, depends=_DEPENDS)
wine_botrytis = fields.Float('Botrytis',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine']
)}, depends=_DEPENDS)
wine_botrytis_comment = fields.Text('Botrytis Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine']
)}, depends=_DEPENDS)
wine_alcohol_content = fields.Float('Alcohol Content',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_alcohol_content_comment = fields.Text('Alcohol Content Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_density = fields.Float('Density',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine']
)}, depends=_DEPENDS)
wine_density_comment = fields.Text('Density Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine']
)}, depends=_DEPENDS)
wine_temperature = fields.Float('Temperature',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'filtered-wine']
)}, depends=_DEPENDS)
wine_temperature_comment = fields.Text('Temperature Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'filtered-wine']
)}, depends=_DEPENDS)
wine_ph = fields.Float('PH',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_ph_comment = fields.Text('PH Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_free_sulphur = fields.Float('Free Sulphur',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_free_sulphur_comment = fields.Text('Free Sulphur Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_total_sulphur = fields.Float('Total Sulphur',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_total_sulphur_comment = fields.Text('Total Sulphur Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tartaric_acidity = fields.Float('Tartaric Acidity',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tartaric_acidity_comment = fields.Text('Tartaric Acidity Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_volatility = fields.Float('Volatility',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_volatility_comment = fields.Text('Volatility Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_malic_acid = fields.Float('Malic Acid',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine']
)}, depends=_DEPENDS)
wine_malic_acid_comment = fields.Text('Malic Acid Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine']
)}, depends=_DEPENDS)
wine_lactic_acid = fields.Float('Lactic Acid',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine']
)}, depends=_DEPENDS)
wine_lactic_acid_comment = fields.Text('Lactic Acid Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine']
)}, depends=_DEPENDS)
wine_protein_stability = fields.Float('Protein Stability',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_protein_stability_comment = fields.Text('Protein Stability Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tartaric_stability = fields.Float('Tartaric Stability',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tartaric_stability_comment = fields.Text('Tartaric Stability Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_turbidity = fields.Float('Turbidity',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine']
)}, depends=_DEPENDS)
wine_turbidity_comment = fields.Text('Turbidity Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine']
)}, depends=_DEPENDS)
wine_glucose_fructose = fields.Float('Glucose/Fructose',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_glucose_fructose_comment = fields.Text('Glucose/Fructose Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_color_intensity = fields.Float('Color Intensity',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_color_intensity_comment = fields.Text('Color Intensity Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tone = fields.Float('Tone',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tone_comment = fields.Text('Tone Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_clogging = fields.Float('Clogging',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine']
)}, depends=_DEPENDS)
wine_clogging_comment = fields.Text('Clogging Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['filtered-wine']
)}, depends=_DEPENDS)
wine_overall_impression = fields.Float('Overall Impression',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_overall_impression_comment = fields.Text('Overall Impression Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['grape', 'do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_observing_phase = fields.Float('Observing Phase',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_observing_phase_comment = fields.Text('Observing Phase Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_smelling_phase = fields.Float('Smelling Phase',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_smelling_phase_comment = fields.Text('Smelling Phase Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tasting_phase = fields.Float('Tasting Phase',
digits=(16, _WINE_DIGITS), readonly=True, states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_tasting_phase_comment = fields.Text('Tasting Phase Comment',
states={
'invisible': ~Eval('agronomic_type').in_(
['do-wort', 'not-do-wort', 'unfiltered-wine', 'clarified-wine', 'filtered-wine', 'bottled-wine']
)}, depends=_DEPENDS)
wine_comment = fields.Function(fields.Text('Wine Comments'),
'get_wine_comment')
@classmethod
def get_wine_comment(cls, records, name):
pool = Pool()
Translation = pool.get('ir.translation')
res = dict((x.id, None) for x in records)
language = Transaction().language
for record in records:
data = ''
for key in cls._fields.keys():
if (key.startswith('wine_') and key.endswith('_comment')
and key != 'wine_comment'):
if not getattr(record, key):
continue
field_name = '%s,%s' % (cls.__name__, key)
label = (Translation.get_source(field_name, 'field', language)
or getattr(cls, key).string)
data += '<h2>%s</h2>%s' % (label, getattr(record, key))
res[record.id] = data
print('.....' * 10)
print(res)
return res

101
wine.xml Normal file
View File

@ -0,0 +1,101 @@
<tryton>
<data>
<!-- quality.proof data-->
<record model="quality.proof.template" id="wine_likely_alcohol_content">
<field name="name">Grau esperat</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_botrytis">
<field name="name">Botrytis</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_alcohol_content">
<field name="name">Grau alcohol</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_density">
<field name="name">Densitat</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_temperature">
<field name="name">Temperatura</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_ph">
<field name="name">PH</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_free_sulphur">
<field name="name">Sulfuros lliure</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_total_sulphur">
<field name="name">Sulfurós Total</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_tartaric_acidity">
<field name="name">Acidesa tartàric</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_volatility">
<field name="name">Volatil</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_malic_acid">
<field name="name">Àcid màlic</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_lactic_acid">
<field name="name">Àcil lactica</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_protein_stability">
<field name="name">Estabilitat proteica</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_tartaric_stability">
<field name="name">Estabilitat tartarica</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_turbidity">
<field name="name">Terbolesa</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_glucose_fructose">
<field name="name">Glucosa/fructosa</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_color_intensity">
<field name="name">Intensitat colorant</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_tone">
<field name="name">Tonalitat</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_clogging">
<field name="name">Colmatacio</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_overall_impression">
<field name="name">Impresió general</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_observing_phase">
<field name="name">Fase visual</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_smelling_phase">
<field name="name">Fase olfactiva</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_tasting_phase">
<field name="name">Fase gustativa</field>
<field name="type">quantitative</field>
</record>
<record model="quality.proof.template" id="wine_notes">
<field name="name">Observacions</field>
<field name="type">quantitative</field>
</record>
</data>
</tryton>