address
parent
1a712b1203
commit
954dcedd66
|
@ -1,4 +1,5 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_user
|
||||
|
||||
class Settings(Model):
|
||||
_inherit="settings"
|
||||
|
@ -9,4 +10,20 @@ class Settings(Model):
|
|||
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),
|
||||
}
|
||||
|
||||
def get_default_address(self,ids,context={}):
|
||||
branch_id=None
|
||||
if context.get("branch_id"):
|
||||
branch_id=context['branch_id']
|
||||
else:
|
||||
user_id=get_active_user()
|
||||
user=get_model("base.user").browse(user_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
|
||||
return vals
|
||||
|
||||
Settings.register()
|
||||
|
|
|
@ -1000,12 +1000,21 @@ class HDCase(Model):
|
|||
payment=get_model("account.payment").browse(int(payment_id))
|
||||
comp_id=get_active_company()
|
||||
comp=get_model('company').browse(comp_id)
|
||||
st=get_model('settings').browse(1)
|
||||
hdcase=payment.related_id
|
||||
if hdcase:
|
||||
context['branch_id']=hdcase.branch_id.id
|
||||
st=get_model('settings').browse(1,context=context)
|
||||
cst=get_model('clinic.setting').browse(1)
|
||||
addresses=st.addresses
|
||||
comp_addr=''
|
||||
if addresses:
|
||||
comp_addr=addresses[0].address_text
|
||||
if st.default_address_id:
|
||||
comp_addr='\n'.join([
|
||||
st.default_address_id.address or "",
|
||||
st.default_address_id.city or "",
|
||||
st.default_address_id.postal_code or "",
|
||||
st.default_address_id.country_id.name or "",
|
||||
st.default_address_id.phone and "Phone: %s"%st.default_address_id.phone or "",
|
||||
st.default_address_id.fax and "Fax: %s"%st.default_address_id.fax or ""
|
||||
])
|
||||
cust=payment.partner_id
|
||||
cust_name=cust.name or ''
|
||||
cust_addr=''
|
||||
|
@ -1038,16 +1047,11 @@ class HDCase(Model):
|
|||
pay_type=payment.pay_type or ''
|
||||
user_id=get_active_user()
|
||||
user=get_model("base.user").browse(user_id)
|
||||
#XXX remove ,
|
||||
index=0
|
||||
for ca in comp_addr:
|
||||
ca=ca.replace(" ","")
|
||||
if ca==',':
|
||||
break
|
||||
index+=1
|
||||
comp_addr=comp_addr[index+1:]
|
||||
comp_name=comp.name or ""
|
||||
if st.default_address_id.company:
|
||||
comp_name=st.default_address_id.company or ""
|
||||
data={
|
||||
'comp_name': comp.name or '',
|
||||
'comp_name': comp_name,
|
||||
'comp_addr': comp_addr or '',
|
||||
'tax_no': st.tax_no or '',
|
||||
'number': payment.number or '',
|
||||
|
|
|
@ -498,12 +498,19 @@ class Shop(Model):
|
|||
shop=self.browse(shop_id)
|
||||
comp_id=get_active_company()
|
||||
comp=get_model('company').browse(comp_id)
|
||||
st=get_model('settings').browse(1)
|
||||
context['branch_id']=shop.branch_id.id
|
||||
st=get_model('settings').browse(1,context=context)
|
||||
cst=get_model('clinic.setting').browse(1)
|
||||
addresses=st.addresses
|
||||
comp_addr=''
|
||||
if addresses:
|
||||
comp_addr=addresses[0].address_text
|
||||
if st.default_address_id:
|
||||
comp_addr='\n'.join([
|
||||
st.default_address_id.address or "",
|
||||
st.default_address_id.city or "",
|
||||
st.default_address_id.postal_code or "",
|
||||
st.default_address_id.country_id.name or "",
|
||||
st.default_address_id.phone and "Phone: %s"%st.default_address_id.phone or "",
|
||||
st.default_address_id.fax and "Fax: %s"%st.default_address_id.fax or ""
|
||||
])
|
||||
cust=shop.contact_id
|
||||
cust_name=cust.name or ''
|
||||
cust_addr=''
|
||||
|
@ -538,16 +545,11 @@ class Shop(Model):
|
|||
pay_type=shop.pay_type or ''
|
||||
user_id=get_active_user()
|
||||
user=get_model("base.user").browse(user_id)
|
||||
#XXX remove ,
|
||||
index=0
|
||||
for ca in comp_addr:
|
||||
ca=ca.replace(" ","")
|
||||
if ca==',':
|
||||
break
|
||||
index+=1
|
||||
comp_addr=comp_addr[index+1:]
|
||||
comp_name=comp.name or ""
|
||||
if st.default_address_id.company:
|
||||
comp_name=st.default_address_id.company or ""
|
||||
data={
|
||||
'comp_name': comp.name or '',
|
||||
'comp_name': comp_name,
|
||||
'comp_addr': comp_addr or '',
|
||||
'tax_no': st.tax_no or '',
|
||||
'number': shop.number or '',
|
||||
|
|
Loading…
Reference in New Issue