new features
This commit is contained in:
parent
6a93796643
commit
96f5d99022
|
@ -14,6 +14,7 @@ def register():
|
|||
plot.Plantation,
|
||||
plot.Ecological,
|
||||
plot.Parcel,
|
||||
plot.ParcelDo,
|
||||
plot.Beneficiaries,
|
||||
module='agronomics', type_='model')
|
||||
Pool.register(
|
||||
|
|
34
locale/ca.po
34
locale/ca.po
|
@ -92,12 +92,16 @@ msgstr "Producció Màxima (kg/ha)"
|
|||
|
||||
msgctxt "field:agronomics.max.production.allowed,product:"
|
||||
msgid "Product"
|
||||
msgstr "Productes"
|
||||
msgstr "Producte"
|
||||
|
||||
msgctxt "field:agronomics.max.production.allowed,variety:"
|
||||
msgid "Variety"
|
||||
msgstr "Varietat"
|
||||
|
||||
msgctxt "field:agronomics.parcel,all_do:"
|
||||
msgid "All DO"
|
||||
msgstr "Totes les DO"
|
||||
|
||||
msgctxt "field:agronomics.parcel,beneficiaries:"
|
||||
msgid "Beneficiaries"
|
||||
msgstr "Beneficiaris"
|
||||
|
@ -119,7 +123,7 @@ msgid "Irrigation"
|
|||
msgstr "Irrigació"
|
||||
|
||||
msgctxt "field:agronomics.parcel,max_production:"
|
||||
msgid "Max Production"
|
||||
msgid "Max. Production"
|
||||
msgstr "Producció Màxima"
|
||||
|
||||
msgctxt "field:agronomics.parcel,plant_number:"
|
||||
|
@ -136,12 +140,16 @@ msgstr "Premium"
|
|||
|
||||
msgctxt "field:agronomics.parcel,producer:"
|
||||
msgid "Party"
|
||||
msgstr "Tercers"
|
||||
msgstr "Productor"
|
||||
|
||||
msgctxt "field:agronomics.parcel,species:"
|
||||
msgid "Spices"
|
||||
msgstr "Espècie"
|
||||
|
||||
msgctxt "field:agronomics.parcel,spieces:"
|
||||
msgid "Spices"
|
||||
msgstr "Espècie"
|
||||
|
||||
msgctxt "field:agronomics.parcel,surface:"
|
||||
msgid "Surface"
|
||||
msgstr "Superfície"
|
||||
|
@ -158,6 +166,14 @@ msgctxt "field:agronomics.parcel,variety:"
|
|||
msgid "Variety"
|
||||
msgstr "Varietat"
|
||||
|
||||
msgctxt "field:agronomics.parcel-agronomics.do,do:"
|
||||
msgid "Denomination Origin"
|
||||
msgstr "Denominació d'origen"
|
||||
|
||||
msgctxt "field:agronomics.parcel-agronomics.do,parcel:"
|
||||
msgid "Parcel"
|
||||
msgstr "Parcel·la"
|
||||
|
||||
msgctxt "field:agronomics.plantation,code:"
|
||||
msgid "Code"
|
||||
msgstr "Codi"
|
||||
|
@ -206,6 +222,10 @@ msgctxt "model:agronomics.parcel,name:"
|
|||
msgid "Parcel"
|
||||
msgstr "Parcel·la"
|
||||
|
||||
msgctxt "model:agronomics.parcel-agronomics.do,name:"
|
||||
msgid "Parcel - Denomination Origin"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "model:agronomics.plantation,name:"
|
||||
msgid "Plantation"
|
||||
msgstr "Plantació"
|
||||
|
@ -242,6 +262,14 @@ msgctxt "model:ir.action,name:act_plantation_tree"
|
|||
msgid "Plantation"
|
||||
msgstr "Plantació"
|
||||
|
||||
msgctxt "model:ir.message,text:msg_beneficiaris_percent"
|
||||
msgid ""
|
||||
"Beneficiaris of Crop \"%(crop)s\" and Plantation \"%(plantation)s\" must sum"
|
||||
" 100."
|
||||
msgstr ""
|
||||
"Els % Beneficiares de les collites \"%(crop)s\" i la plantació "
|
||||
"\"%(plantation)s\" han de sumar 100."
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_agronomics"
|
||||
msgid "Agronomics"
|
||||
msgstr "Agronomics"
|
||||
|
|
34
locale/es.po
34
locale/es.po
|
@ -92,12 +92,16 @@ msgstr "Producción Máxima (kg/ha)"
|
|||
|
||||
msgctxt "field:agronomics.max.production.allowed,product:"
|
||||
msgid "Product"
|
||||
msgstr "Productos"
|
||||
msgstr "Producto"
|
||||
|
||||
msgctxt "field:agronomics.max.production.allowed,variety:"
|
||||
msgid "Variety"
|
||||
msgstr "Variedad"
|
||||
|
||||
msgctxt "field:agronomics.parcel,all_do:"
|
||||
msgid "All DO"
|
||||
msgstr "Todos los DO"
|
||||
|
||||
msgctxt "field:agronomics.parcel,beneficiaries:"
|
||||
msgid "Beneficiaries"
|
||||
msgstr "Beneficiarios"
|
||||
|
@ -119,7 +123,7 @@ msgid "Irrigation"
|
|||
msgstr "Irrigación"
|
||||
|
||||
msgctxt "field:agronomics.parcel,max_production:"
|
||||
msgid "Max Production"
|
||||
msgid "Max. Production"
|
||||
msgstr "Producción Máxima"
|
||||
|
||||
msgctxt "field:agronomics.parcel,plant_number:"
|
||||
|
@ -136,12 +140,16 @@ msgstr "Premium"
|
|||
|
||||
msgctxt "field:agronomics.parcel,producer:"
|
||||
msgid "Party"
|
||||
msgstr "Terceros"
|
||||
msgstr "Productor"
|
||||
|
||||
msgctxt "field:agronomics.parcel,species:"
|
||||
msgid "Spices"
|
||||
msgstr "Especie"
|
||||
|
||||
msgctxt "field:agronomics.parcel,spieces:"
|
||||
msgid "Spices"
|
||||
msgstr "Especie"
|
||||
|
||||
msgctxt "field:agronomics.parcel,surface:"
|
||||
msgid "Surface"
|
||||
msgstr "Superficie"
|
||||
|
@ -158,6 +166,14 @@ msgctxt "field:agronomics.parcel,variety:"
|
|||
msgid "Variety"
|
||||
msgstr "Variedad"
|
||||
|
||||
msgctxt "field:agronomics.parcel-agronomics.do,do:"
|
||||
msgid "Denomination Origin"
|
||||
msgstr "Denominación de origen"
|
||||
|
||||
msgctxt "field:agronomics.parcel-agronomics.do,parcel:"
|
||||
msgid "Parcel"
|
||||
msgstr "Parcela"
|
||||
|
||||
msgctxt "field:agronomics.plantation,code:"
|
||||
msgid "Code"
|
||||
msgstr "Código"
|
||||
|
@ -206,6 +222,10 @@ msgctxt "model:agronomics.parcel,name:"
|
|||
msgid "Parcel"
|
||||
msgstr "Parcela"
|
||||
|
||||
msgctxt "model:agronomics.parcel-agronomics.do,name:"
|
||||
msgid "Parcel - Denomination Origin"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "model:agronomics.plantation,name:"
|
||||
msgid "Plantation"
|
||||
msgstr "Plantación"
|
||||
|
@ -242,6 +262,14 @@ msgctxt "model:ir.action,name:act_plantation_tree"
|
|||
msgid "Plantation"
|
||||
msgstr "Plantación"
|
||||
|
||||
msgctxt "model:ir.message,text:msg_beneficiaris_percent"
|
||||
msgid ""
|
||||
"Beneficiaris of Crop \"%(crop)s\" and Plantation \"%(plantation)s\" must sum"
|
||||
" 100."
|
||||
msgstr ""
|
||||
"El % de los beneficiarios de la cosecha \"%(crop)s\" y de la plantación "
|
||||
"\"%(plantation)s\" han de sumar 100."
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_agronomics"
|
||||
msgid "Agronomics"
|
||||
msgstr "Agronomics"
|
||||
|
|
66
plot.py
66
plot.py
|
@ -1,7 +1,9 @@
|
|||
# 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
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
class Enclosure(ModelSQL, ModelView):
|
||||
""" Enclosure """
|
||||
|
@ -45,7 +47,7 @@ class MaxProductionAllowed(ModelSQL, ModelView):
|
|||
variety = fields.Many2One('product.taxon', 'Variety',
|
||||
domain=[('rank', '=', 'variety')], required=True,
|
||||
depends=['variety'])
|
||||
max_production = fields.Numeric('Max Production (kg/ha)')
|
||||
max_production = fields.Numeric('Max Production (kg/ha)', required=True)
|
||||
|
||||
|
||||
class Irrigation(ModelSQL, ModelView):
|
||||
|
@ -64,6 +66,11 @@ class Plantation(ModelSQL, ModelView):
|
|||
'Enclosure')
|
||||
parcels = fields.One2Many('agronomics.parcel', 'plantation', 'Parcel')
|
||||
|
||||
def get_rec_name(self, name):
|
||||
if self.code:
|
||||
return self.code
|
||||
return self.name
|
||||
|
||||
|
||||
class Ecological(ModelSQL, ModelView):
|
||||
""" Ecological """
|
||||
|
@ -79,26 +86,63 @@ class Parcel(ModelSQL, ModelView):
|
|||
plantation = fields.Many2One('agronomics.plantation', 'Plantation',
|
||||
required=True)
|
||||
crop = fields.Many2One('agronomics.crop', 'Crop', required=True)
|
||||
variety = fields.Many2One('product.taxon', 'Variety',
|
||||
domain=[('rank', '=', 'variety')], required=True,
|
||||
depends=['variety'])
|
||||
species = fields.Many2One('product.taxon', 'Spices',
|
||||
domain=[('rank', '=', 'species')], required=True,
|
||||
depends=['species'])
|
||||
variety = fields.Many2One('product.taxon', 'Variety',
|
||||
domain=[('rank', '=', 'variety')], required=True,
|
||||
depends=['variety'])
|
||||
ecological = fields.Many2One('agronomics.ecological', 'Ecological')
|
||||
denomination_origin = fields.Many2One('agronomics.denomination_of_origin',
|
||||
'Denomination of Origin', required=True)
|
||||
denomination_origin = fields.Many2Many('agronomics.parcel-agronomics.do',
|
||||
'parcel', 'do', 'Denomination of Origin')
|
||||
table = fields.Boolean('Table')
|
||||
premium = fields.Boolean('Premium')
|
||||
plant_number = fields.Integer('Plant number')
|
||||
surface = fields.Float('Surface', digits=(16, 2))
|
||||
surface = fields.Float('Surface', digits=(16, 2), required=True)
|
||||
producer = fields.Many2One('party.party', 'Party')
|
||||
irrigation = fields.Many2One('agronomics.irrigation', 'Irrigation')
|
||||
max_production = fields.Many2One('agronomics.max.production.allowed',
|
||||
'Max Production')
|
||||
tenure_regime = fields.Text('Teneru Regime')
|
||||
max_production = fields.Function(fields.Float("Max. Production",
|
||||
digits=(16, 2)), 'get_max_production')
|
||||
tenure_regime = fields.Char('Teneru Regime')
|
||||
beneficiaries = fields.One2Many('agronomics.beneficiary', 'parcel',
|
||||
'Beneficiaries')
|
||||
all_do = fields.Function(fields.Char('All DO'), 'get_all_do')
|
||||
|
||||
@classmethod
|
||||
def validate(cls, records):
|
||||
super().validate(records)
|
||||
cls.check_percent_beneficiaries(records)
|
||||
|
||||
@classmethod
|
||||
def check_percent_beneficiaries(cls, records):
|
||||
for record in records:
|
||||
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.plantation.rec_name))
|
||||
|
||||
def get_all_do(self, name):
|
||||
return ",".join([x.name for x in self.denomination_origin])
|
||||
|
||||
def get_max_production(self, name):
|
||||
MaxProduction = Pool().get('agronomics.max.production.allowed')
|
||||
max_production = MaxProduction.search([('crop', '=', self.crop.id),
|
||||
('variety', '=', self.variety.id), ('denomination_origin', 'in',
|
||||
self.denomination_origin)])
|
||||
if not max_production:
|
||||
return None
|
||||
return round(float(min([x.max_production for x in max_production])
|
||||
)*self.surface, 2)
|
||||
|
||||
class ParcelDo(ModelSQL):
|
||||
'Parcel - Denomination Origin'
|
||||
__name__ = 'agronomics.parcel-agronomics.do'
|
||||
|
||||
parcel = fields.Many2One('agronomics.parcel', 'Parcel')
|
||||
do = fields.Many2One('agronomics.denomination_of_origin',
|
||||
'Denomination Origin')
|
||||
|
||||
|
||||
class Beneficiaries(ModelSQL, ModelView):
|
||||
""" Beneficiaries """
|
||||
|
|
12
plot.xml
12
plot.xml
|
@ -72,7 +72,7 @@
|
|||
<field name="act_window" ref="act_enclosure_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_enclosure_tree" id="menu_enclosure_list"/>
|
||||
|
||||
<record model="ir.ui.menu-res.group"
|
||||
|
@ -115,7 +115,7 @@
|
|||
<field name="act_window" ref="act_crop_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_crop_tree" id="menu_crop_list"/>
|
||||
|
||||
<record model="ir.ui.menu-res.group"
|
||||
|
@ -158,7 +158,7 @@
|
|||
<field name="act_window" ref="act_do_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_do_tree" id="menu_do_list"/>
|
||||
|
||||
<record model="ir.ui.menu-res.group"
|
||||
|
@ -201,7 +201,7 @@
|
|||
<field name="act_window" ref="act_max_production_allowed_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_max_production_allowed_tree" id="menu_max_production_allowed_list"/>
|
||||
<record model="ir.ui.menu-res.group"
|
||||
id="menu_max_production_allowed_list_group_agronomics">
|
||||
|
@ -244,7 +244,7 @@
|
|||
<field name="act_window" ref="act_irrigation_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_irrigation_tree" id="menu_irrigation_list"/>
|
||||
<record model="ir.ui.menu-res.group"
|
||||
id="menu_irrigation_list_group_agronomics">
|
||||
|
@ -331,7 +331,7 @@
|
|||
<field name="act_window" ref="act_ecological_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem parent="menu_agronomics" sequence="1"
|
||||
<menuitem parent="menu_configuration" sequence="1"
|
||||
action="act_ecological_tree" id="menu_ecological_list"/>
|
||||
<record model="ir.ui.menu-res.group"
|
||||
id="menu_ecological_list_group_agronomics">
|
||||
|
|
|
@ -6,3 +6,4 @@ depends:
|
|||
product_classification_taxonomic
|
||||
xml:
|
||||
plot.xml
|
||||
message.xml
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
<field name="species"/>
|
||||
<label name="ecological"/>
|
||||
<field name="ecological"/>
|
||||
<label name="denomination_origin"/>
|
||||
<field name="denomination_origin"/>
|
||||
<label name="table"/>
|
||||
<field name="table"/>
|
||||
<label name="premium"/>
|
||||
|
@ -23,7 +21,11 @@
|
|||
<field name="producer"/>
|
||||
<label name="irrigation"/>
|
||||
<field name="irrigation"/>
|
||||
<label name="surface"/>
|
||||
<field name="surface"/>
|
||||
<newline/>
|
||||
<label name="tenure_regime"/>
|
||||
<field name="tenure_regime" colspan="4"/>
|
||||
<field name="tenure_regime" colspan="3"/>
|
||||
<field name="denomination_origin" colspan="4"/>
|
||||
<field name="beneficiaries" colspan="4"/>
|
||||
</form>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<field name="variety"/>
|
||||
<field name="species"/>
|
||||
<field name="ecological"/>
|
||||
<field name="denomination_origin"/>
|
||||
<field name="all_do"/>
|
||||
<field name="table"/>
|
||||
<field name="premium"/>
|
||||
<field name="max_production"/>
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<notebook>
|
||||
<page name="enclosures">
|
||||
<field name="enclosures" widget="many2many"/>
|
||||
</page>
|
||||
<page name="parcels">
|
||||
<field name="parcels" widget="many2many"/>
|
||||
</page>
|
||||
<page name="enclosures">
|
||||
<field name="enclosures" widget="many2many"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue