* weighing feature #044025
This commit is contained in:
Àngel Àlvarez Serra 2021-09-01 10:10:48 +02:00 committed by GitHub
parent 9bbb7ff674
commit e813e592eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1136 additions and 4 deletions

View File

@ -5,6 +5,7 @@ from trytond.pool import Pool
from . import party
from . import plot
from . import product
from . import weighing
from . import quality
@ -29,6 +30,10 @@ def register():
product.ProductEcological,
product.ProductVariety,
product.Template,
weighing.WeighingCenter,
weighing.Weighing,
weighing.WeighingPlantation,
weighing.WeighingDo,
quality.QualityTest,
quality.QuantitativeTestLine,
quality.QualitativeTestLine,

View File

@ -14,6 +14,10 @@ msgctxt "field:agronomics.beneficiary,percent:"
msgid "Percent"
msgstr "Percentatge"
msgctxt "field:agronomics.beneficiary,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.certification,date:"
msgid "Date"
msgstr "Data"
@ -140,7 +144,7 @@ msgstr "Irrigació"
msgctxt "field:agronomics.parcel,max_production:"
msgid "Max. Production"
msgstr "Max. producció"
msgstr "Producció Màxima"
msgctxt "field:agronomics.parcel,plant_number:"
msgid "Plant number"
@ -158,6 +162,10 @@ msgctxt "field:agronomics.parcel,producer:"
msgid "Party"
msgstr "Productor"
msgctxt "field:agronomics.parcel,product:"
msgid "Product"
msgstr "Productes"
msgctxt "field:agronomics.parcel,species:"
msgid "Spices"
msgstr "Espècie"
@ -202,6 +210,126 @@ msgctxt "field:agronomics.plantation,party:"
msgid "Party"
msgstr "Tercers"
msgctxt "field:agronomics.weighing,all_do:"
msgid "All DO"
msgstr "Totes les DO"
msgctxt "field:agronomics.weighing,beneficiaries:"
msgid "Beneficiaries"
msgstr "Beneficiaris"
msgctxt "field:agronomics.weighing,crop:"
msgid "Crop"
msgstr "Collita"
msgctxt "field:agronomics.weighing,denomination_origin:"
msgid "Denomination of Origin"
msgstr "Denominació d'origen"
msgctxt "field:agronomics.weighing,do:"
msgid "Denomination Origin"
msgstr "Denominació d'origen"
msgctxt "field:agronomics.weighing,ecological:"
msgid "Ecological"
msgstr "Ecològic"
msgctxt "field:agronomics.weighing,net_weight:"
msgid "Net Weight"
msgstr "Pes net"
msgctxt "field:agronomics.weighing,netweight:"
msgid "Net Weight"
msgstr "Pes net"
msgctxt "field:agronomics.weighing,number:"
msgid "Number"
msgstr "Número"
msgctxt "field:agronomics.weighing,plantations:"
msgid "plantations"
msgstr "Plantacions"
msgctxt "field:agronomics.weighing,product:"
msgid "Product"
msgstr "Productes"
msgctxt "field:agronomics.weighing,product_created:"
msgid "Product Created"
msgstr "Producte creat"
msgctxt "field:agronomics.weighing,purchase_contract:"
msgid "Purchase Contract"
msgstr "Contracte de compra"
msgctxt "field:agronomics.weighing,quality_test:"
msgid "Test"
msgstr "Test"
msgctxt "field:agronomics.weighing,state:"
msgid "State"
msgstr "Estat"
msgctxt "field:agronomics.weighing,table:"
msgid "Table"
msgstr "Taula"
msgctxt "field:agronomics.weighing,tara:"
msgid "Tara"
msgstr "Tara"
msgctxt "field:agronomics.weighing,variety:"
msgid "Variety"
msgstr "Varietat"
msgctxt "field:agronomics.weighing,weighing_center:"
msgid "Weighing Center"
msgstr "Centre de pesada"
msgctxt "field:agronomics.weighing,weighing_date:"
msgid "Date"
msgstr "Data"
msgctxt "field:agronomics.weighing,weight:"
msgid "Weight"
msgstr "Pes"
msgctxt "field:agronomics.weighing-agronomics.do,do:"
msgid "Denomination Origin"
msgstr "Denominació d'origen"
msgctxt "field:agronomics.weighing-agronomics.do,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing-agronomics.plantation,Plantation:"
msgid "Plantation"
msgstr "Plantacións"
msgctxt "field:agronomics.weighing-agronomics.plantation,plantation:"
msgid "Plantation"
msgstr "Plantacións"
msgctxt "field:agronomics.weighing-agronomics.plantation,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing-agronomics.plantations,Plantation:"
msgid "Plantation"
msgstr "Plantacións"
msgctxt "field:agronomics.weighing-agronomics.plantations,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing.center,name:"
msgid "Name"
msgstr "Nom"
msgctxt "field:agronomics.weighing.center,weighing_sequence:"
msgid "Weighing Sequence"
msgstr "Seqüència de pesada"
msgctxt "field:party.party,parcels:"
msgid "Parcels"
msgstr "Parceles"
@ -246,6 +374,10 @@ msgctxt "field:product.product,quality_sample:"
msgid "Quality Sample"
msgstr "Mostra de qualitat"
msgctxt "field:product.product,quality_weighing:"
msgid "Quality Weighing"
msgstr "Qualitat Pesada"
msgctxt "field:product.product,shipment_in_quality_template:"
msgid "Shipment In Quality Template"
msgstr "Plantilla qualitat albarà entrada"
@ -306,6 +438,10 @@ msgctxt "field:product.template,container:"
msgid "Container"
msgstr "Envàs"
msgctxt "field:product.template,quality_weighing:"
msgid "Quality Weighing"
msgstr "Qualitat pesada"
msgctxt "model:agronomics.beneficiary,name:"
msgid "Beneficiaries"
msgstr "Beneficiaris"
@ -354,6 +490,26 @@ msgctxt "model:agronomics.plantation,name:"
msgid "Plantation"
msgstr "Plantació"
msgctxt "model:agronomics.weighing,name:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:agronomics.weighing-agronomics.do,name:"
msgid "Weighing - Denomination Origin"
msgstr "Pesada - Denominació Origen"
msgctxt "model:agronomics.weighing-agronomics.plantation,name:"
msgid "Weighing - Plantations"
msgstr "Pesada - Plantacions"
msgctxt "model:agronomics.weighing-agronomics.plantations,name:"
msgid "Weighing - Plantations"
msgstr "Pesada - Plantacions"
msgctxt "model:agronomics.weighing.center,name:"
msgid "Weighing Center"
msgstr "Centre de pesada"
msgctxt "model:ir.action,name:act_certification_tree"
msgid "Certification"
msgstr "Certificació"
@ -394,6 +550,31 @@ msgctxt "model:ir.action,name:act_plantation_tree"
msgid "Plantation"
msgstr "Plantació"
msgctxt "model:ir.action,name:act_weighing_action"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.action,name:act_weighing_center_action"
msgid "Weighing Center"
msgstr "Centre de pesada"
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_all"
msgid "All"
msgstr "Tots"
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_analysis"
msgid "In Analysis"
msgstr "En Anàlisi"
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_draft"
msgid "Draft"
msgstr "Esborrany"
msgctxt ""
"model:ir.action.act_window.domain,name:act_weighing_domain_processing"
msgid "Processing"
msgstr "Processos"
msgctxt "model:ir.message,text:msg_beneficiaris_percent"
msgid ""
"Beneficiaris of Crop \"%(crop)s\" and Plantation \"%(plantation)s\" must sum"
@ -418,6 +599,34 @@ msgstr ""
"El producte \"%(product)s\" no pot tenir més d'una collita degut al seu "
"tipus agronòmic"
msgctxt "model:ir.model.button,string:weighing_analysis_button"
msgid "Analysis"
msgstr "Anàlisi"
msgctxt "model:ir.model.button,string:weighing_cancel_button"
msgid "Cancel"
msgstr "Cancel·lat"
msgctxt "model:ir.model.button,string:weighing_done_button"
msgid "Done"
msgstr "Realitzat"
msgctxt "model:ir.model.button,string:weighing_draft_button"
msgid "Draft"
msgstr "Esborrany"
msgctxt "model:ir.model.button,string:weighing_process_button"
msgid "Process"
msgstr "Processa"
msgctxt "model:ir.sequence,name:sequence_weighing"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.sequence.type,name:sequence_type_weighing"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.ui.menu,name:menu_agronomics"
msgid "Agronomics"
msgstr "Agronomics"
@ -466,6 +675,14 @@ msgctxt "model:ir.ui.menu,name:menu_plantation_list"
msgid "Plantation"
msgstr "Plantació"
msgctxt "model:ir.ui.menu,name:menu_weighing_center_list"
msgid "Weighing Center"
msgstr "Centre de pesada"
msgctxt "model:ir.ui.menu,name:menu_weighing_list"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:product.product-agronomics.crop,name:"
msgid "Product - Crop"
msgstr "Producte - Collita"
@ -490,6 +707,26 @@ msgctxt "model:res.group,name:group_agronomics_admin"
msgid "Agronomics Administration"
msgstr "Administració Agronomics"
msgctxt "selection:agronomics.weighing,state:"
msgid "Cancelled"
msgstr "Cancel·lat"
msgctxt "selection:agronomics.weighing,state:"
msgid "Done"
msgstr "Realitzat"
msgctxt "selection:agronomics.weighing,state:"
msgid "Draft"
msgstr "Esborrany"
msgctxt "selection:agronomics.weighing,state:"
msgid "In Analysis"
msgstr "En anàlisis"
msgctxt "selection:agronomics.weighing,state:"
msgid "Processing"
msgstr "Processos"
msgctxt "selection:product.product,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vi embotellat"

