conv_bal
watcha.h@almacom.co.th 2015-03-25 15:23:52 +07:00
parent 0404d848d6
commit 24e9811f9d
5 changed files with 32 additions and 25 deletions

View File

@ -12,18 +12,25 @@ class Settings(Model):
def get_default_address(self,ids,context={}): def get_default_address(self,ids,context={}):
branch_id=None branch_id=None
user_id=get_active_user()
if context.get("branch_id"): if context.get("branch_id"):
branch_id=context['branch_id'] branch_id=context['branch_id']
else: else:
user_id=get_active_user()
user=get_model("base.user").browse(user_id) user=get_model("base.user").browse(user_id)
branch_id=user.branch_id.id branch_id=user.branch_id.id
print("branch_id ", branch_id, 'user_id ', user_id)
vals={} vals={}
for obj in self.browse(ids): for obj in self.browse(ids):
vals[obj.id]=obj.addresses and obj.addresses[0].id or None vals[obj.id]=obj.addresses and obj.addresses[0].id or None
if branch_id: if branch_id:
branch=get_model("clinic.branch").browse(branch_id) branch=get_model("clinic.branch").browse(branch_id)
vals[obj.id]=branch.addresses and branch.addresses[0].id or None 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 return vals
Settings.register() Settings.register()

View File

@ -1065,16 +1065,6 @@ class HDCase(Model):
context['branch_id']=hdcase.branch_id.id context['branch_id']=hdcase.branch_id.id
st=get_model('settings').browse(1,context=context) st=get_model('settings').browse(1,context=context)
cst=get_model('clinic.setting').browse(1) cst=get_model('clinic.setting').browse(1)
comp_addr=''
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=payment.partner_id
cust_name=cust.name or '' cust_name=cust.name or ''
cust_addr='' cust_addr=''
@ -1112,9 +1102,17 @@ class HDCase(Model):
comp_name=comp.name or "" comp_name=comp.name or ""
if st.default_address_id.company: if st.default_address_id.company:
comp_name=st.default_address_id.company or "" comp_name=st.default_address_id.company or ""
add=st.default_address_id
data={ data={
'comp_name': comp_name, 'comp_name': comp_name,
'comp_addr': comp_addr or '', 'add_address': add.address or '',
'add_address2': add.address2 or '',
'add_province_name': add.province_id.name or '',
'add_district_name': add.district_id.name or '',
'add_city': add.city or '',
'add_postal_code': add.postal_code or '',
'add_phone': add.phone or '',
'add_fax': add.fax or '',
'tax_no': st.tax_no or '', 'tax_no': st.tax_no or '',
'number': payment.number or '', 'number': payment.number or '',
'ref': payment.ref, 'ref': payment.ref,

View File

@ -168,11 +168,14 @@ class SelectCompany(Model):
department_name='' department_name=''
if obj.branch: if obj.branch:
for branch in get_model("clinic.branch").search_browse([["name","=",obj.branch]]): for branch in get_model("clinic.branch").search_browse([["name","=",obj.branch]]):
user=get_model("base.user").browse(user_id)
user.write({ user.write({
'branch_id': branch.id, 'branch_id': branch.id,
}) })
elif obj.department: else:
user.write({
'branch_id': None,
})
if obj.department:
department_name=obj.department department_name=obj.department
# set to main profile of that user # set to main profile of that user
for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]): for dpt in get_model("clinic.department").search_browse([["name","=",obj.department]]):

View File

@ -501,16 +501,6 @@ class Shop(Model):
context['branch_id']=shop.branch_id.id context['branch_id']=shop.branch_id.id
st=get_model('settings').browse(1,context=context) st=get_model('settings').browse(1,context=context)
cst=get_model('clinic.setting').browse(1) cst=get_model('clinic.setting').browse(1)
comp_addr=''
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=shop.contact_id
cust_name=cust.name or '' cust_name=cust.name or ''
cust_addr='' cust_addr=''
@ -558,9 +548,18 @@ class Shop(Model):
for inv in shop.invoices: for inv in shop.invoices:
number=inv.number or "" number=inv.number or ""
ref=shop.number or "" ref=shop.number or ""
add=st.default_address_id
data={ data={
'comp_name': comp_name, 'comp_name': comp_name,
'comp_addr': comp_addr or '', 'add_address': add.address or '',
'add_address2': add.address2 or '',
'add_province_name': add.province_id.name or '',
'add_district_name': add.district_id.name or '',
'add_city': add.city or '',
'add_postal_code': add.postal_code or '',
'add_phone': add.phone or '',
'add_fax': add.fax or '',
'tax_no': st.tax_no or '', 'tax_no': st.tax_no or '',
'number': number, 'number': number,
'ref': ref, 'ref': ref,