clinic/netforce_clinic/models/setting.py

67 lines
2.2 KiB
Python
Raw Normal View History

2014-09-11 03:21:52 +00:00
from netforce.model import Model, fields, get_model
2014-11-25 14:20:30 +00:00
from netforce.utils import get_file_path, get_data_path
2014-11-21 16:11:57 +00:00
from netforce.access import get_active_company
2014-09-11 03:21:52 +00:00
class ClinicSetting(Model):
_name="clinic.setting"
_string="Setting"
_fields={
2014-10-26 08:48:51 +00:00
"var_k": fields.Float("K"),
2014-10-27 14:17:22 +00:00
'file': fields.File("File"),
2014-11-21 02:39:26 +00:00
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
2014-11-26 11:22:17 +00:00
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
2014-11-27 15:14:31 +00:00
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
2014-11-21 16:11:57 +00:00
'cost_per_case': fields.Float("Cost Per Case"),
'company_id': fields.Many2One("company", 'Company'),
2014-11-27 15:14:31 +00:00
'period_id': fields.Many2One("clinic.period","Period"),
2014-11-30 05:54:57 +00:00
'waiting_approval': fields.Boolean("Waiting Approval"),
2014-12-02 08:51:21 +00:00
'real_time': fields.Boolean("Real Time"),
2014-09-11 03:21:52 +00:00
}
2014-10-27 19:01:18 +00:00
2014-11-21 16:11:57 +00:00
_defaults={
"company_id": lambda *a: get_active_company(),
}
2014-11-25 14:20:30 +00:00
def onchange_line(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
var_a=line['var_a'] or ''
var_b=line['var_b'] or ''
op=line['op'] or ''
line['formular']='%sX%s%s'%(var_a,op,var_b)
return data
2014-09-11 03:21:52 +00:00
2014-11-26 11:22:17 +00:00
def onchange_product(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
product_id=line['product_id']
if product_id:
prod=get_model("product").browse(product_id)
uom=prod.uom_id
if not uom:
uom=get_model("uom").browse(1)
if not uom:
raise Exception("Not found uom 'Unit'")
line['uom_id']=uom.id
line['description']=prod.name
2014-11-27 15:14:31 +00:00
price=prod.sale_price or 0.0
line['price']=price
2014-12-02 07:08:20 +00:00
qty=1
2014-11-27 15:14:31 +00:00
amt=qty*price
2014-11-26 11:22:17 +00:00
line['amount']=amt
return data
2014-11-27 15:14:31 +00:00
def onchange_setting_line(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
qty=line['qty'] or 0
price=line['price'] or 0
amt=qty*price
line['amount']=amt
return data
2014-09-11 03:21:52 +00:00
ClinicSetting.register()