View File

@ -14,6 +14,10 @@ msgctxt "field:agronomics.beneficiary,percent:"
msgid "Percent"
msgstr "Porcentaje"
msgctxt "field:agronomics.beneficiary,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.certification,date:"
msgid "Date"
msgstr "Fecha"
@ -140,7 +144,7 @@ msgstr "Irrigación"
msgctxt "field:agronomics.parcel,max_production:"
msgid "Max. Production"
msgstr "Max. producción"
msgstr "Producción Máxima"
msgctxt "field:agronomics.parcel,plant_number:"
msgid "Plant number"
@ -158,6 +162,10 @@ msgctxt "field:agronomics.parcel,producer:"
msgid "Party"
msgstr "Productor"
msgctxt "field:agronomics.parcel,product:"
msgid "Product"
msgstr "Productos"
msgctxt "field:agronomics.parcel,species:"
msgid "Spices"
msgstr "Especie"
@ -202,6 +210,126 @@ msgctxt "field:agronomics.plantation,party:"
msgid "Party"
msgstr "Terceros"
msgctxt "field:agronomics.weighing,all_do:"
msgid "All DO"
msgstr "Todos los DO"
msgctxt "field:agronomics.weighing,beneficiaries:"
msgid "Beneficiaries"
msgstr "Beneficiarios"
msgctxt "field:agronomics.weighing,crop:"
msgid "Crop"
msgstr "Cosecha"
msgctxt "field:agronomics.weighing,denomination_origin:"
msgid "Denomination of Origin"
msgstr "Denominación de origen"
msgctxt "field:agronomics.weighing,do:"
msgid "Denomination Origin"
msgstr "Denominación de origen"
msgctxt "field:agronomics.weighing,ecological:"
msgid "Ecological"
msgstr "Ecológico"
msgctxt "field:agronomics.weighing,net_weight:"
msgid "Net Weight"
msgstr "Peso neto"
msgctxt "field:agronomics.weighing,netweight:"
msgid "Net Weight"
msgstr "Peso neto"
msgctxt "field:agronomics.weighing,number:"
msgid "Number"
msgstr "Número"
msgctxt "field:agronomics.weighing,plantations:"
msgid "plantations"
msgstr "Plantación"
msgctxt "field:agronomics.weighing,product:"
msgid "Product"
msgstr "Productos"
msgctxt "field:agronomics.weighing,product_created:"
msgid "Product Created"
msgstr ""
msgctxt "field:agronomics.weighing,purchase_contract:"
msgid "Purchase Contract"
msgstr "Contrato de compra"
msgctxt "field:agronomics.weighing,quality_test:"
msgid "Test"
msgstr "Test"
msgctxt "field:agronomics.weighing,state:"
msgid "State"
msgstr "Estado"
msgctxt "field:agronomics.weighing,table:"
msgid "Table"
msgstr "Mesa"
msgctxt "field:agronomics.weighing,tara:"
msgid "Tara"
msgstr "Tara"
msgctxt "field:agronomics.weighing,variety:"
msgid "Variety"
msgstr "Variedad"
msgctxt "field:agronomics.weighing,weighing_center:"
msgid "Weighing Center"
msgstr "Centro de pesada"
msgctxt "field:agronomics.weighing,weighing_date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:agronomics.weighing,weight:"
msgid "Weight"
msgstr "Peso"
msgctxt "field:agronomics.weighing-agronomics.do,do:"
msgid "Denomination Origin"
msgstr "Denominación de origen"
msgctxt "field:agronomics.weighing-agronomics.do,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing-agronomics.plantation,Plantation:"
msgid "Plantation"
msgstr "Plantaciónes"
msgctxt "field:agronomics.weighing-agronomics.plantation,plantation:"
msgid "Plantation"
msgstr "Plantaciónes"
msgctxt "field:agronomics.weighing-agronomics.plantation,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing-agronomics.plantations,Plantation:"
msgid "Plantation"
msgstr "Plantaciónes"
msgctxt "field:agronomics.weighing-agronomics.plantations,weighing:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "field:agronomics.weighing.center,name:"
msgid "Name"
msgstr "Nombre"
msgctxt "field:agronomics.weighing.center,weighing_sequence:"
msgid "Weighing Sequence"
msgstr "Secuencia"
msgctxt "field:party.party,parcels:"
msgid "Parcels"
msgstr "Parcelas"
@ -246,6 +374,10 @@ msgctxt "field:product.product,quality_sample:"
msgid "Quality Sample"
msgstr "Muestra de calidad"
msgctxt "field:product.product,quality_weighing:"
msgid "Quality Weighing"
msgstr "Calidad pesada"
msgctxt "field:product.product,shipment_in_quality_template:"
msgid "Shipment In Quality Template"
msgstr "Plantilla calidad albarán de entrada"
@ -306,6 +438,10 @@ msgctxt "field:product.template,container:"
msgid "Container"
msgstr "Envase"
msgctxt "field:product.template,quality_weighing:"
msgid "Quality Weighing"
msgstr "Calidad pesada"
msgctxt "model:agronomics.beneficiary,name:"
msgid "Beneficiaries"
msgstr "Beneficiarios"
@ -348,12 +484,32 @@ msgstr "Parcela"
msgctxt "model:agronomics.parcel-agronomics.do,name:"
msgid "Parcel - Denomination Origin"
msgstr "Parecela - Denominación de origen"
msgstr "Parcela - Denominación de origen"
msgctxt "model:agronomics.plantation,name:"
msgid "Plantation"
msgstr "Plantación"
msgctxt "model:agronomics.weighing,name:"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:agronomics.weighing-agronomics.do,name:"
msgid "Weighing - Denomination Origin"
msgstr "Pesada - Denominación de origen"
msgctxt "model:agronomics.weighing-agronomics.plantation,name:"
msgid "Weighing - Plantations"
msgstr "Pesada - Plantación"
msgctxt "model:agronomics.weighing-agronomics.plantations,name:"
msgid "Weighing - Plantations"
msgstr "Pesada - Plantación"
msgctxt "model:agronomics.weighing.center,name:"
msgid "Weighing Center"
msgstr "Centro de pesada"
msgctxt "model:ir.action,name:act_certification_tree"
msgid "Certification"
msgstr "Certificación"
@ -394,6 +550,31 @@ msgctxt "model:ir.action,name:act_plantation_tree"
msgid "Plantation"
msgstr "Plantación"
msgctxt "model:ir.action,name:act_weighing_action"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.action,name:act_weighing_center_action"
msgid "Weighing Center"
msgstr "Centro de pesada"
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_all"
msgid "All"
msgstr "Todos"
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_analysis"
msgid "In Analysis"
msgstr ""
msgctxt "model:ir.action.act_window.domain,name:act_weighing_domain_draft"
msgid "Draft"
msgstr "Esborany"
msgctxt ""
"model:ir.action.act_window.domain,name:act_weighing_domain_processing"
msgid "Processing"
msgstr "Procesos"
msgctxt "model:ir.message,text:msg_beneficiaris_percent"
msgid ""
"Beneficiaris of Crop \"%(crop)s\" and Plantation \"%(plantation)s\" must sum"
@ -418,6 +599,34 @@ msgstr ""
"El producto \"%(product)s\" no puede tener más de una cosecha debido a su "
"Tipo Agronómico"
msgctxt "model:ir.model.button,string:weighing_analysis_button"
msgid "Analysis"
msgstr "Análisis"
msgctxt "model:ir.model.button,string:weighing_cancel_button"
msgid "Cancel"
msgstr "Cancel·lar"
msgctxt "model:ir.model.button,string:weighing_done_button"
msgid "Done"
msgstr "Realizado"
msgctxt "model:ir.model.button,string:weighing_draft_button"
msgid "Draft"
msgstr "Esborany"
msgctxt "model:ir.model.button,string:weighing_process_button"
msgid "Process"
msgstr "Procesar"
msgctxt "model:ir.sequence,name:sequence_weighing"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.sequence.type,name:sequence_type_weighing"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:ir.ui.menu,name:menu_agronomics"
msgid "Agronomics"
msgstr "Agronomics"
@ -466,6 +675,14 @@ msgctxt "model:ir.ui.menu,name:menu_plantation_list"
msgid "Plantation"
msgstr "Plantación"
msgctxt "model:ir.ui.menu,name:menu_weighing_center_list"
msgid "Weighing Center"
msgstr "Centro de pesada"
msgctxt "model:ir.ui.menu,name:menu_weighing_list"
msgid "Weighing"
msgstr "Pesada"
msgctxt "model:product.product-agronomics.crop,name:"
msgid "Product - Crop"
msgstr "Producto - Cosecha"
@ -490,6 +707,26 @@ msgctxt "model:res.group,name:group_agronomics_admin"
msgid "Agronomics Administration"
msgstr "Agronomics Administración"
msgctxt "selection:agronomics.weighing,state:"
msgid "Cancelled"
msgstr "Cancelado"
msgctxt "selection:agronomics.weighing,state:"
msgid "Done"
msgstr "Realizado"
msgctxt "selection:agronomics.weighing,state:"
msgid "Draft"
msgstr "Esborany"
msgctxt "selection:agronomics.weighing,state:"
msgid "In Analysis"
msgstr "En Análisis"
msgctxt "selection:agronomics.weighing,state:"
msgid "Processing"
msgstr "Procesos"
msgctxt "selection:product.product,agronomic_type:"
msgid "Bottled Wine"
msgstr "Vino embotellado"

