changes to equipments
This commit is contained in:
parent
33f3cdc5ef
commit
7bf05f4857
21
equipment.py
21
equipment.py
@ -8,6 +8,7 @@ from trytond.pyson import Eval, If
|
|||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.model.exceptions import AccessError
|
||||||
|
|
||||||
|
|
||||||
_MAINTENANCE_FREQUENCY = [("none", ''),
|
_MAINTENANCE_FREQUENCY = [("none", ''),
|
||||||
@ -97,15 +98,16 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
|||||||
maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency",
|
maintenance_frequency = fields.Selection(_MAINTENANCE_FREQUENCY, "Maintenance Frequency",
|
||||||
depends=['propietary'])
|
depends=['propietary'])
|
||||||
|
|
||||||
purchase_origin = fields.Reference("Purchase Origin", selection='get_origin', select=True)
|
purchase_origin = fields.Reference("Purchase Origin", selection='get_origin',select=True,
|
||||||
|
states=_states)
|
||||||
|
|
||||||
del _states_serial
|
del _states
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_origin(cls):
|
def _get_origin(cls):
|
||||||
'Return list of Model names for origin Reference'
|
'Return list of Model names for origin Reference'
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Purchase = pool.get('purchase.purchase')
|
Purchase = pool.get('purchase.line')
|
||||||
|
|
||||||
return [Purchase.__name__]
|
return [Purchase.__name__]
|
||||||
|
|
||||||
@ -236,6 +238,19 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
|
|||||||
# def draft(cls, equipments):
|
# def draft(cls, equipments):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def delete(cls, equipments):
|
||||||
|
for equipment in equipments:
|
||||||
|
if equipment.purchase_origin:
|
||||||
|
raise AccessError(
|
||||||
|
gettext('estos equipos no se pueden borrar'))
|
||||||
|
elif equipment.state != 'draft' and equipment.serial != None:
|
||||||
|
raise AccessError(
|
||||||
|
gettext('estos equipos no se pueden borrar'))
|
||||||
|
super(OpticalEquipment, cls).delete(equipments)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@Workflow.transition('registred')
|
@Workflow.transition('registred')
|
||||||
|
@ -63,6 +63,7 @@ class Purchase(metaclass=PoolMeta):
|
|||||||
health_register=line.health_register,
|
health_register=line.health_register,
|
||||||
software_version=line.product.software_version,
|
software_version=line.product.software_version,
|
||||||
maintenance_frequency="none",
|
maintenance_frequency="none",
|
||||||
|
purchase_origin=line,
|
||||||
)
|
)
|
||||||
equipment.save()
|
equipment.save()
|
||||||
else:
|
else:
|
||||||
|
@ -3,14 +3,9 @@
|
|||||||
this repository contains the full copyright notices and license terms.-->
|
this repository contains the full copyright notices and license terms.-->
|
||||||
<tree editable="1">
|
<tree editable="1">
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="state"/>
|
<field name="purchase_origin"/>
|
||||||
<field name="company"/>
|
|
||||||
<field name="location"/>
|
|
||||||
<field name="propietary"/>
|
<field name="propietary"/>
|
||||||
<field name="propietary_address"/>
|
|
||||||
<field name="product"/>
|
<field name="product"/>
|
||||||
<field name="equipment_type"/>
|
|
||||||
<field name="serial" expand="1"/>
|
<field name="serial" expand="1"/>
|
||||||
<button name="registred"/>
|
<button name="registred"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user