model of products
This commit is contained in:
parent
5f73e49550
commit
f0faa4058f
@ -2,7 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from . import party, product
|
||||
from . import party, product, maintenance
|
||||
|
||||
__all__ = ['register']
|
||||
|
||||
@ -12,7 +12,11 @@ def register():
|
||||
party.Address,
|
||||
party.Party,
|
||||
product.Template,
|
||||
product.Product,
|
||||
product.Pattern,
|
||||
product.Image,
|
||||
maintenance.MaintenanceService,
|
||||
maintenance.MaintenanceLine,
|
||||
module='optical_equipment', type_='model')
|
||||
Pool.register(
|
||||
module='optical_equipment', type_='wizard')
|
||||
|
35
maintenance.py
Normal file
35
maintenance.py
Normal file
@ -0,0 +1,35 @@
|
||||
# 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 (
|
||||
Workflow, ModelSQL, ModelView, Unique, fields, sequence_ordered)
|
||||
from trytond.wizard import (
|
||||
Button, StateAction, StateTransition, StateView, Wizard)
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Bool, Eval, If, Id, Equal
|
||||
from trytond.pool import Pool
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
from trytond.modules.product import price_digits
|
||||
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
#from scipy.stats import t
|
||||
#import matplotlib.pyplot as plt
|
||||
#import numpy as np
|
||||
#import math as mt
|
||||
|
||||
from io import BytesIO
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
_digits = (16, 2)
|
||||
|
||||
|
||||
class MaintenanceService(Workflow, ModelSQL, ModelView):
|
||||
'Equipment Maintenance Service'
|
||||
__name__ = 'optical_equipment_maintenance.service'
|
||||
|
||||
|
||||
class MaintenanceLine(Workflow, ModelSQL, ModelView):
|
||||
'Equipment Maintenance'
|
||||
__name__ = 'optical_equipment.maintenance'
|
99
product.py
99
product.py
@ -23,7 +23,7 @@ _BIOMEDICAL_CLASS = [
|
||||
|
||||
_MAIN_TECNOLOGY = [
|
||||
('', ""),
|
||||
('mecanico', 'Mecánico'),
|
||||
('mecanico', 'Mecánico'),
|
||||
('electrico', 'Electrico'),
|
||||
('electronico', 'Electrónico'),
|
||||
('hidraulico', 'Hidraulico'),
|
||||
@ -43,8 +43,8 @@ class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
|
||||
|
||||
#product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
||||
# ondelete='CASCADE', select=True)
|
||||
product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
||||
ondelete='CASCADE', select=True)
|
||||
equipment = fields.Boolean('It is equipment',
|
||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||
},depends=['type']
|
||||
@ -201,56 +201,53 @@ class Template(metaclass=PoolMeta):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_frequency():
|
||||
def default_frequency(cls):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_moisture_min():
|
||||
def default_moisture_min(cls):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_moisture_max():
|
||||
def default_moisture_max(cls):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_voltageDC():
|
||||
def default_voltageDC(cls):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_voltageAC():
|
||||
def default_voltageAC(cls):
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def default_risk():
|
||||
return 'n/a'
|
||||
|
||||
@staticmethod
|
||||
def default_use():
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def default_biomedical_class():
|
||||
return 'n/a'
|
||||
|
||||
@staticmethod
|
||||
|
||||
def default_main_tecnology():
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
||||
def default_calibration():
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
|
||||
def default_refurbish():
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
|
||||
def default_refurbish():
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
@fields.depends('temperature')
|
||||
def default_temperature_uom():
|
||||
def default_temperature_uom(self):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Celsius'])[0].id
|
||||
@ -258,7 +255,7 @@ class Template(metaclass=PoolMeta):
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
def default_frequency_uom():
|
||||
def default_frequency_uom(cls):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Hertz'])[0].id
|
||||
@ -266,7 +263,7 @@ class Template(metaclass=PoolMeta):
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
def default_moisture_uom():
|
||||
def default_moisture_uom(cls):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Relative Humedity'])[0].id
|
||||
@ -274,7 +271,15 @@ class Template(metaclass=PoolMeta):
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
def default_voltageAC_uom():
|
||||
def default_voltageAC_uom(cls):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
||||
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
def default_voltageDC_uom(cls):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
||||
@ -298,13 +303,21 @@ class Template(metaclass=PoolMeta):
|
||||
self.analog_resolution = None
|
||||
self.a_factor_resolution = None
|
||||
|
||||
|
||||
@fields.depends('equipment', 'replacement')
|
||||
def on_change_equipment(self):
|
||||
if self.equipment:
|
||||
self.replacement=False
|
||||
self.maintenance_activity=False
|
||||
self.calibration=False
|
||||
self.mark_category = None
|
||||
self.model_category = None
|
||||
self.reference_category = None
|
||||
self.equipment_type = None
|
||||
self.risk = 'n/a'
|
||||
self.biomedical_class = 'n/a'
|
||||
self.use = ''
|
||||
self.useful_life = 0
|
||||
self.warranty = 0
|
||||
|
||||
@fields.depends('mark_category', 'model_category', 'reference_category')
|
||||
def on_change_mark_category(self):
|
||||
@ -324,6 +337,52 @@ class Template(metaclass=PoolMeta):
|
||||
self.voltageDC = 0
|
||||
self.frequency = 0
|
||||
|
||||
@classmethod
|
||||
def copy(cls, templates, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default.setdefault('code', None)
|
||||
default.setdefault('images', None)
|
||||
return super().copy(templates, default=default)
|
||||
|
||||
|
||||
class Product(metaclass=PoolMeta):
|
||||
__name__ = 'product.product'
|
||||
|
||||
@classmethod
|
||||
def copy(cls, products, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
|
||||
default.setdefault('suffix_code', None)
|
||||
default.setdefault('code', None)
|
||||
default.setdefault('poduct', None)
|
||||
default.setdefault('images', None)
|
||||
return super().copy(products, default=default)
|
||||
|
||||
|
||||
class Image(metaclass=PoolMeta):
|
||||
__name__ = 'product.image'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
|
||||
@classmethod
|
||||
def copy(cls, images, default=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
else:
|
||||
default = default.copy()
|
||||
default.setdefault('template', None)
|
||||
default.setdefault('product', None)
|
||||
return super().copy(images, default=default)
|
||||
|
||||
|
||||
class Pattern(ModelSQL, ModelView):
|
||||
"Pattern K of equipment"
|
||||
__name__ = 'optical_equipment.product_pattern'
|
||||
|
@ -5,6 +5,7 @@ depends:
|
||||
company
|
||||
party
|
||||
product
|
||||
product_image
|
||||
product_measurements
|
||||
xml:
|
||||
party.xml
|
||||
|
@ -11,36 +11,45 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="maintenance_activity"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
||||
<page string="Features" id="features">
|
||||
<page string="Features" id="features" col="-1">
|
||||
<newline/>
|
||||
<label name="mark_category"/>
|
||||
<field name="mark_category"/>
|
||||
<label name="model_category"/>
|
||||
<field name="model_category"/>
|
||||
<newline/>
|
||||
<label name="reference_category"/>
|
||||
<field name="reference_category"/>
|
||||
<label name="equipment_type"/>
|
||||
<field name="equipment_type"/>
|
||||
<newline/>
|
||||
<label name="calibration"/>
|
||||
<field name="calibration"/>
|
||||
<newline/>
|
||||
<label name="risk"/>
|
||||
<field name="risk"/>
|
||||
<label name="use"/>
|
||||
<field name="use"/>
|
||||
<newline/>
|
||||
<label name="biomedical_class"/>
|
||||
<field name="biomedical_class"/>
|
||||
<label name="origin_country"/>
|
||||
<field name="origin_country"/>
|
||||
<newline/>
|
||||
<label name="main_tecnology"/>
|
||||
<field name="main_tecnology"/>
|
||||
<label name="software_required"/>
|
||||
<field name="software_required"/>
|
||||
<label name="software_version"/>
|
||||
<field name="software_version"/>
|
||||
<newline/>
|
||||
<label name="useful_life"/>
|
||||
<field name="useful_life"/>
|
||||
<field name="useful_life" xexpand="0"/>
|
||||
<label name="useful_life" string="Months"/>
|
||||
<newline/>
|
||||
<label name="warranty"/>
|
||||
<field name="warranty"/>
|
||||
<field name="warranty" xexpand="0"/>
|
||||
<label name="warranty" string="Months"/>
|
||||
<newline/>
|
||||
<label name="observation"/>
|
||||
<field name="observation"/>
|
||||
@ -84,6 +93,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='measurements']/label[@name='length']" position="before">
|
||||
<newline/>
|
||||
<separator id="measurements_equipment" string="Measurements of Equipment" colspan="4"/>
|
||||
</xpath>
|
||||
<xpath
|
||||
|
Loading…
Reference in New Issue
Block a user