print bill in hdcase the same template as shop
parent
b984eb4c2a
commit
7b01f7835d
|
@ -1,6 +1,6 @@
|
||||||
<action>
|
<action>
|
||||||
<field name="type">report_odt</field>
|
<field name="type">report_odt2</field>
|
||||||
<field name="model">clinic.hd.case</field>
|
<field name="model">clinic.hd.case</field>
|
||||||
<field name="method">get_report_payment_data</field>
|
<field name="method">get_payment_data</field>
|
||||||
<field name="template">payment_form</field>
|
<field name="template">cust_payment</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
<field name="branch_id" invisible="1"/>
|
<field name="branch_id" invisible="1"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
<related>
|
<related>
|
||||||
<field name="hd_cases"/>
|
<field name="hd_cases" readonly="1"/>
|
||||||
</related>
|
</related>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -5,6 +5,7 @@ from netforce.model import Model, fields, get_model
|
||||||
from netforce.utils import get_data_path, get_file_path
|
from netforce.utils import get_data_path, get_file_path
|
||||||
from netforce.access import get_active_user,set_active_user
|
from netforce.access import get_active_user,set_active_user
|
||||||
from netforce.access import get_active_company
|
from netforce.access import get_active_company
|
||||||
|
from . import utils
|
||||||
|
|
||||||
class HDCase(Model):
|
class HDCase(Model):
|
||||||
_name="clinic.hd.case"
|
_name="clinic.hd.case"
|
||||||
|
@ -351,15 +352,12 @@ class HDCase(Model):
|
||||||
'ref': bill_no or obj.number or "",
|
'ref': bill_no or obj.number or "",
|
||||||
'direct_lines': [],
|
'direct_lines': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
patient=obj.patient_id
|
patient=obj.patient_id
|
||||||
ptype=patient.type_id
|
ptype=patient.type_id
|
||||||
#XXX
|
|
||||||
shop_type=st.shop_type_id
|
shop_type=st.shop_type_id
|
||||||
if not shop_type:
|
if not shop_type:
|
||||||
raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type")
|
raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type")
|
||||||
ptype=shop_type
|
ptype=shop_type
|
||||||
|
|
||||||
prod_acc=st.get_product_account
|
prod_acc=st.get_product_account
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
if line.reimbursable=='no':
|
if line.reimbursable=='no':
|
||||||
|
@ -383,14 +381,6 @@ class HDCase(Model):
|
||||||
"amount": line.amount or 0,
|
"amount": line.amount or 0,
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
}))
|
}))
|
||||||
#vals['direct_lines'].append(('create',{
|
|
||||||
#'description': 'Payment; %s'%obj.number,
|
|
||||||
#'account_id': income_account_id,
|
|
||||||
#'qty': 1,
|
|
||||||
#'unit_price': pay_amount,
|
|
||||||
#'amount': pay_amount,
|
|
||||||
#}))
|
|
||||||
|
|
||||||
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
||||||
obj.write({
|
obj.write({
|
||||||
'state': 'paid',
|
'state': 'paid',
|
||||||
|
@ -924,40 +914,89 @@ class HDCase(Model):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_report_payment_data(self,context={}):
|
def get_report_payment_data(self,context={}):
|
||||||
settings=get_model("settings").browse(1)
|
if not context.get('payment_id'):
|
||||||
refer_id=context.get("refer_id")
|
return {}
|
||||||
payment_id=context.get("payment_id")
|
payment_id=context.get("payment_id")
|
||||||
data={
|
if not payment_id:
|
||||||
'settings_address_text': settings.default_address_id and settings.default_address_id.get_address_text()[settings.default_address_id.id] or "",
|
return {}
|
||||||
'logo': get_file_path(settings.logo) or "",
|
|
||||||
}
|
|
||||||
if refer_id:
|
|
||||||
pass
|
|
||||||
if payment_id:
|
|
||||||
#context['refer_id']=payment_id
|
|
||||||
#data=get_model("account.payment").get_report_data(context=context)
|
|
||||||
payment=get_model("account.payment").browse(int(payment_id))
|
payment=get_model("account.payment").browse(int(payment_id))
|
||||||
partner_address_id=payment.partner_id.default_address_id
|
comp_id=get_active_company()
|
||||||
data['number']=payment.number
|
comp=get_model('company').browse(comp_id)
|
||||||
data['ref']=payment.related_id.number
|
st=get_model('settings').browse(1)
|
||||||
data['date']=payment.date
|
addresses=st.addresses
|
||||||
data['partner_name']=payment.partner_id.name or 0
|
comp_addr=''
|
||||||
data['partner_address_text']=partner_address_id and partner_address_id.get_address_text()[partner_address_id.id] or "",
|
if addresses:
|
||||||
|
comp_addr=addresses[0].address_text
|
||||||
|
cust=payment.partner_id
|
||||||
|
cust_name=cust.name or ''
|
||||||
|
cust_addr=''
|
||||||
|
if cust.addresses:
|
||||||
|
cust_addr=cust.addresses[0].address_text
|
||||||
|
if cust.walkin_cust:
|
||||||
|
cust_name=payment.ref or ''
|
||||||
|
no=1
|
||||||
|
sub_total=0
|
||||||
|
amount_total=0
|
||||||
lines=[]
|
lines=[]
|
||||||
for line in payment.direct_lines:
|
for line in payment.lines:
|
||||||
|
amt=line.amount or 0
|
||||||
lines.append({
|
lines.append({
|
||||||
|
'no': no,
|
||||||
|
'product_name': '',
|
||||||
'description': line.description or '',
|
'description': line.description or '',
|
||||||
'qty': line.qty,
|
'uom_name': '',
|
||||||
'unit_price': line.unit_price or 0.0,
|
'qty': line.qty or 0,
|
||||||
'amount': line.amount or 0.0,
|
'price': line.unit_price or 0,
|
||||||
|
'amount': amt,
|
||||||
})
|
})
|
||||||
data['lines']=lines
|
sub_total+=amt
|
||||||
data['amount_subtotal']=payment.amount_subtotal or 0.0
|
no+=1
|
||||||
data['amount_tax']=payment.amount_tax or 0.0
|
amount_total=sub_total
|
||||||
data['amount_total']=payment.amount_total or 0.0
|
is_draft=payment.state=='draft' and True or False
|
||||||
|
is_cheque=False
|
||||||
|
pay_type=payment.pay_type or ''
|
||||||
|
data={
|
||||||
|
'comp_name': comp.name or '',
|
||||||
|
'comp_addr': comp_addr or '',
|
||||||
|
'tax_no': st.tax_no or '',
|
||||||
|
'number': payment.number or '',
|
||||||
|
'ref': payment.ref,
|
||||||
|
'date': payment.date,
|
||||||
|
'cust_name': cust_name,
|
||||||
|
'cust_addr': cust_addr,
|
||||||
|
'note': payment.memo or '',
|
||||||
|
'lines':lines,
|
||||||
|
'amount_subtotal': sub_total,
|
||||||
|
'amount_total': amount_total,
|
||||||
|
'total_text': utils.num2word(amount_total),
|
||||||
|
'is_cheque': is_cheque,
|
||||||
|
'is_draft': is_draft,
|
||||||
|
'pay_type': pay_type,
|
||||||
|
}
|
||||||
|
if pay_type=='direct':
|
||||||
|
data['pay_type']='Cash'
|
||||||
|
else:
|
||||||
|
data['pay_type']='Credit'
|
||||||
|
if st.logo:
|
||||||
|
data['logo']=get_file_path(st.logo)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def get_payment_data(self,ids,context={}):
|
||||||
|
settings=get_model('settings').browse(1)
|
||||||
|
pages=[]
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
for payment in obj.payments:
|
||||||
|
context['payment_id']=payment.id
|
||||||
|
data=self.get_report_payment_data(context=context)
|
||||||
|
pages.append(data)
|
||||||
|
if pages:
|
||||||
|
pages[-1]["is_last_page"]=True
|
||||||
|
return {
|
||||||
|
"pages": pages,
|
||||||
|
"logo": get_file_path(settings.logo),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
def new_dialyzer(self,ids,context={}):
|
def new_dialyzer(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
is_wiz=context.get("is_wiz")
|
is_wiz=context.get("is_wiz")
|
||||||
|
|
|
@ -53,7 +53,6 @@ class Shop(Model):
|
||||||
'cheque_no': fields.Char("Cheque No."),
|
'cheque_no': fields.Char("Cheque No."),
|
||||||
'hd_case_call': fields.Boolean("HD Case Call"),
|
'hd_case_call': fields.Boolean("HD Case Call"),
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
'is_cheque': fields.Boolean("Is Cheque"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_branch(self,context={}):
|
def _get_branch(self,context={}):
|
||||||
|
@ -522,11 +521,9 @@ class Shop(Model):
|
||||||
sub_total+=amt
|
sub_total+=amt
|
||||||
no+=1
|
no+=1
|
||||||
amount_total=sub_total #XXX
|
amount_total=sub_total #XXX
|
||||||
is_cash=''
|
|
||||||
is_cheque=shop.is_cheque and 'x' or ''
|
|
||||||
if shop.pay_type=='cash':
|
|
||||||
is_cash='x'
|
|
||||||
is_draft=shop.state=='draft' and True or False
|
is_draft=shop.state=='draft' and True or False
|
||||||
|
is_cheque=False
|
||||||
|
pay_type=shop.pay_type or ''
|
||||||
data={
|
data={
|
||||||
'comp_name': comp.name or '',
|
'comp_name': comp.name or '',
|
||||||
'comp_addr': comp_addr or '',
|
'comp_addr': comp_addr or '',
|
||||||
|
@ -542,9 +539,19 @@ class Shop(Model):
|
||||||
'amount_total': amount_total,
|
'amount_total': amount_total,
|
||||||
'total_text': utils.num2word(amount_total),
|
'total_text': utils.num2word(amount_total),
|
||||||
'is_cheque': is_cheque,
|
'is_cheque': is_cheque,
|
||||||
'is_cash': is_cash,
|
|
||||||
'is_draft': is_draft,
|
'is_draft': is_draft,
|
||||||
}
|
}
|
||||||
|
blank_dot=''
|
||||||
|
if pay_type=='cash':
|
||||||
|
data['pay_type']='Cash'
|
||||||
|
if shop.cheque_no:
|
||||||
|
data['is_cheque']=True
|
||||||
|
data['bank_name']=shop.bank_name or blank_dot
|
||||||
|
data['branch_name']=shop.branch_name or blank_dot
|
||||||
|
data['cheque_no']=shop.cheque_no or blank_dot
|
||||||
|
data['cheque_date']=shop.pay_date or blank_dot
|
||||||
|
else:
|
||||||
|
data['pay_type']='Credit'
|
||||||
if st.logo:
|
if st.logo:
|
||||||
data['logo']=get_file_path(st.logo)
|
data['logo']=get_file_path(st.logo)
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue