correction to bugs and add complete behaviors
This commit is contained in:
parent
8e173c4758
commit
209a2083b3
@ -1,6 +1,6 @@
|
||||
from trytond.pool import Pool
|
||||
from . import (address, diary, party, product, purchase, sale,
|
||||
equipment, configuration_equipment, maintenance, subscription)
|
||||
equipment, configuration_equipment, maintenance, subscription, exceptions)
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
|
114
equipment.py
114
equipment.py
@ -4,6 +4,8 @@ from trytond.model import (
|
||||
Workflow, ModelSQL, ModelView, Unique, fields)
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.i18n import gettext
|
||||
#from .exceptions import NotSequenceEquipment
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
||||
@ -22,43 +24,60 @@ class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
||||
required=True, readonly=True, sort=False)
|
||||
|
||||
company = fields.Many2One('company.company', "Company", readonly=True)
|
||||
location = fields.Many2One('stock.location', "Location")
|
||||
propietary = fields.Many2One('party.party', "Propietary")
|
||||
location = fields.Many2One('stock.location', "Location",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
propietary = fields.Many2One('party.party', "Propietary",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
propietary_address = fields.Many2One('party.address', "Propietary Address", required=True,
|
||||
domain=[('party', '=', Eval('propietary'))]
|
||||
domain=[('party', '=', Eval('propietary'))],
|
||||
states={'readonly': Eval('state') != 'draft',}
|
||||
)
|
||||
product = fields.Many2One('product.product', "Product",
|
||||
domain=[('equipment', '=', True)],
|
||||
states={'readonly': Eval('state') != 'draft',},
|
||||
depends=['equipment']
|
||||
)
|
||||
refurbish = fields.Boolean("Refurbish", readonly=True)
|
||||
refurbish = fields.Boolean("Refurbish",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
equipment_type = fields.Char('type', readonly=True)
|
||||
risk = fields.Char('Type risk')
|
||||
use = fields.Char('Use')
|
||||
biomedical_class = fields.Char('Biomedical Class')
|
||||
main_tecnology = fields.Char('Main tecnology')
|
||||
risk = fields.Char('Type risk',readonly=True)
|
||||
use = fields.Char('Use', readonly=True)
|
||||
biomedical_class = fields.Char('Biomedical Class', readonly=True)
|
||||
main_tecnology = fields.Char('Main tecnology', readonly=True)
|
||||
calibration = fields.Boolean("Apply calibration", readonly=True)
|
||||
mark_category = fields.Many2One('product.category', 'Mark', required=True,
|
||||
domain=[('parent', '=', None),
|
||||
('accounting', '=', False)],
|
||||
states={'readonly': Eval('state') != 'draft',}
|
||||
)
|
||||
model_category = fields.Many2One('product.category', "Model", required=True,
|
||||
domain=[('parent', '=', Eval('mark_category')),
|
||||
('accounting', '=', False)],)
|
||||
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.Integer("Useful life")
|
||||
warranty = fields.Integer("Warranty")
|
||||
serial = fields.Char("Serial", size=None)
|
||||
health_register = fields.Char("Health Register", size=None)
|
||||
('accounting', '=', False)],
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
reference_category = fields.Many2One('product.category', "Reference",
|
||||
domain=[('parent', '=', Eval('model_category'))],
|
||||
states={'readonly': Eval('state') != 'draft',},
|
||||
depends=['model_category']
|
||||
)
|
||||
origin_country = fields.Many2One('country.country',"Origin Country",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
software_version = fields.Char("Software version", size=None,
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
useful_life = fields.Integer("Useful life",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
warranty = fields.Integer("Warranty",
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
serial = fields.Char("Serial", size=None,
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
health_register = fields.Char("Health Register", size=None,
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
|
||||
subscription_history = fields.Many2Many('sale.subscription-optical_equipment.equipment',
|
||||
'equipment','subscription', "Subscriptions",
|
||||
states={'readonly': True})
|
||||
|
||||
current_subscription = fields.Many2One('sale.subscription')
|
||||
software_version = fields.Char("Software version", size=None)
|
||||
states={'readonly': True}
|
||||
)
|
||||
software_version = fields.Char("Software version", size=None,
|
||||
states={'readonly': Eval('state') != 'draft',},)
|
||||
|
||||
|
||||
@classmethod
|
||||
@ -67,7 +86,9 @@ class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints = [
|
||||
('serial_unique', Unique(t, t.serial),
|
||||
'optical_equipment.msg_serial_unique')
|
||||
'optical_equipment.msg_serial_unique'),
|
||||
('code_unique', Unique(t, t.code),
|
||||
'optical_equipment.msg_code_unique')
|
||||
]
|
||||
cls._transitions = ({
|
||||
('draft', 'registred'),
|
||||
@ -86,13 +107,16 @@ class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
||||
Config = pool.get('optical_equipment.configuration')
|
||||
config = Config(1)
|
||||
for equipment in equipments:
|
||||
if not equipment.code:
|
||||
if config.equipment_sequence != None and not equipment.code:
|
||||
#if not equipment.code:
|
||||
try:
|
||||
equipment.code = config.equipment_sequence.get()
|
||||
equipment.state = 'registred'
|
||||
cls.save(equipments) #Revisar
|
||||
except UserError:
|
||||
raise UserError(str('Validation Error'))
|
||||
else:
|
||||
raise UserError(gettext('optical_equipment.msg_not_sequence_equipment'))
|
||||
|
||||
@classmethod
|
||||
def default_state(cls):
|
||||
@ -107,20 +131,40 @@ class OpticalEquipment(Workflow, ModelSQL, ModelView):
|
||||
'mark_category', 'model_category')
|
||||
def on_change_product(self):
|
||||
if self.product:
|
||||
self.equipment_type = self.product.equipment_type
|
||||
self.use = self.product.use
|
||||
self.biomedical_class = self.product.biomedical_class
|
||||
self.calibration = self.product.calibration
|
||||
self.mark_category = self.product.mark_category
|
||||
self.model_category = self.product.model_category
|
||||
self.equipment_type=self.product.equipment_type
|
||||
self.use=self.product.use
|
||||
self.biomedical_class=self.product.biomedical_class
|
||||
self.calibration=self.product.calibration
|
||||
self.mark_category=self.product.mark_category
|
||||
self.model_category=self.product.model_category
|
||||
self.reference_category=self.product.reference_category
|
||||
self.useful_life=self.product.useful_life if self.product.useful_life else int(0)
|
||||
self.calibration=True if self.product.calibration else False
|
||||
self.warranty=self.product.warranty if self.product.warranty else int(0)
|
||||
self.risk=self.product.risk
|
||||
self.origin_country=self.product.origin_country
|
||||
self.use=self.product.use
|
||||
self.biomedical_class=self.product.biomedical_class
|
||||
else:
|
||||
self.equipment_type = None
|
||||
self.use = None
|
||||
self.biomedical_class = None
|
||||
self.calibration = None
|
||||
self.mark_category = None
|
||||
self.model_category = None
|
||||
|
||||
self.equipment_type=None
|
||||
self.use=None
|
||||
self.biomedical_class=None
|
||||
self.calibration=None
|
||||
self.mark_category=None
|
||||
self.model_category=None
|
||||
self.reference_category=None
|
||||
self.useful_life=None
|
||||
self.calibration=False
|
||||
self.warranty=None
|
||||
self.risk=None
|
||||
self.origin_country=None
|
||||
self.use=None
|
||||
self.biomedical_class=None
|
||||
self.refurbish=None
|
||||
self.serial=None
|
||||
self.health_register=None
|
||||
self.software_version=None
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
|
@ -2,6 +2,10 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.model.exceptions import ValidationError
|
||||
|
||||
class InvalidNumberPurchases(UserError):
|
||||
pass
|
||||
|
||||
class NotSequenceEquipment(ValidationError):
|
||||
pass
|
||||
|
@ -11,5 +11,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_serial_unique">
|
||||
<field name="text">The serial number of equipment, should be unique.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_not_sequence_equipment">
|
||||
<field name="text">You do not have a sequence assigned for equipments</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
12
purchase.py
12
purchase.py
@ -43,16 +43,18 @@ class Purchase(metaclass=PoolMeta):
|
||||
product=line.product,
|
||||
model_category=line.product.model_category,
|
||||
mark_category=line.product.mark_category,
|
||||
useful_life=line.product.useful_life,
|
||||
calibration=line.product.calibration,
|
||||
warranty=line.product.warranty,
|
||||
reference_category=line.product.reference_category,
|
||||
useful_life=line.product.useful_life if line.product.useful_life else 0,
|
||||
calibration=True if line.product.calibration else False,
|
||||
warranty=line.product.warranty if line.product.warranty else 0,
|
||||
risk=line.product.risk,
|
||||
origin_country=line.product.origin_country,
|
||||
use=line.product.use,
|
||||
biomedical_class=line.product.biomedical_class,
|
||||
refurbish=line.refurbish,
|
||||
serial=line.serial_equipment,
|
||||
software_version=line.product.software_version)
|
||||
health_register=line.health_register,
|
||||
software_version=line.software_version)
|
||||
equipment.save()
|
||||
else:
|
||||
continue
|
||||
@ -72,6 +74,8 @@ class Line(metaclass=PoolMeta):
|
||||
refurbish = fields.Boolean("Refurbish")
|
||||
product_equipment = fields.Boolean("Product Equipment",
|
||||
states={'readonly': True})
|
||||
software_version = fields.Char("Software version")
|
||||
health_register = fields.Char("Registro Medico")
|
||||
|
||||
@classmethod
|
||||
def default_address_equipment(cls):
|
||||
|
8
sale.py
8
sale.py
@ -6,6 +6,7 @@ from decimal import Decimal
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
#from collections import setdefault
|
||||
|
||||
from trytond.wizard import (
|
||||
Button, StateAction, StateTransition, StateView, Wizard)
|
||||
@ -51,9 +52,12 @@ class CreateSubscription(Wizard):
|
||||
])
|
||||
create_subscription = StateAction('sale_subscription.act_subscription_form')
|
||||
|
||||
done_ = StateView('sale.create.subscription.start',
|
||||
'optical_equipment.create_subscription_view_form',[
|
||||
Button('Done', 'end', 'tryton-cancel'),
|
||||
])
|
||||
@property
|
||||
def _subscription_start(self):
|
||||
subscription_lines = []
|
||||
return dict(start_date=self.start.start_date,
|
||||
end_date=self.start.end_date,
|
||||
invoice_recurrence=self.start.invoice_recurrence,
|
||||
@ -105,7 +109,7 @@ class CreateSubscription(Wizard):
|
||||
)
|
||||
subscription.save()
|
||||
|
||||
|
||||
return 'done_'
|
||||
|
||||
class SaleLine(metaclass=PoolMeta):
|
||||
'SaleLine'
|
||||
|
@ -27,6 +27,8 @@
|
||||
<field name="mark_category"/>
|
||||
<label name="model_category"/>
|
||||
<field name="model_category"/>
|
||||
<label name="reference_category"/>
|
||||
<field name="reference_category"/>
|
||||
<label name="refurbish"/>
|
||||
<field name="refurbish"/>
|
||||
<label name="software_version"/>
|
||||
@ -41,8 +43,6 @@
|
||||
<field name="health_register"/>
|
||||
<label name="origin_country"/>
|
||||
<field name="origin_country"/>
|
||||
<label name="current_subscription"/>
|
||||
<field name="current_subscription"/>
|
||||
<notebook>
|
||||
<page string="Subscriptions" id="subscriptions_equipment">
|
||||
<field name="subscription_history"/>
|
||||
|
@ -10,6 +10,12 @@
|
||||
<label name="serial_equipment"/>
|
||||
<field name="serial_equipment"/>
|
||||
<newline/>
|
||||
<label name="software_version"/>
|
||||
<field name="software_version"/>
|
||||
<newline/>
|
||||
<label name="health_register"/>
|
||||
<field name="health_register"/>
|
||||
<newline/>
|
||||
<label name="refurbish"/>
|
||||
<field name="refurbish"/>
|
||||
</page>
|
||||
|
Loading…
Reference in New Issue
Block a user