40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
from netforce.model import Model, fields, get_model
|
|
from netforce.access import get_active_user
|
|
|
|
class Settings(Model):
|
|
_inherit="settings"
|
|
_fields={
|
|
"cash_account_id": fields.Many2One("account.account","Cash Account"),
|
|
"income_account_id": fields.Many2One("account.account","Income Account"),
|
|
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
|
|
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),
|
|
'acc_prod_match': fields.Boolean("Account Product Matching"),
|
|
}
|
|
|
|
def get_default_address(self,ids,context={}):
|
|
branch_id=None
|
|
user_id=get_active_user()
|
|
if context.get("branch_id"):
|
|
branch_id=context['branch_id']
|
|
else:
|
|
user=get_model("base.user").browse(user_id)
|
|
if user.department_id:
|
|
branch_id=user.department_id.branch_id.id
|
|
elif user.branch_id:
|
|
branch_id=user.branch_id.id
|
|
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
|
|
add=branch.addresses[0]
|
|
print('='*50)
|
|
print(add.company)
|
|
print(add.address)
|
|
print(add.address1)
|
|
print('='*50)
|
|
return vals
|
|
|
|
Settings.register()
|