clinic/netforce_clinic/models/cycle_item_copy.py

39 lines
1.1 KiB
Python

from netforce.model import Model, fields, get_model
class CycleItemCopy(Model):
_name="clinic.cycle.item.copy"
_transient=True
_fields={
"cycle_item_id": fields.Many2One("clinic.cycle.item","Cycle Item",required=True,on_delete="cascade"),
'choice': fields.Selection([['item','Cycle Item'],['schd','Schedule']],'Choice'),
"item_copy_id": fields.Many2One("clinic.cycle.item","Cycle Item"),
"schd_copy_id": fields.Many2One("clinic.schedule","Schedule"),
'lines': fields.One2Many("clinic.cycle.item.copy.line","item_copy_id","Lines"),
}
def _get_cycle_item_id(self,context={}):
refer_id=context.get("refer_id")
if not refer_id:
return None
return int(refer_id)
_defaults={
'cycle_item_id': _get_cycle_item_id,
'choice': 'item',
}
def onchange_choice(self,context={}):
data=context['data']
return data
def onchange_item(self,context={}):
data=context['data']
return data
def onchange_schd(self,context={}):
data=context['data']
return data
CycleItemCopy.register()