From 112c9754a1e7dbede6cad171a40b6b059c9195ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80ngel=20=C3=80lvarez?= Date: Mon, 21 Jun 2021 12:14:21 +0200 Subject: [PATCH 01/45] fix typo on view file --- plot.xml | 1 - view/{beneficary_form.xml => beneficiary_form.xml} | 1 - 2 files changed, 2 deletions(-) rename view/{beneficary_form.xml => beneficiary_form.xml} (99%) diff --git a/plot.xml b/plot.xml index d4f00aa..6bf9f7c 100644 --- a/plot.xml +++ b/plot.xml @@ -388,7 +388,6 @@ - agronomics.beneficiary form diff --git a/view/beneficary_form.xml b/view/beneficiary_form.xml similarity index 99% rename from view/beneficary_form.xml rename to view/beneficiary_form.xml index e914784..d87b709 100644 --- a/view/beneficary_form.xml +++ b/view/beneficiary_form.xml @@ -5,5 +5,4 @@ - - - - @@ -244,7 +244,7 @@ - @@ -331,7 +331,7 @@ - diff --git a/tryton.cfg b/tryton.cfg index 3e316c7..8c380b6 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -6,3 +6,4 @@ depends: product_classification_taxonomic xml: plot.xml + message.xml diff --git a/view/parcel_form.xml b/view/parcel_form.xml index 0910755..741518d 100644 --- a/view/parcel_form.xml +++ b/view/parcel_form.xml @@ -9,8 +9,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/product.py b/product.py new file mode 100644 index 0000000..a30e282 --- /dev/null +++ b/product.py @@ -0,0 +1,142 @@ +# 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.pyson import Eval +from trytond.exceptions import UserError +from trytond.i18n import gettext + + +class Certification(ModelSQL, ModelView): + "Certification" + __name__ = 'agronomics.certification' + _rec_name = 'number' + + number = fields.Char('Number') + date = fields.Date('Date') + + def get_rec_name(self, name): + return self.number + + +class Container(ModelSQL, ModelView): + "Container" + __name__ = 'agronomics.container' + + name = fields.Char('Name') + capacity = fields.Numeric('Capacity', digits=(16, 2)) + + +class Template(metaclass=PoolMeta): + __name__ = 'product.template' + + agronomic_type = fields.Selection([ + (None, ''), + ('grape', "Grape"), + ('do-wort', "DO Wort"), + ('not-do-wort', "Not DO Wort"), + ('wine', "Wine"), + ('bottled-wine', "Bottled Wine"), + ], "Agronomic Type", select=True) + container = fields.Many2One('agronomics.container', 'Container', + states={ + 'invisible': Eval('agronomic_type') != 'bottled-wine', + }, depends=['agronomic_type']) + capacity = fields.Function(fields.Numeric('Capacity', digits=(16, 2), + states={ + 'invisible': Eval('agronomic_type') != 'bottled-wine', + }, depends=['agronomic_type']), 'get_capacity', + searcher='search_capacity') + + def get_capacity(self, name): + if self.container: + return self.container.capacity + + @classmethod + def search_capacity(cls, name, clause): + return [('container.capacity',) + tuple(clause[1:])] + + +class Product(metaclass=PoolMeta): + __name__ = 'product.product' + + vintages = fields.Many2Many('product.product-agronomics.crop', 'product', + 'crop', 'Vintages') + varieties = fields.Many2Many('product.product-product.taxon', 'product', + 'variety', 'Varieties') + denominations_of_origin = fields.Many2Many( + 'product.product-agronomics.denomination_of_origin', 'product', + 'do', 'DOs', + states={ + 'invisible': Eval('agronomic_type').in_( + ['not-do-wort'] + ) + }, depends=['agronomic_type']) + ecologicals = fields.Many2Many('product.product-agronomics.ecological', + 'product', 'ecological', 'Ecologicals') + quality_sample = fields.Many2One('quality.sample', 'Quality Sample', + states={ + 'invisible': ~ Eval('agronomic_type').in_( + ['wine', 'bottled-wine'] + ) + }, depends=['agronomic_type']) + certification = fields.Many2One('agronomics.certification', + 'Certification', states={ + 'invisible': ~ Eval('agronomic_type').in_( + ['wine', 'bottled-wine'] + ) + }, depends=['agronomic_type']) + alcohol_volume = fields.Numeric('Alcohol Volume', digits=(16, 2), states={ + 'invisible': ~ Eval('agronomic_type').in_( + ['wine', 'bottled-wine'] + )}, depends=['agronomic_type']) + + @classmethod + def validate(cls, products): + for product in products: + if (product.agronomic_type in + ['grape', 'do-wort', 'not-do-wort', 'bottled-wine']): + if len(product.vintages) > 1: + raise UserError(gettext('agronomics.msg_vintage_limit', + product=product.rec_name)) + if (product.agronomic_type in + ['grape']): + if len(product.varieties) > 1: + raise UserError(gettext('agronomics.msg_variety_limit', + product=product.rec_name)) + + +class ProductCrop(ModelSQL): + "Product - Crop" + __name__ = 'product.product-agronomics.crop' + product = fields.Many2One('product.product', 'Product', + ondelete='CASCADE', select=True, required=True) + crop = fields.Many2One('agronomics.crop', 'Crop', + ondelete='CASCADE', select=True, required=True) + + +class ProductVariety(ModelSQL): + "Product - Variety" + __name__ = 'product.product-product.taxon' + product = fields.Many2One('product.product', 'Product', + ondelete='CASCADE', select=True, required=True) + variety = fields.Many2One('product.taxon', 'Variety', + ondelete='CASCADE', select=True, required=True) + + +class ProductDO(ModelSQL): + "Product - DO" + __name__ = 'product.product-agronomics.denomination_of_origin' + product = fields.Many2One('product.product', 'Product', + ondelete='CASCADE', select=True, required=True) + do = fields.Many2One('agronomics.denomination_of_origin', 'DO', + ondelete='CASCADE', select=True, required=True) + + +class ProductEcological(ModelSQL): + "Product - Ecological" + __name__ = 'product.product-agronomics.ecological' + product = fields.Many2One('product.product', 'Product', + ondelete='CASCADE', select=True, required=True) + ecological = fields.Many2One('agronomics.ecological', 'Ecological', + ondelete='CASCADE', select=True, required=True) \ No newline at end of file diff --git a/product.xml b/product.xml new file mode 100644 index 0000000..3150f14 --- /dev/null +++ b/product.xml @@ -0,0 +1,159 @@ + + + + + product.template + template_form + + + + product.template + template_list + + + + + product.product + product_form + + + + product.product + product_list + + + + + agronomics.certification + form + certification_form + + + agronomics.certification + tree + + certification_list + + + + Certification + agronomics.certification + + + + + + + + + + + + + + + + + + + + + + + + + + agronomics.container + form + container_form + + + agronomics.container + tree + + container_list + + + + Container + agronomics.container + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tryton.cfg b/tryton.cfg index e0810ab..d67166e 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -4,7 +4,9 @@ depends: party product_classification product_classification_taxonomic + quality_control_sample xml: plot.xml party.xml message.xml + product.xml diff --git a/view/certification_form.xml b/view/certification_form.xml new file mode 100644 index 0000000..8d2065d --- /dev/null +++ b/view/certification_form.xml @@ -0,0 +1,6 @@ +
+