View File

@ -88,6 +88,7 @@ class Parcel(ModelSQL, ModelView):
plantation = fields.Many2One('agronomics.plantation', 'Plantation',
required=True)
crop = fields.Many2One('agronomics.crop', 'Crop', required=True)
product = fields.Many2One('product.template', 'Product', required=True)
species = fields.Many2One('product.taxon', 'Spices',
domain=[('rank', '=', 'species')], required=True,
depends=['species'])
@ -153,4 +154,5 @@ class Beneficiaries(ModelSQL, ModelView):
party = fields.Many2One('party.party', 'Beneficiary', required=True)
percent = fields.Float('Percent', digits=(16, 2), required=True)
parcel = fields.Many2One('agronomics.parcel', 'Parcel', required=True)
parcel = fields.Many2One('agronomics.parcel', 'Parcel')
weighing = fields.Many2One('agronomics.weighing', 'Weighing')

View File

@ -53,6 +53,8 @@ class Template(metaclass=PoolMeta):
}, depends=['agronomic_type']), 'get_capacity',
searcher='search_capacity')
quality_weighing = fields.Many2One('quality.template', 'Quality Weighing')
def get_capacity(self, name):
if self.container:
return self.container.capacity

View File

@ -7,9 +7,11 @@ depends:
product_classification
product_classification_taxonomic
quality_control_sample
purchase_contract
xml:
plot.xml
party.xml
product.xml
weighning.xml
wine.xml
message.xml

