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