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.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from . import party, product
|
from . import party, product, maintenance
|
||||||
|
|
||||||
__all__ = ['register']
|
__all__ = ['register']
|
||||||
|
|
||||||
@ -12,7 +12,11 @@ def register():
|
|||||||
party.Address,
|
party.Address,
|
||||||
party.Party,
|
party.Party,
|
||||||
product.Template,
|
product.Template,
|
||||||
|
product.Product,
|
||||||
product.Pattern,
|
product.Pattern,
|
||||||
|
product.Image,
|
||||||
|
maintenance.MaintenanceService,
|
||||||
|
maintenance.MaintenanceLine,
|
||||||
module='optical_equipment', type_='model')
|
module='optical_equipment', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
module='optical_equipment', type_='wizard')
|
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'
|
97
product.py
97
product.py
@ -43,8 +43,8 @@ class Template(metaclass=PoolMeta):
|
|||||||
__name__ = 'product.template'
|
__name__ = 'product.template'
|
||||||
|
|
||||||
|
|
||||||
#product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
||||||
# ondelete='CASCADE', select=True)
|
ondelete='CASCADE', select=True)
|
||||||
equipment = fields.Boolean('It is equipment',
|
equipment = fields.Boolean('It is equipment',
|
||||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||||
},depends=['type']
|
},depends=['type']
|
||||||
@ -201,56 +201,53 @@ class Template(metaclass=PoolMeta):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_frequency():
|
def default_frequency(cls):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_moisture_min():
|
def default_moisture_min(cls):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_moisture_max():
|
def default_moisture_max(cls):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_voltageDC():
|
def default_voltageDC(cls):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_voltageAC():
|
def default_voltageAC(cls):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_risk():
|
def default_risk():
|
||||||
return 'n/a'
|
return 'n/a'
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_use():
|
def default_use():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_biomedical_class():
|
def default_biomedical_class():
|
||||||
return 'n/a'
|
return 'n/a'
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_main_tecnology():
|
def default_main_tecnology():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_calibration():
|
def default_calibration():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_refurbish():
|
def default_refurbish():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def default_refurbish():
|
def default_refurbish():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@fields.depends('temperature')
|
@fields.depends('temperature')
|
||||||
def default_temperature_uom():
|
def default_temperature_uom(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Measurements = pool.get('product.uom')
|
Measurements = pool.get('product.uom')
|
||||||
measurement = Measurements.search(['name', '=', 'Celsius'])[0].id
|
measurement = Measurements.search(['name', '=', 'Celsius'])[0].id
|
||||||
@ -258,7 +255,7 @@ class Template(metaclass=PoolMeta):
|
|||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_frequency_uom():
|
def default_frequency_uom(cls):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Measurements = pool.get('product.uom')
|
Measurements = pool.get('product.uom')
|
||||||
measurement = Measurements.search(['name', '=', 'Hertz'])[0].id
|
measurement = Measurements.search(['name', '=', 'Hertz'])[0].id
|
||||||
@ -266,7 +263,7 @@ class Template(metaclass=PoolMeta):
|
|||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_moisture_uom():
|
def default_moisture_uom(cls):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Measurements = pool.get('product.uom')
|
Measurements = pool.get('product.uom')
|
||||||
measurement = Measurements.search(['name', '=', 'Relative Humedity'])[0].id
|
measurement = Measurements.search(['name', '=', 'Relative Humedity'])[0].id
|
||||||
@ -274,7 +271,15 @@ class Template(metaclass=PoolMeta):
|
|||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
@classmethod
|
@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()
|
pool = Pool()
|
||||||
Measurements = pool.get('product.uom')
|
Measurements = pool.get('product.uom')
|
||||||
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
||||||
@ -298,13 +303,21 @@ class Template(metaclass=PoolMeta):
|
|||||||
self.analog_resolution = None
|
self.analog_resolution = None
|
||||||
self.a_factor_resolution = None
|
self.a_factor_resolution = None
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('equipment', 'replacement')
|
@fields.depends('equipment', 'replacement')
|
||||||
def on_change_equipment(self):
|
def on_change_equipment(self):
|
||||||
if self.equipment:
|
if self.equipment:
|
||||||
self.replacement=False
|
self.replacement=False
|
||||||
self.maintenance_activity=False
|
self.maintenance_activity=False
|
||||||
self.calibration=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')
|
@fields.depends('mark_category', 'model_category', 'reference_category')
|
||||||
def on_change_mark_category(self):
|
def on_change_mark_category(self):
|
||||||
@ -324,6 +337,52 @@ class Template(metaclass=PoolMeta):
|
|||||||
self.voltageDC = 0
|
self.voltageDC = 0
|
||||||
self.frequency = 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):
|
class Pattern(ModelSQL, ModelView):
|
||||||
"Pattern K of equipment"
|
"Pattern K of equipment"
|
||||||
__name__ = 'optical_equipment.product_pattern'
|
__name__ = 'optical_equipment.product_pattern'
|
||||||
|
@ -5,6 +5,7 @@ depends:
|
|||||||
company
|
company
|
||||||
party
|
party
|
||||||
product
|
product
|
||||||
|
product_image
|
||||||
product_measurements
|
product_measurements
|
||||||
xml:
|
xml:
|
||||||
party.xml
|
party.xml
|
||||||
|
@ -11,36 +11,45 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="maintenance_activity"/>
|
<field name="maintenance_activity"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
<xpath expr="/form/notebook/page[@id='general']" position="after">
|
||||||
<page string="Features" id="features">
|
<page string="Features" id="features" col="-1">
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="mark_category"/>
|
<label name="mark_category"/>
|
||||||
<field name="mark_category"/>
|
<field name="mark_category"/>
|
||||||
<label name="model_category"/>
|
<label name="model_category"/>
|
||||||
<field name="model_category"/>
|
<field name="model_category"/>
|
||||||
|
<newline/>
|
||||||
<label name="reference_category"/>
|
<label name="reference_category"/>
|
||||||
<field name="reference_category"/>
|
<field name="reference_category"/>
|
||||||
<label name="equipment_type"/>
|
<label name="equipment_type"/>
|
||||||
<field name="equipment_type"/>
|
<field name="equipment_type"/>
|
||||||
|
<newline/>
|
||||||
<label name="calibration"/>
|
<label name="calibration"/>
|
||||||
<field name="calibration"/>
|
<field name="calibration"/>
|
||||||
|
<newline/>
|
||||||
<label name="risk"/>
|
<label name="risk"/>
|
||||||
<field name="risk"/>
|
<field name="risk"/>
|
||||||
<label name="use"/>
|
<label name="use"/>
|
||||||
<field name="use"/>
|
<field name="use"/>
|
||||||
|
<newline/>
|
||||||
<label name="biomedical_class"/>
|
<label name="biomedical_class"/>
|
||||||
<field name="biomedical_class"/>
|
<field name="biomedical_class"/>
|
||||||
<label name="origin_country"/>
|
<label name="origin_country"/>
|
||||||
<field name="origin_country"/>
|
<field name="origin_country"/>
|
||||||
|
<newline/>
|
||||||
<label name="main_tecnology"/>
|
<label name="main_tecnology"/>
|
||||||
<field name="main_tecnology"/>
|
<field name="main_tecnology"/>
|
||||||
<label name="software_required"/>
|
<label name="software_required"/>
|
||||||
<field name="software_required"/>
|
<field name="software_required"/>
|
||||||
<label name="software_version"/>
|
<label name="software_version"/>
|
||||||
<field name="software_version"/>
|
<field name="software_version"/>
|
||||||
|
<newline/>
|
||||||
<label name="useful_life"/>
|
<label name="useful_life"/>
|
||||||
<field name="useful_life"/>
|
<field name="useful_life" xexpand="0"/>
|
||||||
|
<label name="useful_life" string="Months"/>
|
||||||
|
<newline/>
|
||||||
<label name="warranty"/>
|
<label name="warranty"/>
|
||||||
<field name="warranty"/>
|
<field name="warranty" xexpand="0"/>
|
||||||
|
<label name="warranty" string="Months"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="observation"/>
|
<label name="observation"/>
|
||||||
<field name="observation"/>
|
<field name="observation"/>
|
||||||
@ -84,6 +93,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/notebook/page[@id='measurements']/label[@name='length']" position="before">
|
<xpath expr="/form/notebook/page[@id='measurements']/label[@name='length']" position="before">
|
||||||
|
<newline/>
|
||||||
<separator id="measurements_equipment" string="Measurements of Equipment" colspan="4"/>
|
<separator id="measurements_equipment" string="Measurements of Equipment" colspan="4"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
|
Loading…
Reference in New Issue
Block a user