View File

@ -3,6 +3,8 @@
<field name="crop"/>
<label name="plantation"/>
<field name="plantation"/>
<label name="product"/>
<field name="product"/>
<label name="species"/>
<field name="species"/>
<label name="variety"/>

View File

@ -1,6 +1,7 @@
<tree>
<field name="plantation"/>
<field name="crop"/>
<field name="product"/>
<field name="variety"/>
<field name="species"/>
<field name="ecological"/>

View File

@ -6,5 +6,8 @@
<field name="container"/>
<label name="capacity"/>
<field name="capacity"/>
<label name="quality_weighing"/>
<field name="quality_weighing"/>
</xpath>
</data>

View File

@ -0,0 +1,6 @@
<form>
<label name="name"/>
<field name="name"/>
<label name="weighing_sequence"/>
<field name="weighing_sequence"/>
</form>

View File

@ -0,0 +1,3 @@
<tree>
<field name="name"/>
</tree>

51
view/weighing_form.xml Normal file
View File

@ -0,0 +1,51 @@
<form>
<label name="number"/>
<field name="number"/>
<label name="weighing_date"/>
<field name="weighing_date"/>
<label name="weighing_center"/>
<field name="weighing_center"/>
<label name="crop"/>
<field name="crop"/>
<label name="purchase_contract"/>
<field name="purchase_contract"/>
<label name="product"/>
<field name="product"/>
<label name="variety"/>
<field name="variety"/>
<label name="table"/>
<field name="table"/>
<label name="ecological"/>
<field name="ecological"/>
<group col="6" colspan="4" id="weight">
<label name="weight"/>
<field name="weight"/>
<label name="tara"/>
<field name="tara"/>
<label name="netweight"/>
<field name="netweight"/>
</group>
<label name="product_created"/>
<field name="product_created"/>
<label name="quality_test"/>
<field name="quality_test"/>
<notebook>
<page name="plantations">
<field name="plantations" colspan="4"/>
<field name="denomination_origin" colspan="4"/>
</page>
<page name="beneficiaries">
<field name="beneficiaries" colspan="4"/>
</page>
</notebook>
<label name="state"/>
<field name="state"/>
<group col="-1" colspan="2" id="buttons">
<button name="cancel" icon="tryton-cancel"/>
<button name="draft"/>
<button name="process" icon="tryton-forward"/>
<button name="analysis" icon="tryton-forward"/>
<button name="done" icon="tryton-forward"/>
</group>
</form>

