59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
from collections import defaultdict
|
|
from trytond.pool import Pool
|
|
from trytond.model import ModelSQL, ModelView, fields
|
|
from trytond.exceptions import UserError
|
|
|
|
class OpticalEquipment(ModelSQL, ModelView):
|
|
'Optical Equipment'
|
|
__name__ = "optical_equipment.equipment"
|
|
|
|
company = fields.Many2One('company.company', "Company")
|
|
location = fields.Many2One('stock.location', "Location")
|
|
party = fields.Many2One('party.party', "Party")
|
|
party_address = fields.Many2One('party.address', "Party Address")
|
|
#origin = fields.reference("Origin", selection='get_origin', select=True)
|
|
product = fields.Many2One('product.product', "Product")
|
|
refurbish = fields.Boolean("Refurbish")
|
|
equipment_type = fields.Char('type')
|
|
risk = fields.Char('Type risk')
|
|
use = fields.Char('Use')
|
|
biomedical_class = fields.Char('Biomedical Class')
|
|
main_tecnology = fields.Char('Main tecnology')
|
|
calibration = fields.Boolean("Apply calibration")
|
|
mark_category = fields.Many2One('product.category', 'Mark')
|
|
model_category = fields.Many2One('product.category', "Model")
|
|
reference = fields.Char("Reference", size=None)
|
|
origin_country = fields.Many2One('country.country',"Origin Country")
|
|
software_version = fields.Char("Software version", size=None)
|
|
useful_life = fields.Char("Useful life", size=None)
|
|
warranty = fields.Char("Warranty", size=None)
|
|
serial = fields.Char("Serial", size=None)
|
|
health_register = fields.Char("Health Register", size=None)
|
|
|
|
subscription_history = fields.Many2Many('sale.subscription-optical_equipment.equipment', 'equipment', 'subscription', "Subscriptions")
|
|
|
|
@staticmethod
|
|
def get_origin():
|
|
return None
|
|
|
|
@classmethod
|
|
def get_subscription_history(cls, records, names):
|
|
pool = Pool()
|
|
ids = []
|
|
for record in records:
|
|
ids.append(record.id)
|
|
|
|
Subscriptions = pool.get('sale.subscription-optical_equipment.equipment')
|
|
subscriptions = Subscriptions.search([("equipment", 'in', ids)])
|
|
subscriptions_history_id = []
|
|
DICC = {}
|
|
|
|
for subscription in subscriptions:
|
|
DICC[subscription.equipment.id] = subscription.id
|
|
|
|
#raise UserError(str(type(subscriptions_history_id[0])))
|
|
#raise UserError(str(list(subscriptions_history_id[0])))
|
|
#raise UserError(str(type(subscriptions_history_id)))
|
|
|
|
return DICC
|