clinic/netforce_clinic/models/fin_setting.py

40 lines
1.5 KiB
Python
Raw Normal View History

2015-03-18 03:51:38 +00:00
from netforce.model import Model, fields, get_model
from netforce.access import get_active_user
2014-10-22 03:45:23 +00:00
class Settings(Model):
_inherit="settings"
_fields={
2014-12-21 10:11:22 +00:00
"cash_account_id": fields.Many2One("account.account","Cash Account"),
"income_account_id": fields.Many2One("account.account","Income Account"),
2014-10-26 10:11:19 +00:00
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
2014-10-27 14:17:22 +00:00
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),
2015-08-08 15:34:21 +00:00
'acc_prod_match': fields.Boolean("Account Product Matching"),
2014-10-22 03:45:23 +00:00
}
2015-03-18 03:51:38 +00:00
def get_default_address(self,ids,context={}):
branch_id=None
2015-03-25 08:23:52 +00:00
user_id=get_active_user()
2015-03-18 03:51:38 +00:00
if context.get("branch_id"):
branch_id=context['branch_id']
else:
user=get_model("base.user").browse(user_id)
2015-03-25 10:26:18 +00:00
if user.department_id:
branch_id=user.department_id.branch_id.id
elif user.branch_id:
branch_id=user.branch_id.id
2015-03-18 03:51:38 +00:00
vals={}
for obj in self.browse(ids):
vals[obj.id]=obj.addresses and obj.addresses[0].id or None
if branch_id:
branch=get_model("clinic.branch").browse(branch_id)
vals[obj.id]=branch.addresses and branch.addresses[0].id or None
2015-03-25 08:23:52 +00:00
add=branch.addresses[0]
print('='*50)
print(add.company)
print(add.address)
print(add.address1)
print('='*50)
2015-03-18 03:51:38 +00:00
return vals
2014-10-22 03:45:23 +00:00
Settings.register()