15
view/weighing_list.xml Normal file
View File

@ -0,0 +1,15 @@
<tree>
<field name="number"/>
<field name="weighing_date"/>
<field name="weighing_center"/>
<field name="crop"/>
<field name="product"/>
<field name="variety"/>
<field name="all_do"/>
<field name="table"/>
<field name="ecological"/>
<field name="weight"/>
<field name="tara"/>
<field name="netweight"/>
<field name="state"/>
</tree>

364
weighing.py Normal file
View File

@ -0,0 +1,364 @@
# 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 fields, ModelSQL, ModelView, Workflow
from trytond.pyson import Id, Eval, If
from trytond.pool import Pool
from trytond.i18n import gettext
from trytond.exceptions import UserError
from trytond.transaction import Transaction
from datetime import datetime
class WeighingCenter(ModelSQL, ModelView):
""" Weighing Center """
__name__ = 'agronomics.weighing.center'
name = fields.Char('Name', required=True)
weighing_sequence = fields.Many2One('ir.sequence', 'Weighing Sequence',
domain=[
('sequence_type', '=', Id('agronomics', 'sequence_type_weighing'))
])
READONLY = ['processing', 'in_analysis', 'done', 'cancelled']
READONLY2 = ['draft', 'in_analysis', 'done', 'cancelled']
class Weighing(Workflow, ModelSQL, ModelView):
""" Weighing """
__name__ = 'agronomics.weighing'
_rec_name = 'number'
number = fields.Char('Number', readonly=True, select=True)
weighing_date = fields.Date('Date', states={
'readonly': Eval('state').in_(READONLY),
'required': True
}, depends=['state'])
weighing_center = fields.Many2One('agronomics.weighing.center',
'Weighing Center', states={
'readonly': Eval('state').in_(READONLY),
'required': True
}, depends=['state'])
purchase_contract = fields.Many2One('purchase.contract',
'Purchase Contract', states={
'readonly': Eval('state').in_(READONLY),
'required': True
}, depends=['state'])
crop = fields.Many2One('agronomics.crop', 'Crop', states={
'readonly': Eval('state').in_(READONLY),
'required': Eval('state') == 'in_analysis',
}, depends=['state'])
product = fields.Many2One('product.template', 'Product', states={
'readonly': Eval('state').in_(READONLY),
'required': Eval('state') == 'in_analysis',
}, depends=['state'])
variety = fields.Many2One('product.taxon', 'Variety', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
}, depends=['state'])
table = fields.Boolean('Table', states={
'readonly': Eval('state').in_(READONLY2),
}, depends=['state'])
ecological = fields.Many2One('agronomics.ecological', 'Ecological',
states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
}, depends=['state'])
weight = fields.Float('Weight', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
})
tara = fields.Float('Tara', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
})
netweight = fields.Float('Net Weight', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
})
beneficiaries = fields.One2Many('agronomics.beneficiary', 'weighing',
'Beneficiaries', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
})
denomination_origin = fields.Many2Many('agronomics.weighing-agronomics.do',
'weighing', 'do', 'Denomination of Origin', states={
'readonly': Eval('state').in_(READONLY2),
'required': Eval('state') == 'in_analysis',
})
plantations = fields.Many2Many('agronomics.weighing-agronomics.plantation',
'weighing', 'plantation', 'plantations', states={
'readonly': Eval('state').in_(READONLY),
'required': Eval('state') == 'process',
}, size=4)
state = fields.Selection([
('draft', "Draft"),
('processing', "Processing"),
('in_analysis', "In Analysis"),
('done', "Done"),
('cancelled', "Cancelled"),
], "State", readonly=True, required=True)
state_string = state.translated('state')
all_do = fields.Function(fields.Char('All DO'), 'get_all_do')
quality_test = fields.Many2One('quality.test', 'Test', readonly=True)
product_created = fields.Many2One('product.product', 'Product Created',
readonly=True)
@classmethod
def __setup__(cls):
super(Weighing, cls).__setup__()
cls._order = [
('weighing_date', 'DESC NULLS FIRST'),
('id', 'DESC'),
]
cls._transitions |= set((
('draft', 'processing'),
('processing', 'draft'),
('processing', 'in_analysis'),
('draft', 'cancelled'),
('processing', 'cancelled'),
('in_analysis', 'done'),
))
cls._buttons.update({
'done': {
'invisible': ~Eval('state').in_(['in_analysis']),
'depends': ['state'],
},
'cancel': {
'invisible': ~Eval('state').in_(['draft']),
'depends': ['state'],
},
'draft': {
'invisible': ~Eval('state').in_(['processing']),
'icon': If(Eval('state') == 'cancelled',
'tryton-undo',
'tryton-back'),
'depends': ['state'],
},
'process': {
'invisible': Eval('state') != 'draft',
'depends': ['state'],
},
'analysis': {
'invisible': Eval('state') != 'processing',
'depends': ['state'],
},
})
@staticmethod
def default_weighing_date():
Date = Pool().get('ir.date')
return Date.today()
@staticmethod
def default_state():
return 'draft'
def get_all_do(self, name):
return ",".join([x.name for x in self.denomination_origin])
@fields.depends('weighing_date')
def on_change_with_crop(self):
Crop = Pool().get('agronomics.crop')
crop = Crop.search([('start_date', '<=', self.weighing_date),
('end_date', '>=', self.weighing_date)], limit=1)
if not crop:
return
return crop[0].id
def get_parcel(self):
if not self.plantations:
return
plantation = self.plantations[0]
if not plantation.parcels:
return
return plantation.parcels[0]
@fields.depends('plantations')
def on_change_with_variety(self):
parcel = self.get_parcel()
if not parcel:
return
return parcel.variety and parcel.variety.id
@fields.depends('plantations')
def on_change_with_denomination_origin(self):
parcel = self.get_parcel()
if not parcel:
return
return [x.id for x in parcel.denomination_origin]
@fields.depends('plantations')
def on_change_with_table(self):
parcel = self.get_parcel()
if not parcel:
return
return parcel.table
@fields.depends('plantations')
def on_change_with_ecological(self):
parcel = self.get_parcel()
if not parcel:
return
return parcel.ecological and parcel.ecological.id
@fields.depends('plantations')
def on_change_with_product(self):
parcel = self.get_parcel()
if not parcel:
return
return parcel.product and parcel.product.id
@fields.depends('plantations')
def on_change_with_purchase_contract(self):
parcel = self.get_parcel()
if not parcel:
return
producer = parcel.producer and parcel.producer.id
if not producer:
return
Contract = Pool().get('purchase.contract')
contracts = Contract.search([('party', '=', producer)], limit=1)
if not contracts:
return
contract, = contracts
return contract and contract.id
@fields.depends('weight', 'tara')
def on_change_with_netweight(self):
return (self.weight or 0) - (self.tara or 0)
@classmethod
def validate(cls, records):
super().validate(records)
cls.check_percent_beneficiaries(records)
@classmethod
def check_percent_beneficiaries(cls, records):
for record in records:
if record.state == 'draft':
continue
percent = sum([x.percent for x in record.beneficiaries])
if record.beneficiaries and abs(100 - round(percent, 2)) > 0.0001:
raise UserError(gettext('agronomics.msg_beneficiaris_percent',
crop=record.crop.rec_name,
plantation=record.plantations[0].rec_name))
@classmethod
@Workflow.transition('in_analysis')
def analysis(cls, weighings):
pool = Pool()
Product = pool.get('product.product')
default_product_values = Product.default_get(Product._fields.keys(),
with_rec_name=False)
product = Product(**default_product_values)
for weighing in weighings:
product.template = weighing.product
product.denominations_of_origin = weighing.denomination_origin
product.ecologicals = [weighing.ecological]
product.varieties = [weighing.variety.id]
product.vintages = [weighing.crop.id]
weighing.product_created = product
weighing.quality_test = weighing.create_quality_test()
cls.save(weighings)
def create_quality_test(self):
pool = Pool()
QualityTest = pool.get('quality.test')
with Transaction().set_context(_check_access=False):
if not (self.product and self.product.quality_weighing):
return
template = self.product.quality_weighing
test = QualityTest(
test_date=datetime.now(),
templates=[template],
document=str(self))
test.apply_template_values()
return test
@classmethod
@Workflow.transition('draft')
def draft(cls, weighings):
pass
@classmethod
@Workflow.transition('done')
def done(cls, weighings):
pass
@classmethod
@Workflow.transition('processing')
def process(cls, weighings):
Beneficiary = Pool().get('agronomics.beneficiary')
to_save = []
for weighing in weighings:
if weighing.beneficiaries:
Beneficiary.delete([x for x in weighing.beneficiaries])
parcel = weighing.get_parcel()
if not parcel:
continue
for ben in parcel.beneficiaries:
b = Beneficiary()
b.party = ben.party
b.weighing = weighing
b.percent = ben.percent
to_save.append(b)
if to_save:
Beneficiary.save(to_save)
@classmethod
@Workflow.transition('cancel')
def cancel(cls, weighings):
pass
@classmethod
def set_number(cls, weighing_center):
WeighingCenter = Pool().get('agronomics.weighing.center')
weighing_center = WeighingCenter(weighing_center)
return (weighing_center.weighing_sequence and
weighing_center.weighing_sequence.get())
@classmethod
def create(cls, vlist):
vlist = [v.copy() for v in vlist]
for values in vlist:
if not values.get('number'):
values['number'] = cls.set_number(values.get('weighing_center'))
return super().create(vlist)
@classmethod
def copy(cls, weighings, default=None):
if default is None:
default = {}
else:
default = default.copy()
default.setdefault('beneficiaries', None)
return super().copy(weighings, default=default)
class WeighingDo(ModelSQL):
'Weighing - Denomination Origin'
__name__ = 'agronomics.weighing-agronomics.do'
weighing = fields.Many2One('agronomics.weighing', 'Weighing')
do = fields.Many2One('agronomics.denomination_of_origin',
'Denomination Origin')
class WeighingPlantation(ModelSQL):
'Weighing - Plantations'
__name__ = 'agronomics.weighing-agronomics.plantation'
weighing = fields.Many2One('agronomics.weighing', 'Weighing')
plantation = fields.Many2One('agronomics.plantation',
'Plantation')

