From f25fd3681419d3347adbb6ab548ffee97cebbb44 Mon Sep 17 00:00:00 2001 From: sinergia Date: Tue, 14 Jun 2022 19:07:35 -0500 Subject: [PATCH] add views template --- __init__.py | 6 +----- party.py | 0 product.py | 32 +++++++++++++++++++++----------- product.xml | 6 +++--- view/product_template_form.xml | 19 ------------------- view/product_template_tree.xml | 3 --- 6 files changed, 25 insertions(+), 41 deletions(-) delete mode 100644 party.py delete mode 100644 view/product_template_form.xml delete mode 100644 view/product_template_tree.xml diff --git a/__init__.py b/__init__.py index 967c857..c849a77 100644 --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,7 @@ from trytond.pool import Pool from . import product - -__all__ = ['register'] - - def register(): Pool.register( - product.Product, + product.Template, module='optical_equipment', type_='model') diff --git a/party.py b/party.py deleted file mode 100644 index e69de29..0000000 diff --git a/product.py b/product.py index c7436ba..0af0210 100644 --- a/product.py +++ b/product.py @@ -2,10 +2,9 @@ #txhis repository contains the full copyright notices and license terms from trytond.pool import Pool, PoolMeta -from trytond.model import ModelView, ModelSQL -from trytond.model import fields +from trytond.model import ModelView, ModelSQL, fields +from trytond.pyson import If, Eval -__all__ = ['Product'] _RISK = [('uno', 'I'), ('dosA', 'IIA'), @@ -26,11 +25,12 @@ _MAIN_TECNOLOGY = [('mecanico', 'Mecánico'), _MACHINE_TYPE = [('mobiliario_optico', 'Mobiliario óptico'), ('refraccion', 'Refracción'), - ('medicio', 'Medicion'), + ('medico', 'Medicion'), ('accesorios', 'Accesorios')] -class Product(ModelSQL, ModelView, metaclass=PoolMeta): - 'Product' + +class Template(metaclass=PoolMeta): + 'Template' __name__ = 'product.template' machine = fields.Boolean('It is machine') @@ -43,8 +43,9 @@ class Product(ModelSQL, ModelView, metaclass=PoolMeta): 'Main tecnology') calibration = fields.Boolean("Apply calibration") observation = fields.Text(size=None) - trade_mark = fields.Char("Trade Mark", size=None, required=True) - model = fields.Char("Model", size=None, required=True) + mark_category = fields.Many2One('product.category', 'Mark') + model_category = fields.Many2One('product.category', "Model", + domain=[Eval('parent')]) reference = fields.Char("Reference", size=None, required=True) origin_country = fields.Many2One('country.country',"Origin Country") software_version = fields.Char( @@ -86,7 +87,16 @@ class Product(ModelSQL, ModelView, metaclass=PoolMeta): @staticmethod def default_refurbish(): return False - - - + + @fields.depends('mark_category', 'model_category') + def on_change_mark_category(self): + if self.mark_category: + self.model_category = None + + @classmethod + def view_attributes(cls): + return super(Template, cls).view_attributes() + [ + ('//page[@id="features"]', 'states', { + 'invisible': ~Eval('machine'), + })] diff --git a/product.xml b/product.xml index d0be9a3..34d0252 100644 --- a/product.xml +++ b/product.xml @@ -4,9 +4,9 @@ - product.template - - template_form + product.template + + template_form product.template diff --git a/view/product_template_form.xml b/view/product_template_form.xml deleted file mode 100644 index e31b1a8..0000000 --- a/view/product_template_form.xml +++ /dev/null @@ -1,19 +0,0 @@ - - -
- - - - -
- - diff --git a/view/product_template_tree.xml b/view/product_template_tree.xml deleted file mode 100644 index 159b3de..0000000 --- a/view/product_template_tree.xml +++ /dev/null @@ -1,3 +0,0 @@ - -