changes to equipments

This commit is contained in:
sinergia 2022-08-10 23:16:03 -05:00
parent 33f3cdc5ef
commit 7bf05f4857
3 changed files with 20 additions and 9 deletions

View File

@ -8,6 +8,7 @@ from trytond.pyson import Eval, If
from trytond.transaction import Transaction
from trytond.i18n import gettext
from trytond.exceptions import UserError
from trytond.model.exceptions import AccessError
_MAINTENANCE_FREQUENCY = [("none", ''),
@ -97,15 +98,16 @@ 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',select=True,
states=_states)
del _states_serial
del _states
@classmethod
def _get_origin(cls):
'Return list of Model names for origin Reference'
pool = Pool()
Purchase = pool.get('purchase.purchase')
Purchase = pool.get('purchase.line')
return [Purchase.__name__]
@ -236,6 +238,19 @@ class OpticalEquipment(DeactivableMixin, Workflow, ModelSQL, ModelView):
# def draft(cls, equipments):
# 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
@ModelView.button
@Workflow.transition('registred')

View File

@ -63,6 +63,7 @@ class Purchase(metaclass=PoolMeta):
health_register=line.health_register,
software_version=line.product.software_version,
maintenance_frequency="none",
purchase_origin=line,
)
equipment.save()
else:

View File

@ -3,14 +3,9 @@
this repository contains the full copyright notices and license terms.-->
<tree editable="1">
<field name="code"/>
<field name="state"/>
<field name="company"/>
<field name="location"/>
<field name="purchase_origin"/>
<field name="propietary"/>
<field name="propietary_address"/>
<field name="product"/>
<field name="equipment_type"/>
<field name="serial" expand="1"/>
<button name="registred"/>
</tree>