202
weighning.xml Normal file
View File

@ -0,0 +1,202 @@
<tryton>
<data>
<!-- Weighing Center -->
<record model="ir.ui.view" id="weighing_center_view_form">
<field name="model">agronomics.weighing.center</field>
<field name="type">form</field>
<field name="name">weighing_center_form</field>
</record>
<record model="ir.ui.view" id="weighing_center_view_tree">
<field name="model">agronomics.weighing.center</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">weighing_center_list</field>
</record>
<record model="ir.action.act_window" id="act_weighing_center_action">
<field name="name">Weighing Center</field>
<field name="res_model">agronomics.weighing.center</field>
</record>
<record model="ir.action.act_window.view" id="act_weighing_center_tree_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="weighing_center_view_tree"/>
<field name="act_window" ref="act_weighing_center_action"/>
</record>
<record model="ir.action.act_window.view" id="act_weighing_center_tree_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="weighing_center_view_form"/>
<field name="act_window" ref="act_weighing_center_action"/>
</record>
<menuitem parent="menu_configuration" sequence="1"
action="act_weighing_center_action" id="menu_weighing_center_list"/>
<record model="ir.ui.menu-res.group"
id="menu_weighing_center_list_group_agronomics">
<field name="menu" ref="menu_weighing_center_list"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.ui.menu-res.group"
id="menu_weighing_center_list_group_agronomics_admin">
<field name="menu" ref="menu_weighing_center_list"/>
<field name="group" ref="group_agronomics_admin"/>
</record>
<!-- Weighing -->
<record model="ir.ui.view" id="weighing_view_form">
<field name="model">agronomics.weighing</field>
<field name="type">form</field>
<field name="name">weighing_form</field>
</record>
<record model="ir.ui.view" id="weighing_view_tree">
<field name="model">agronomics.weighing</field>
<field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="name">weighing_list</field>
</record>
<record model="ir.action.act_window" id="act_weighing_action">
<field name="name">Weighing</field>
<field name="res_model">agronomics.weighing</field>
</record>
<record model="ir.action.act_window.view" id="act_weighing_tree_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="weighing_view_tree"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<record model="ir.action.act_window.view" id="act_weighing_tree_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="weighing_view_form"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<record model="ir.action.act_window.domain" id="act_weighing_domain_draft">
<field name="name">Draft</field>
<field name="sequence" eval="10"/>
<field name="domain"
eval="[('state', '=', 'draft')]"
pyson="1"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<record model="ir.action.act_window.domain" id="act_weighing_domain_processing">
<field name="name">Processing</field>
<field name="sequence" eval="10"/>
<field name="domain"
eval="[('state', '=', 'processing')]"
pyson="1"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<record model="ir.action.act_window.domain" id="act_weighing_domain_analysis">
<field name="name">In Analysis</field>
<field name="sequence" eval="10"/>
<field name="domain"
eval="[('state', '=', 'in_analysis')]"
pyson="1"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<record model="ir.action.act_window.domain" id="act_weighing_domain_all">
<field name="name">All</field>
<field name="sequence" eval="10"/>
<field name="domain"/>
<field name="act_window" ref="act_weighing_action"/>
</record>
<menuitem parent="menu_agronomics" sequence="1"
action="act_weighing_action" id="menu_weighing_list"/>
<record model="ir.ui.menu-res.group"
id="menu_weighing_list_group_agronomics">
<field name="menu" ref="menu_weighing_list"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.ui.menu-res.group"
id="menu_weighing_list_group_agronomics_admin">
<field name="menu" ref="menu_weighing_list"/>
<field name="group" ref="group_agronomics_admin"/>
</record>
<record model="ir.sequence.type" id="sequence_type_weighing">
<field name="name">Weighing</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_weighing_group_admin">
<field name="sequence_type" ref="sequence_type_weighing"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_weighing_group_sale_admin">
<field name="sequence_type" ref="sequence_type_weighing"/>
<field name="group" ref="group_agronomics_admin"/>
</record>
<record model="ir.sequence" id="sequence_weighing">
<field name="name">Weighing</field>
<field name="sequence_type" ref="sequence_type_weighing"/>
</record>
<record model="ir.model.button" id="weighing_draft_button">
<field name="name">draft</field>
<field name="string">Draft</field>
<field name="model" search="[('model', '=', 'agronomics.weighing')]"/>
</record>
<record model="ir.model.button-res.group" id="weighing_draft_button_group_agronomics">
<field name="button" ref="weighing_draft_button"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.model.button" id="weighing_process_button">
<field name="name">process</field>
<field name="string">Process</field>
<field name="model" search="[('model', '=', 'agronomics.weighing')]"/>
</record>
<record model="ir.model.button-res.group" id="weighing_process_button_group_agronomics">
<field name="button" ref="weighing_process_button"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.model.button" id="weighing_analysis_button">
<field name="name">analysis</field>
<field name="string">Analysis</field>
<field name="model" search="[('model', '=', 'agronomics.weighing')]"/>
</record>
<record model="ir.model.button-res.group" id="weighing_analysis_button_group_agronomics">
<field name="button" ref="weighing_analysis_button"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.model.button" id="weighing_cancel_button">
<field name="name">cancel</field>
<field name="string">Cancel</field>
<field name="model" search="[('model', '=', 'agronomics.weighing')]"/>
</record>
<record model="ir.model.button-res.group" id="weighing_cancel_button_group_agronomics">
<field name="button" ref="weighing_cancel_button"/>
<field name="group" ref="group_agronomics"/>
</record>
<record model="ir.model.button" id="weighing_done_button">
<field name="name">done</field>
<field name="string">Done</field>
<field name="model" search="[('model', '=', 'agronomics.weighing')]"/>
</record>
<record model="ir.model.button-res.group" id="weighing_done_button_group_agronomics">
<field name="button" ref="weighing_done_button"/>
<field name="group" ref="group_agronomics"/>
</record>
</data>
</tryton>