add views template

This commit is contained in:
sinergia 2022-06-14 19:07:35 -05:00
parent b4f4bbace3
commit f25fd36814
6 changed files with 25 additions and 41 deletions

View File

@ -1,11 +1,7 @@
from trytond.pool import Pool from trytond.pool import Pool
from . import product from . import product
__all__ = ['register']
def register(): def register():
Pool.register( Pool.register(
product.Product, product.Template,
module='optical_equipment', type_='model') module='optical_equipment', type_='model')

View File

View File

@ -2,10 +2,9 @@
#txhis repository contains the full copyright notices and license terms #txhis repository contains the full copyright notices and license terms
from trytond.pool import Pool, PoolMeta from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView, ModelSQL from trytond.model import ModelView, ModelSQL, fields
from trytond.model import fields from trytond.pyson import If, Eval
__all__ = ['Product']
_RISK = [('uno', 'I'), _RISK = [('uno', 'I'),
('dosA', 'IIA'), ('dosA', 'IIA'),
@ -26,11 +25,12 @@ _MAIN_TECNOLOGY = [('mecanico', 'Mecánico'),
_MACHINE_TYPE = [('mobiliario_optico', 'Mobiliario óptico'), _MACHINE_TYPE = [('mobiliario_optico', 'Mobiliario óptico'),
('refraccion', 'Refracción'), ('refraccion', 'Refracción'),
('medicio', 'Medicion'), ('medico', 'Medicion'),
('accesorios', 'Accesorios')] ('accesorios', 'Accesorios')]
class Product(ModelSQL, ModelView, metaclass=PoolMeta):
'Product' class Template(metaclass=PoolMeta):
'Template'
__name__ = 'product.template' __name__ = 'product.template'
machine = fields.Boolean('It is machine') machine = fields.Boolean('It is machine')
@ -43,8 +43,9 @@ class Product(ModelSQL, ModelView, metaclass=PoolMeta):
'Main tecnology') 'Main tecnology')
calibration = fields.Boolean("Apply calibration") calibration = fields.Boolean("Apply calibration")
observation = fields.Text(size=None) observation = fields.Text(size=None)
trade_mark = fields.Char("Trade Mark", size=None, required=True) mark_category = fields.Many2One('product.category', 'Mark')
model = fields.Char("Model", size=None, required=True) model_category = fields.Many2One('product.category', "Model",
domain=[Eval('parent')])
reference = fields.Char("Reference", size=None, required=True) reference = fields.Char("Reference", size=None, required=True)
origin_country = fields.Many2One('country.country',"Origin Country") origin_country = fields.Many2One('country.country',"Origin Country")
software_version = fields.Char( software_version = fields.Char(
@ -86,7 +87,16 @@ class Product(ModelSQL, ModelView, metaclass=PoolMeta):
@staticmethod @staticmethod
def default_refurbish(): def default_refurbish():
return False 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'),
})]

View File

@ -4,9 +4,9 @@
<tryton> <tryton>
<data> <data>
<record model="ir.ui.view" id="template_view_form"> <record model="ir.ui.view" id="template_view_form">
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit" ref="product.template_view_form"/> <field name="inherit" ref="product.template_view_form"/>
<field name="name">template_form</field> <field name="name">template_form</field>
</record> </record>
<record model="ir.ui.view" id="template_view_tree"> <record model="ir.ui.view" id="template_view_tree">
<field name="model">product.template</field> <field name="model">product.template</field>

View File

@ -1,19 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form col="6">
<notebook colspan="6">
<page string="Features" id="features">
<label name="risk"/>
<field name="risk"/>
<label name="use"/>
<field name="use"/>
<label name="biomedical_class"/>
<field name="biomedical_class"/>
<label name="main_tecnology"/>
<field name="main_tecnology"/>
</page>
</notebook>
</form>

View File

@ -1,3 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->