fix: se limpia código para migración 6.8
This commit is contained in:
parent
224c2d65e9
commit
b981dcd670
@ -1,30 +1,31 @@
|
||||
# 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,fields, sequence_ordered)
|
||||
Workflow, ModelSQL, ModelView, fields, sequence_ordered)
|
||||
from trytond.pyson import Bool, Eval, If, Id, Equal
|
||||
from trytond.pool import Pool
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
_digits = (16, 2)
|
||||
_digits = (16, 2)
|
||||
_states = {'readonly': If(Eval('state') != 'draft', True)}
|
||||
|
||||
|
||||
class Calibration(ModelSQL, ModelView):
|
||||
'Calibration of Maintenance'
|
||||
__name__ = 'optical_equipment.maintenance.calibration'
|
||||
|
||||
_states={'readonly': True}
|
||||
|
||||
_states = {'readonly': True}
|
||||
|
||||
maintenance = fields.Many2One('optical_equipment.maintenance', "Maintenance", ondelete="CASCADE",
|
||||
select=True, required=True)
|
||||
required=True)
|
||||
graph_dates = fields.Char("Graph Dates", readonly=True)
|
||||
diopter = fields.Float("Diopter", states=_states)
|
||||
mean = fields.Float("Mean", states=_states)
|
||||
dev_std = fields.Float("Standart Desviation", states=_states)
|
||||
uncertain_type_A = fields.Float("Uncertain Type A", states=_states)
|
||||
uncertain_pattern = fields.Float("Uncertain Pattern", states=_states)
|
||||
k_c_calibration = fields.Float("K Crt Calibration",states=_states)
|
||||
k_c_calibration = fields.Float("K Crt Calibration", states=_states)
|
||||
uncertain_U_b1 = fields.Float("U_b1", states=_states)
|
||||
d_resolution = fields.Float("d_resolution", states=_states)
|
||||
uncertain_U_b2_dig = fields.Float("U_b2", states=_states)
|
||||
@ -32,25 +33,26 @@ class Calibration(ModelSQL, ModelView):
|
||||
uncertain_combinated = fields.Float("U_combinated", states=_states)
|
||||
uncertain_eff = fields.Float("U eff", states=_states)
|
||||
t_student = fields.Float("T Student", states=_states)
|
||||
|
||||
uncertain_expanded = fields.Float("Uexpand", _digits, states=_states)
|
||||
|
||||
uncertain_expanded = fields.Float("Uexpand", _digits, states=_states)
|
||||
|
||||
state = fields.Char('State')
|
||||
|
||||
|
||||
|
||||
class CalibrationSample(sequence_ordered(), ModelView, ModelSQL):
|
||||
'Samples of Calibration'
|
||||
__name__ = 'optical_equipment.maintenance.calibration_sample'
|
||||
|
||||
|
||||
maintenance = fields.Many2One('optical_equipment.maintenance', 'Maintenance')
|
||||
product = fields.Function(fields.Integer("Product ID"), 'on_change_with_product')
|
||||
number_sample = fields.Float("Sample #", _digits)
|
||||
number_sample = fields.Float("Sample #", _digits)
|
||||
value_patterns = fields.Many2One('optical_equipment.product_pattern', "Value Pattern", ondelete='RESTRICT', required=True,
|
||||
domain=[('product', '=', Eval('product'))],
|
||||
depends=['product'])
|
||||
value_equipment = fields.Float("Value in Equipment", _digits, required=True,
|
||||
states={'readonly': Eval('value_patterns') == None})
|
||||
mistake = fields.Float("Mistake", _digits)
|
||||
mistake_rate = fields.Float("% Mistake", _digits,
|
||||
value_equipment = fields.Float("Value in Equipment", _digits, required=True,
|
||||
states={'readonly': Eval('value_patterns') is None})
|
||||
mistake = fields.Float("Mistake", _digits)
|
||||
mistake_rate = fields.Float("% Mistake", _digits,
|
||||
states={'readonly': True},
|
||||
depends=['mistake'])
|
||||
|
||||
@ -58,7 +60,7 @@ class CalibrationSample(sequence_ordered(), ModelView, ModelSQL):
|
||||
def on_change_with_product(self, name=None):
|
||||
if self.maintenance:
|
||||
return self.maintenance.equipment.product.template.id
|
||||
|
||||
|
||||
@fields.depends('value_patterns', 'value_equipment',
|
||||
'mistake', 'mistake_rate')
|
||||
def on_change_value_equipment(self):
|
||||
@ -75,7 +77,7 @@ class CalibrationSample(sequence_ordered(), ModelView, ModelSQL):
|
||||
else:
|
||||
self.mistake_rate = abs(self.mistake / self.value_patterns.pattern) * 100
|
||||
|
||||
|
||||
|
||||
class CalibrationReport(CompanyReport):
|
||||
__name__ = 'optical_equipment.maintenance'
|
||||
|
||||
|
139
contract.py
139
contract.py
@ -15,6 +15,7 @@ from trytond.modules.product import price_digits
|
||||
import datetime
|
||||
from datetime import timedelta, date
|
||||
|
||||
|
||||
class Cron(metaclass=PoolMeta):
|
||||
__name__ = 'ir.cron'
|
||||
|
||||
@ -25,34 +26,33 @@ class Cron(metaclass=PoolMeta):
|
||||
('optical_equipment.contract|contract_expiration', 'Contract Expiration'),
|
||||
)
|
||||
|
||||
|
||||
|
||||
class Contract(Workflow, ModelSQL, ModelView):
|
||||
'Contracts'
|
||||
__name__ = 'optical_equipment.contract'
|
||||
_rec_name = 'number'
|
||||
_order_name = 'number'
|
||||
|
||||
|
||||
company = fields.Many2One(
|
||||
'company.company', "Company", required=True, select=True,
|
||||
'company.company', "Company", required=True,
|
||||
states={
|
||||
'readonly': (Eval('state') != 'draft') | Eval('party', True),
|
||||
},help="Make the subscription belong to the company.")
|
||||
}, help="Make the subscription belong to the company.")
|
||||
number = fields.Char(
|
||||
"Number", readonly=True, select=True,
|
||||
"Number", readonly=True,
|
||||
help="The main identification of the subscription.")
|
||||
reference = fields.Char(
|
||||
"Reference", select=True,
|
||||
"Reference",
|
||||
help="The identification of an external origin.")
|
||||
description = fields.Char("Description",
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
party = fields.Many2One(
|
||||
'party.party', "Party", required=True,
|
||||
states={
|
||||
'readonly': (Eval('state') != 'draft') | Eval('party', True),
|
||||
},help="The party who subscribes.")
|
||||
}, help="The party who subscribes.")
|
||||
equipment = fields.Many2One('optical_equipment.equipment', "Equipment")
|
||||
contact = fields.Many2One('party.contact_mechanism', "Contact", required=True)
|
||||
invoice_address = fields.Many2One('party.address', 'Invoice Address',
|
||||
@ -73,26 +73,24 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
|
||||
|
||||
maintenance_services = fields.Many2Many('optical_equipment_maintenance.service-equipment.contract',
|
||||
'contract', 'maintenance_services', "Prorogues",
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
|
||||
current_equipments = fields.Many2Many('optical_equipment.contract-optical_equipment.equipment',
|
||||
'contract', 'equipment', "Current Equipments",
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
history_equipments = fields.One2Many('optical_equipment.equipment', 'contract', "Equipments",
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
price_contract = Monetary("Price Contract", digits=price_digits, currency='currency', required=True,
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
states={'readonly': Eval('state') != 'draft'})
|
||||
state = fields.Selection([
|
||||
('draft', "Draft"),
|
||||
('running', "Running"),
|
||||
('closed', "Closed"),
|
||||
('cancelled', "Cancelled"),
|
||||
], "State", readonly=True, required=False, sort=False,
|
||||
help="The current state of the subscription.")
|
||||
|
||||
('draft', "Draft"),
|
||||
('running', "Running"),
|
||||
('closed', "Closed"),
|
||||
('cancelled', "Cancelled"),
|
||||
], "State", readonly=True, required=False, sort=False,
|
||||
help="The current state of the subscription.")
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
@ -100,7 +98,7 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
cls._order = [
|
||||
('number', 'DESC NULLS FIRST'),
|
||||
('id', 'DESC'),
|
||||
]
|
||||
]
|
||||
cls._transitions = ({
|
||||
('draft', 'running'),
|
||||
('running', 'draft'),
|
||||
@ -109,13 +107,12 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
('cancelled', 'draft')
|
||||
})
|
||||
cls._buttons.update({
|
||||
'draft': {'invisible': Eval('state').in_(['draft','closed'])},
|
||||
'draft': {'invisible': Eval('state').in_(['draft', 'closed'])},
|
||||
'running': {'invisible': Eval('state').in_(['cancelled', 'running'])},
|
||||
'closed': {'invisible': Eval('state').in_(['draft','cancelled'])},
|
||||
'closed': {'invisible': Eval('state').in_(['draft', 'cancelled'])},
|
||||
'cancelled': {'invisible': Eval('state').in_(['draft', 'cancelled'])}
|
||||
})
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
@ -129,8 +126,8 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
pool = Pool()
|
||||
Config = pool.get('optical_equipment.configuration')
|
||||
config = Config(4)
|
||||
|
||||
if config.contract_sequence != None:
|
||||
|
||||
if config.contract_sequence is not None:
|
||||
if not contracts[0].number:
|
||||
try:
|
||||
contracts[0].number = config.contract_sequence.get()
|
||||
@ -151,7 +148,7 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
if contracts_to_expire != []:
|
||||
for contract in contracts_to_expire:
|
||||
cls.closed([contract])
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
@ -172,7 +169,6 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
equipment.state = "uncontrated"
|
||||
equipment.save()
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('running')
|
||||
@ -184,7 +180,7 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
equipment.save()
|
||||
|
||||
cls.set_number(contracts)
|
||||
contract.state='running'
|
||||
contract.state = 'running'
|
||||
contract.save()
|
||||
|
||||
@classmethod
|
||||
@ -196,23 +192,24 @@ class Contract(Workflow, ModelSQL, ModelView):
|
||||
equipment.state = "uncontrated"
|
||||
equipment.save()
|
||||
|
||||
|
||||
|
||||
class ContractMaintenanceServices(ModelSQL):
|
||||
'Contract - Maintenance Services'
|
||||
__name__ = 'optical_equipment_maintenance.service-equipment.contract'
|
||||
|
||||
maintenance_services = fields.Many2One('optical_equipment_maintenance.service', "Maintenance Service", select=True)
|
||||
maintenance_services = fields.Many2One(
|
||||
'optical_equipment_maintenance.service', "Maintenance Service", )
|
||||
contract = fields.Many2One('optical_equipment.contract', "Contract")
|
||||
|
||||
|
||||
|
||||
class ContractEquipment(ModelSQL):
|
||||
'Optical Equipment - Contract'
|
||||
__name__ = 'optical_equipment.contract-optical_equipment.equipment'
|
||||
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', select=True)
|
||||
contract = fields.Many2One('optical_equipment.contract', 'Contract', select=True)
|
||||
|
||||
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', )
|
||||
contract = fields.Many2One('optical_equipment.contract', 'Contract', )
|
||||
|
||||
|
||||
class ContractReport(CompanyReport):
|
||||
__name__ = 'optical_equipment.contract'
|
||||
|
||||
@ -230,30 +227,30 @@ class ContractReport(CompanyReport):
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
||||
class CreateContractInitial(ModelView, ModelSQL):
|
||||
'Create Contract Inicial'
|
||||
__name__ = 'optical_equipment_create.contract'
|
||||
|
||||
currency = fields.Many2One('currency.currency', 'Currency', required=True)
|
||||
company = fields.Many2One(
|
||||
'company.company', "Company", readonly=True, required=True, select=True,
|
||||
'company.company', "Company", readonly=True, required=True,
|
||||
states={
|
||||
'readonly': (Eval('state') != 'draft') | Eval('party', True),
|
||||
},help="Make the subscription belong to the company.")
|
||||
}, help="Make the subscription belong to the company.")
|
||||
party = fields.Many2One(
|
||||
'party.party', "Party", required=True,
|
||||
help="The party who subscribes.")
|
||||
invoice_address = fields.Many2One('party.address', 'Invoice Address',
|
||||
required=True, domain=[('party', '=', Eval('party'))])
|
||||
payment_term = fields.Many2One('account.invoice.payment_term',
|
||||
'Payment Term')
|
||||
'Payment Term')
|
||||
contact = fields.Many2One(
|
||||
'party.contact_mechanism', "Contact", required=True,
|
||||
domain=[('party', '=', Eval('party'))],
|
||||
context={
|
||||
'company': Eval('company', -1),
|
||||
})
|
||||
})
|
||||
start_date = fields.Date("Start Date", required=True)
|
||||
end_date = fields.Date("End Date",
|
||||
domain=['OR',
|
||||
@ -264,7 +261,7 @@ class CreateContractInitial(ModelView, ModelSQL):
|
||||
('end_date', '=', None),
|
||||
])
|
||||
unit_price = Monetary("Unit Price", digits=price_digits, currency='currency', required=True)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
@ -275,37 +272,35 @@ class CreateContractInitial(ModelView, ModelSQL):
|
||||
if Transaction().context.get('company'):
|
||||
company = Company(Transaction().context['company'])
|
||||
return company.currency.id
|
||||
|
||||
|
||||
@classmethod
|
||||
def default_start_date(cls):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
return Date.today()
|
||||
|
||||
|
||||
@fields.depends('party')
|
||||
def on_change_party(self):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
if self.party:
|
||||
self.invoice_address = self.party.address_get(type='invoice')
|
||||
if self.party.customer_type == "ips":
|
||||
self.end_date = Date.today() + timedelta(days=182)
|
||||
if self.party.customer_type == "ips":
|
||||
self.end_date = Date.today() + timedelta(days=182)
|
||||
else:
|
||||
self.end_date = Date.today() + timedelta(days=365)
|
||||
self.end_date = Date.today() + timedelta(days=365)
|
||||
|
||||
|
||||
|
||||
class CreateContract(Wizard):
|
||||
__name__ = 'optical_equipment.maintenance.contract'
|
||||
|
||||
start = StateView('optical_equipment_create.contract',
|
||||
'optical_equipment.create_contract_view_form',[
|
||||
'optical_equipment.create_contract_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'create_contract', 'tryton-ok', default=True),
|
||||
])
|
||||
create_contract = StateAction('optical_equipment.act_contract_form')
|
||||
|
||||
|
||||
def default_start(self, fields):
|
||||
if self.record:
|
||||
default = {'party': self.record.propietary.id,
|
||||
@ -315,7 +310,7 @@ class CreateContract(Wizard):
|
||||
else self.record.sale_origin.total_amount),
|
||||
}
|
||||
return default
|
||||
|
||||
|
||||
@property
|
||||
def _subscription_start(self):
|
||||
return dict(
|
||||
@ -326,7 +321,7 @@ class CreateContract(Wizard):
|
||||
invoice_address=self.start.invoice_address,
|
||||
unit_price=self.start.unit_price
|
||||
)
|
||||
|
||||
|
||||
def do_create_contract(self, action):
|
||||
maintenance_service = self.records[0]
|
||||
pool = Pool()
|
||||
@ -340,26 +335,26 @@ class CreateContract(Wizard):
|
||||
equipments.append(line.equipment.id)
|
||||
|
||||
if maintenance_service.contract_origin:
|
||||
contract=maintenance_service.contract_origin
|
||||
contract.history_equipments+=tuple(equipments)
|
||||
contract.current_equipments=equipments
|
||||
contract.invoice_address=dates['invoice_address']
|
||||
contract.contact=dates['contact']
|
||||
contract.start_date=dates['start_date']
|
||||
contract.end_date=dates['end_date']
|
||||
contract.maintenance_services+=prorogues
|
||||
contract.state='draft'
|
||||
contract.price_contract=dates['unit_price']
|
||||
contract = maintenance_service.contract_origin
|
||||
contract.history_equipments += tuple(equipments)
|
||||
contract.current_equipments = equipments
|
||||
contract.invoice_address = dates['invoice_address']
|
||||
contract.contact = dates['contact']
|
||||
contract.start_date = dates['start_date']
|
||||
contract.end_date = dates['end_date']
|
||||
contract.maintenance_services += prorogues
|
||||
contract.state = 'draft'
|
||||
contract.price_contract = dates['unit_price']
|
||||
else:
|
||||
contract = Contract(party=dates['party'],
|
||||
invoice_address=dates['invoice_address'],
|
||||
contact=dates['contact'],
|
||||
start_date=dates['start_date'],
|
||||
end_date=dates['end_date'],
|
||||
maintenance_services=prorogues,
|
||||
current_equipments=equipments,
|
||||
state='draft',
|
||||
price_contract=dates['unit_price']
|
||||
)
|
||||
invoice_address=dates['invoice_address'],
|
||||
contact=dates['contact'],
|
||||
start_date=dates['start_date'],
|
||||
end_date=dates['end_date'],
|
||||
maintenance_services=prorogues,
|
||||
current_equipments=equipments,
|
||||
state='draft',
|
||||
price_contract=dates['unit_price']
|
||||
)
|
||||
|
||||
contract.save()
|
||||
|
2
diary.py
2
diary.py
@ -7,7 +7,7 @@ class Diary(ModelSQL, ModelView):
|
||||
__name__ = 'optical_equipment_maintenance.diary'
|
||||
_rec_name = 'code'
|
||||
|
||||
code = fields.Char("Code", select=True, states={'readonly': True})
|
||||
code = fields.Char("Code", states={'readonly': True})
|
||||
date_expected = fields.DateTime("Expected Date", required=True)
|
||||
date_estimated = fields.DateTime("Estimated Date")
|
||||
date_end = fields.DateTime("Date End")
|
||||
|
20
equipment.py
20
equipment.py
@ -37,7 +37,7 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
||||
}
|
||||
|
||||
code = fields.Char(
|
||||
"Code", select=True, states={'readonly': True})
|
||||
"Code", states={'readonly': True})
|
||||
|
||||
state = fields.Selection([('draft', "Draft"),
|
||||
('registred', "Registred"),
|
||||
@ -119,11 +119,11 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
||||
|
||||
maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency",
|
||||
depends=['propietary'])
|
||||
purchase_origin = fields.Reference("Purchase Origin", selection='get_origin', select=True,
|
||||
purchase_origin = fields.Reference("Purchase Origin", selection='get_origin',
|
||||
states={'readonly': True})
|
||||
sale_destination = fields.Reference("Sale Destination", selection='get_destination', select=True,
|
||||
sale_destination = fields.Reference("Sale Destination", selection='get_destination',
|
||||
states={'readonly': True})
|
||||
shipment_destination = fields.Reference("Stock Move", selection='get_shipment', select=True,
|
||||
shipment_destination = fields.Reference("Stock Move", selection='get_shipment',
|
||||
states={'readonly': True})
|
||||
rec_name = fields.Function(fields.Char("rec_name"), 'get_rec_name')
|
||||
|
||||
@ -354,24 +354,24 @@ class EquipmentMaintenance(ModelSQL, ModelView):
|
||||
'Optical Equipment - Equipment - Maintenance'
|
||||
__name__ = 'optical_equipment.maintenance-optical_equipment.equipment'
|
||||
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', select=True)
|
||||
maintenance = fields.Many2One('optical_equipment.maintenance', 'Maintenances', select=True)
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', )
|
||||
maintenance = fields.Many2One('optical_equipment.maintenance', 'Maintenances', )
|
||||
|
||||
|
||||
class EquipmentContract(ModelSQL, ModelView):
|
||||
'Optical Equipment - Contracs Equipment'
|
||||
__name__ = 'optical_equipment.contract-optical_equipment.equipment'
|
||||
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', select=True)
|
||||
contract = fields.Many2One('optical_equipment.contract', 'Contract', select=True)
|
||||
equipment = fields.Many2One('optical_equipment.equipment', 'Equipment', )
|
||||
contract = fields.Many2One('optical_equipment.contract', 'Contract', )
|
||||
|
||||
|
||||
class EquipmentParty(ModelSQL, ModelView):
|
||||
'Optical Equipment - Party'
|
||||
__name__ = 'optical_equipment.equipment-party.party'
|
||||
|
||||
equipment = fields.Many2One('optical_equipment.equipment', "Equipment", select=True)
|
||||
party = fields.Many2One('party.party', "Party", select=True)
|
||||
equipment = fields.Many2One('optical_equipment.equipment', "Equipment", )
|
||||
party = fields.Many2One('party.party', "Party", )
|
||||
|
||||
|
||||
class ChangePropietary(ModelView):
|
||||
|
@ -14,7 +14,7 @@ from trytond.modules.product import price_digits
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from scipy.stats import t
|
||||
# from scipy.stats import t
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import math as mt
|
||||
@ -33,16 +33,16 @@ class MaintenanceService(Workflow, ModelSQL, ModelView):
|
||||
|
||||
_states = {'readonly': If(Eval('state') != 'draft', True)}
|
||||
|
||||
code = fields.Char("Code", readonly=True, select=True)
|
||||
reference = fields.Char("Reference", select=True,
|
||||
code = fields.Char("Code", readonly=True, )
|
||||
reference = fields.Char("Reference",
|
||||
help="The identification of an external origin.")
|
||||
description = fields.Char("Description", states=_states)
|
||||
sale_date = fields.Char("Sale Date")
|
||||
contract_origin = fields.Reference(
|
||||
"Contract Base", selection='get_origin_contract', select=True,
|
||||
"Contract Base", selection='get_origin_contract',
|
||||
states={'readonly': If(Eval('state') == 'finished', True)})
|
||||
sale_origin = fields.Reference(
|
||||
"Sale Origin", selection='get_origin', select=True,
|
||||
"Sale Origin", selection='get_origin',
|
||||
states={'readonly': True})
|
||||
company = fields.Many2One('company.company', "Company", readonly=True)
|
||||
maintenance_type = fields.Selection([('initial', 'Initial'),
|
||||
@ -285,12 +285,12 @@ class MaintenanceServiceLine(Workflow, ModelSQL, ModelView):
|
||||
'readonly': Eval('state').in_(['finished'])}
|
||||
|
||||
service_maintenance = fields.Many2One('optical_equipment_maintenance.service', "Maintenance Service",
|
||||
ondelete='CASCADE', select=True,
|
||||
ondelete='CASCADE',
|
||||
domain=[('state', 'in', ['draft', 'in_progress', 'finished']),
|
||||
('propietary', '=', Eval('propietary'))],
|
||||
states=_states)
|
||||
code = fields.Char(
|
||||
"Code", select=True, states={'readonly': True})
|
||||
"Code", states={'readonly': True})
|
||||
maintenance_type = fields.Selection([('initial', 'Initial'),
|
||||
('preventive', 'Preventive'),
|
||||
('corrective', 'Corrective')], "Maintenance Type", states=_states)
|
||||
@ -782,7 +782,7 @@ class MaintenanceLine(ModelSQL, ModelView):
|
||||
'optical_equipment.maintenance',
|
||||
'Maintenance',
|
||||
ondelete='CASCADE',
|
||||
select=True)
|
||||
)
|
||||
replacement = fields.Many2One('product.product', 'Replacement', ondelete='RESTRICT',
|
||||
domain=[('replacement', '=', True)],
|
||||
states={'invisible': (If(Eval('line_maintenance_activity') == True, True)) | (If(Eval('line_replace') == False, True)),
|
||||
|
180
product.py
180
product.py
@ -1,6 +1,6 @@
|
||||
#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.pool import Pool, PoolMeta
|
||||
# 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.pool import Pool, PoolMeta
|
||||
from trytond.model import (
|
||||
ModelView, ModelSQL, fields, Exclude)
|
||||
from trytond.pyson import Bool, If, Eval, Id
|
||||
@ -17,13 +17,13 @@ _USE = [('', ""),
|
||||
('apoyo', 'Apoyo')]
|
||||
|
||||
_BIOMEDICAL_CLASS = [
|
||||
('n/a', "No aplíca"),
|
||||
('n/a', "No aplíca"),
|
||||
('diagnostico', 'Diagnóstico'),
|
||||
('rehabilitación', 'Rehabilitación')]
|
||||
|
||||
_MAIN_TECNOLOGY = [
|
||||
('', ""),
|
||||
('mecanico', 'Mecánico'),
|
||||
('mecanico', 'Mecánico'),
|
||||
('electrico', 'Electrico'),
|
||||
('electronico', 'Electrónico'),
|
||||
('hidraulico', 'Hidraulico'),
|
||||
@ -38,38 +38,39 @@ _EQUIPMENT_TYPE = [
|
||||
|
||||
NON_MEASURABLE = ['service']
|
||||
|
||||
|
||||
class Template(metaclass=PoolMeta):
|
||||
'Template'
|
||||
__name__ = 'product.template'
|
||||
|
||||
|
||||
product = fields.Many2One('optical_equipment.maintenance', "Maintenance Activity",
|
||||
ondelete='CASCADE', select=True)
|
||||
ondelete='CASCADE', )
|
||||
equipment = fields.Boolean('It is equipment',
|
||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||
})
|
||||
maintenance_activity = fields.Boolean('Maintenance Activity',
|
||||
states={'invisible': Eval('type', 'service') != 'service',
|
||||
'readonly': If(Eval('equipment',True), True)
|
||||
| If(Eval('replacement',True), True)
|
||||
})
|
||||
states={'invisible': Eval('type', 'service') != 'service',
|
||||
'readonly': If(Eval('equipment', True), True)
|
||||
| If(Eval('replacement', True), True)
|
||||
})
|
||||
replacement = fields.Boolean('Replacement',
|
||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||
'readonly': If(Eval('equipment',True), True)
|
||||
| If(Eval('maintenance_activity',True), True)
|
||||
})
|
||||
states={'invisible': Eval('type', 'goods') != 'goods',
|
||||
'readonly': If(Eval('equipment', True), True)
|
||||
| If(Eval('maintenance_activity', True), True)
|
||||
})
|
||||
|
||||
maintenance_required = fields.Boolean('Miantenance Required',
|
||||
states={'invisible': (Eval('type', 'goods') != 'goods')})
|
||||
states={'invisible': (Eval('type', 'goods') != 'goods')})
|
||||
equipment_type = fields.Selection(_EQUIPMENT_TYPE, 'Equipment type',
|
||||
states={'required': Eval('equipment', False)})
|
||||
risk = fields.Selection(_RISK, 'Type risk')
|
||||
use = fields.Selection(_USE, 'Use',
|
||||
states={'required': Eval('equipment', False)},
|
||||
depends={'equipment'})
|
||||
biomedical_class = fields.Selection(_BIOMEDICAL_CLASS,'Biomedical Class',
|
||||
use = fields.Selection(_USE, 'Use',
|
||||
states={'required': Eval('equipment', False)},
|
||||
depends={'equipment'})
|
||||
biomedical_class = fields.Selection(_BIOMEDICAL_CLASS, 'Biomedical Class',
|
||||
states={'required': Eval('equipment', False)})
|
||||
main_tecnology = fields.Selection(_MAIN_TECNOLOGY,'Main tecnology',
|
||||
states={'required': Eval('equipment', False)})
|
||||
main_tecnology = fields.Selection(_MAIN_TECNOLOGY, 'Main tecnology',
|
||||
states={'required': Eval('equipment', False)})
|
||||
calibration = fields.Boolean("Apply calibration")
|
||||
observation = fields.Text('Observation')
|
||||
|
||||
@ -78,91 +79,103 @@ class Template(metaclass=PoolMeta):
|
||||
domain=[('parent', '=', None),
|
||||
('accounting', '=', False)],
|
||||
states={'required': Eval('equipment', False)})
|
||||
model_category = fields.Many2One('product.category', "Model",
|
||||
domain=[('parent', '=', Eval('mark_category')),
|
||||
('accounting', '=', False)],
|
||||
states={'required': Eval('equipment', False)})
|
||||
model_category = fields.Many2One('product.category', "Model",
|
||||
domain=[('parent', '=', Eval('mark_category')),
|
||||
('accounting', '=', False)],
|
||||
states={'required': Eval('equipment', False)})
|
||||
reference_category = fields.Many2One('product.category', "Reference",
|
||||
domain=[('parent', '=', Eval('model_category'))],)
|
||||
|
||||
|
||||
# Iformation Equipment
|
||||
origin_country = fields.Many2One('country.country',"Origin Country")
|
||||
origin_country = fields.Many2One('country.country', "Origin Country")
|
||||
refurbish = fields.Boolean('Refurbish')
|
||||
software_required = fields.Boolean("Software Required")
|
||||
software_version = fields.Char("Software version",
|
||||
states={'invisible': If(~Eval('software_required'), True)},
|
||||
depends={'software_required'})
|
||||
|
||||
#These are measurements required for the equipments, are in this place
|
||||
# These are measurements required for the equipments, are in this place
|
||||
# for manage of class 'product.template'
|
||||
|
||||
temperature_min = fields.Float("Temp Min")
|
||||
temperature_max = fields.Float("Temp Max")
|
||||
temperature_uom = fields.Many2One('product.uom', 'Temperature UOM',
|
||||
domain=[('category', '=', Id('optical_equipment', "uom_cat_temperature"))],
|
||||
states={'invisible' : If(Eval('temperature_min') == None, True)})
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', "uom_cat_temperature"))],
|
||||
states={'invisible': If(Eval('temperature_min') is None, True)})
|
||||
frequency = fields.Float("Frequency")
|
||||
frequency_uom = fields.Many2One('product.uom', "Frequency UOM",
|
||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_frequency'))],
|
||||
states={'invisible' : If(Eval('frequency') == None, True)}
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', 'uom_cat_frequency'))],
|
||||
states={'invisible': If(Eval('frequency') is None, True)}
|
||||
)
|
||||
moisture_min = fields.Float("Moisture Min")
|
||||
moisture_max = fields.Float("Moisture Max")
|
||||
moisture_uom = fields.Many2One('product.uom', "Moisture UOM",
|
||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_relative_humedity'))],
|
||||
states={'invisible' : If(Eval('moisture_min') == None, True)},
|
||||
)
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', 'uom_cat_relative_humedity'))],
|
||||
states={'invisible': If(Eval('moisture_min') is None, True)},
|
||||
)
|
||||
electrical_equipment = fields.Boolean("Electrical Equipment")
|
||||
frequency = fields.Float("Frequency",
|
||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||
frequency_uom = fields.Many2One('product.uom', "Frequency UOM",
|
||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_frequency'))],
|
||||
states={'invisible' : If(Eval('frequency') == None, True) |
|
||||
~Eval('electrical_equipment', True)},
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', 'uom_cat_frequency'))],
|
||||
states={'invisible': If(Eval('frequency') is None, True) |
|
||||
~Eval('electrical_equipment', True)},
|
||||
)
|
||||
voltageAC = fields.Float("Voltage AC",
|
||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||
voltageAC_uom = fields.Many2One('product.uom', "Voltage AC UOM",
|
||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
||||
states={'invisible' : If(Eval('voltageAC') == None, True) |
|
||||
~Eval('electrical_equipment', True)},
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', 'uom_cat_electrical_tension'))],
|
||||
states={'invisible': If(Eval('voltageAC') is None, True) |
|
||||
~Eval('electrical_equipment', True)},
|
||||
)
|
||||
voltageDC = fields.Float("Voltage DC",
|
||||
states={'invisible': ~Bool(Eval('electrical_equipment'))})
|
||||
voltageDC_uom = fields.Many2One('product.uom', "Voltage DC UOM",
|
||||
domain=[('category', '=', Id('optical_equipment', 'uom_cat_electrical_tension'))],
|
||||
states={'invisible' : If(Eval('voltageDC') == None, True) |
|
||||
~Eval('electrical_equipment', True)},)
|
||||
|
||||
domain=[
|
||||
('category', '=', Id(
|
||||
'optical_equipment', 'uom_cat_electrical_tension'))],
|
||||
states={'invisible': If(Eval('voltageDC') is None, True) |
|
||||
~Eval('electrical_equipment', True)},)
|
||||
|
||||
useful_life = fields.Integer("Useful life")
|
||||
warranty = fields.Integer("Warranty")
|
||||
|
||||
#### calibration parameters
|
||||
# calibration parameters
|
||||
use_pattern = fields.Many2One('optical_equipment.use_pattern', "Use Pattern", ondelete='RESTRICT',
|
||||
states={'required': Eval('calibration', True)})
|
||||
states={'required': Eval('calibration', True)})
|
||||
measuring_range = fields.Selection([
|
||||
('dioptria', "Dioptria"),
|
||||
('mmhg', "mmHg")], "Rango de Medición")
|
||||
MEP = fields.Float("MEP", states={'required': Eval('calibration', False)},)
|
||||
uncertainy_pattern = fields.Float("Uncertainy Pattern", states={'required': Eval('calibration', True)},
|
||||
help="Agregar valores separados por ',' Ej:-5,+5,-10,+10")
|
||||
k_pattern = fields.Char("K Pattern",states={'required': Eval('calibration', False)},
|
||||
uncertainy_pattern = fields.Float("Uncertainy Pattern", states={'required': Eval('calibration', True)},
|
||||
help="Agregar valores separados por ',' Ej:-5,+5,-10,+10")
|
||||
k_pattern = fields.Char("K Pattern", states={'required': Eval('calibration', False)},
|
||||
help="Agregar valores separados por ',' Ej:-5,+5,-10,+10")
|
||||
k_pattern_list = fields.One2Many('optical_equipment.product_pattern', 'product', "List of patterns K",
|
||||
states={'required': Eval('calibration', False)},)
|
||||
resolution_type = fields.Selection([('',""),
|
||||
('analoga', "Analoga"),
|
||||
('digital', "Digital")], "Resolution Type",
|
||||
states={'required': Eval('calibration', False)},)
|
||||
resolution_type = fields.Selection([('', ""),
|
||||
('analoga', "Analoga"),
|
||||
('digital', "Digital")], "Resolution Type",
|
||||
states={'required': Eval('calibration', False)},)
|
||||
d_resolution = fields.Float("Resolution d",
|
||||
states={'invisible': If(Eval('resolution_type') != 'digital', True)},)
|
||||
analog_resolution = fields.Float("Analog resolution",
|
||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True),},)
|
||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True), },)
|
||||
a_factor_resolution = fields.Float("(a) Resolution",
|
||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},)
|
||||
Usubi = fields.Integer("Usub i",states={'required': Eval('calibration', False)},)
|
||||
states={'invisible': If(Eval('resolution_type') != 'analoga', True)},)
|
||||
Usubi = fields.Integer("Usub i", states={'required': Eval('calibration', False)},)
|
||||
|
||||
#maintenance activities
|
||||
# maintenance activities
|
||||
initial_operation = fields.Boolean("Verificación inicial de funcionamiento")
|
||||
check_equipment = fields.Boolean("Revisión del Equipo")
|
||||
check_electric_system = fields.Boolean("Revisión del sistema electríco")
|
||||
@ -170,18 +183,18 @@ class Template(metaclass=PoolMeta):
|
||||
clean_eyes = fields.Boolean("Limpieza de lentes y espejos")
|
||||
optical = fields.Boolean("Optical")
|
||||
check_calibration = fields.Boolean("Verificar Calibración")
|
||||
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return super(Template, cls).view_attributes() + [
|
||||
('//page[@id="features"]', 'states', {
|
||||
'invisible': ~Eval('equipment'),}),
|
||||
'invisible': ~Eval('equipment'), }),
|
||||
('//page[@id="calibration"]', 'states', {
|
||||
'invisible': ~Eval('calibration')},),
|
||||
'invisible': ~Eval('calibration')},),
|
||||
('//page[@id="maintenance_activities"]', 'states', {
|
||||
'invisible': ~Eval('maintenance_required')},)
|
||||
'invisible': ~Eval('maintenance_required')},)
|
||||
|
||||
]
|
||||
]
|
||||
|
||||
@classmethod
|
||||
@fields.depends('measuring_range')
|
||||
@ -215,7 +228,7 @@ class Template(metaclass=PoolMeta):
|
||||
return 0
|
||||
|
||||
@classmethod
|
||||
def default_voltageAC(cls):
|
||||
def default_voltageAC(cls):
|
||||
return 0
|
||||
|
||||
def default_risk():
|
||||
@ -227,19 +240,15 @@ class Template(metaclass=PoolMeta):
|
||||
def default_biomedical_class():
|
||||
return 'n/a'
|
||||
|
||||
|
||||
def default_main_tecnology():
|
||||
return None
|
||||
|
||||
|
||||
def default_calibration():
|
||||
return False
|
||||
|
||||
|
||||
def default_refurbish():
|
||||
return False
|
||||
|
||||
|
||||
def default_refurbish():
|
||||
return False
|
||||
|
||||
@ -257,7 +266,7 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Hertz'])[0].id
|
||||
|
||||
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
@ -265,7 +274,7 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Relative Humedity'])[0].id
|
||||
|
||||
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
@ -273,7 +282,7 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
||||
|
||||
|
||||
return measurement
|
||||
|
||||
@classmethod
|
||||
@ -281,7 +290,7 @@ class Template(metaclass=PoolMeta):
|
||||
pool = Pool()
|
||||
Measurements = pool.get('product.uom')
|
||||
measurement = Measurements.search(['name', '=', 'Volt'])[0].id
|
||||
|
||||
|
||||
return measurement
|
||||
|
||||
@fields.depends('voltageDC', 'voltageDC_uom')
|
||||
@ -294,19 +303,19 @@ class Template(metaclass=PoolMeta):
|
||||
@fields.depends('software_required', 'software_version')
|
||||
def on_change_with_sotfware_required(self):
|
||||
self.software_version = None
|
||||
|
||||
|
||||
@fields.depends('d_resolution', 'analog_resolution', 'a_factor_resolution')
|
||||
def on_change_resolution_type(self):
|
||||
self.d_resolution = None
|
||||
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.replacement = False
|
||||
self.maintenance_activity = False
|
||||
self.calibration = False
|
||||
self.mark_category = None
|
||||
self.model_category = None
|
||||
self.reference_category = None
|
||||
@ -316,7 +325,7 @@ class Template(metaclass=PoolMeta):
|
||||
self.use = ''
|
||||
self.useful_life = 0
|
||||
self.warranty = 0
|
||||
|
||||
|
||||
@fields.depends('mark_category', 'model_category', 'reference_category')
|
||||
def on_change_mark_category(self):
|
||||
if not self.mark_category:
|
||||
@ -362,14 +371,14 @@ class Product(metaclass=PoolMeta):
|
||||
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:
|
||||
@ -381,17 +390,18 @@ class Image(metaclass=PoolMeta):
|
||||
return super().copy(images, default=default)
|
||||
|
||||
|
||||
class UsePattern(ModelSQL,ModelView):
|
||||
class UsePattern(ModelSQL, ModelView):
|
||||
"Use Pattern"
|
||||
__name__ = 'optical_equipment.use_pattern'
|
||||
_rec_name = 'name_pattern'
|
||||
|
||||
|
||||
name_pattern = fields.Char('Name Pattern', required=True)
|
||||
|
||||
|
||||
|
||||
class Pattern(ModelSQL, ModelView):
|
||||
"Pattern K of equipment"
|
||||
__name__ = 'optical_equipment.product_pattern'
|
||||
_rec_name = 'pattern'
|
||||
|
||||
|
||||
product = fields.Many2One('product.template', "Template", ondelete='CASCADE')
|
||||
pattern = fields.Float("Value Pattern")
|
||||
|
Loading…
Reference in New Issue
Block a user