merge from production

fix_acc
watcha.h 2015-08-26 10:17:37 +07:00
commit 7afa9d7840
9 changed files with 174 additions and 5 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="type">report_odt2</field>
<field name="model">account.invoice</field>
<field name="method">get_invoice_data</field>
<field name="template">cust_invoice</field>
</action>

View File

@ -1,9 +1,11 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","paid","waiting_payment"]]]}' show_company="1">
<head>
<field name="state"/>
<!--
<button string="Print" dropdown="1" icon="print">
<item string="Reciept" action="report_clinic_payment_form" action_options="convert=pdf"/>
</button>
-->
<button string="Options" dropdown="1">
<item string="New Dialyzer" action="clinic_hd_case_dlz" states="draft,in_progress,waiting_treatment"/>
<item string="Drop Dialyzer" method="drop_dlz" confirm="Are you sure?" states="completed"/>
@ -125,6 +127,9 @@
<related>
<field name="invoices" click_action="view_invoice">
<list colors='{"#9f9":[["state","=","paid"]]}'>
<head>
<button string="Print" action="clinic_hdcase_invoice_print" action_options="convert=pdf" icon="print"/>
</head>
<field name="number"/>
<field name="ref"/>
<field name="inv_type"/>

View File

@ -6,7 +6,8 @@
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
<field name="ptype_id" span="2"/>
<field name="walkin" span="2"/>
<field name="reimbursable" span="2"/>
<field name="cycle_id" span="2"/>
<field name="product_id" span="2"/>
<field name="reimbursable" span="2"/>
<field name="pay_type" attrs='{"invisible":[["reimbursable","=","yes"]]}' span="2"/>
</form>

View File

@ -1,6 +1,10 @@
import time
from netforce.model import Model, fields, get_model
from netforce.utils import get_file_path
from netforce.access import get_active_company, get_active_user
from . import utils
class AccountInvoice(Model):
_inherit="account.invoice"
@ -293,4 +297,134 @@ class AccountInvoice(Model):
dt=(t1-t0)*1000
print("invoice.post <<< %d ms"%dt)
def get_invoice_data(self,ids,context={}):
settings=get_model('settings').browse(1)
pages=[]
for obj in self.browse(ids):
context['refer_id']=obj.id
data=self.get_invoice_page(context=context)
limit_item=10
if data['state']=='draft':
limit_item-=3
for i in range(len(data['lines']),limit_item):
data['lines'].append({
'no': '',
'product_name': '',
'description': '',
'uom_name': '',
'qty': None,
'price': None,
'amount': None,
})
pages.append(data)
if pages:
pages[-1]["is_last_page"]=True
return {
"pages": pages,
"logo": get_file_path(settings.logo),
}
def get_invoice_page(self,context={}):
if not context.get('refer_id'):
return {}
inv_id=int(context['refer_id'])
inv=self.browse(inv_id)
comp_id=get_active_company()
comp=get_model('company').browse(comp_id)
cust=inv.partner_id
cust_tax_no=cust.tax_no or ''
cust_name=cust.name or ''
cust_addr=''
if cust.addresses:
cust_addr=cust.addresses[0].address_text
if 'your' in cust_addr:
cust_addr=''
dpt=inv.department_id
branch_id=None
if dpt:
branch_id=dpt.branch_id.id
elif inv.patient_partner_id:
for pt in get_model('clinic.patient').search_read([['partner_id','=',inv.patient_partner_id.id]],['branch_id']):
if pt.get("branch_id"):
branch_id=pt['branch_id'][0]
context['branch_id']=branch_id
st=get_model('settings').browse(1,context=context)
cst=get_model('clinic.setting').browse(1)
no=1
sub_total=0
amount_total=0
lines=[]
for line in inv.lines:
amt=line.amount or 0
prod=line.product_id
lines.append({
'no': no,
'product_name': prod.name or '',
'description': line.description or '',
'uom_name': prod.uom_id.name or '',
'qty': line.qty or 0,
'price': line.price or 0,
'amount': amt,
})
sub_total+=amt
no+=1
amount_total=sub_total
is_draft=inv.state=='draft' and True or False
is_cheque=False
user_id=get_active_user()
user=get_model("base.user").browse(user_id)
comp_name=comp.name or ""
if st.default_address_id.company:
comp_name=st.default_address_id.company or ""
payment_terms=''
currency_code=''
due_date=inv.due_date
number=inv.number or ""
ref=inv.ref or ""
payment_terms=inv.payment_terms or ""
currency_code=inv.currency_id.code or ""
due_date=inv.due_date
add=st.default_address_id
data={
'partner_name': cust_name,
'partner_address': cust_addr,
'partner_tax_no': cust_tax_no,
'due_date': due_date,
'currency_code': currency_code,
'payment_terms': payment_terms,
'comp_name': comp_name,
'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_subdistrict_name': add.subdistrict_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 '',
'number': number,
'ref': ref,
'date': inv.date,
'datenow': inv.date or time.strftime("%d/%m/%Y"),
'dateprint': inv.date or time.strftime("%d/%m/%Y %H:%M:%S"),
'note': inv.note 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,
'user_name': user.name or "",
'state': inv.state or "",
}
data['pay_type']='Credit'
if st.logo:
data['logo']=get_file_path(st.logo)
if cst.signature:
data['signature']=get_file_path(cst.signature)
return data
AccountInvoice.register()

View File

@ -47,6 +47,7 @@ class AccountPayment(Model):
'name': 'report_clinic_payment_form',
'refer_id': hd_case_id,
'payment_id': obj.id,
'convert': 'pdf',
},
}

View File

@ -1273,7 +1273,7 @@ class HDCase(Model):
for payment in obj.payments:
context['payment_id']=payment.id
data=self.get_report_payment_data(context=context)
limit_item=10
limit_item=9
if data['state']=='draft':
limit_item=10
for i in range(len(data['lines']),limit_item):

View File

@ -19,6 +19,7 @@ class ReportAccountHDCaseSummary(Model):
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Claim'),
'walkin': fields.Selection([['yes','Yes'],['no','No']],'Walkin'),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
'pay_type': fields.Selection([['cash','Cash'],['credit','Credit']],'Pay Type'),
'product_id': fields.Many2One("product","Product"),
}
@ -76,6 +77,7 @@ class ReportAccountHDCaseSummary(Model):
walkin=defaults.get('walkin')
ptype_id=None
cycle_id=None
pay_type=''
if ids:
obj=self.browse(ids)[0]
branch_id=obj.branch_id.id
@ -87,6 +89,7 @@ class ReportAccountHDCaseSummary(Model):
cycle_id=obj.cycle_id.id
reimbursable=obj.reimbursable or ""
product_id=obj.product_id.id
pay_type=obj.pay_type
walkin=obj.walkin
dom=[
['hd_case_id.date','>=', date_from],
@ -214,7 +217,20 @@ class ReportAccountHDCaseSummary(Model):
else:
records[hdcase_id]['misc']+=amt
lines=[]
# nurse would like to see only receipt
del_invoice=False
del_receipt=False
if pay_type and reimbursable=='no' and pay_type=='cash':
del_invoice=True
elif pay_type and reimbursable=='no' and pay_type=='credit':
del_receipt=True
for hdcase_id, vals in records.items():
if del_invoice and vals['inv_number']:
continue
elif del_receipt and vals['pm_number']:
continue
lines.append(vals)
company_name=company.name or ""
if department_id:

View File

@ -896,6 +896,10 @@ class Shop(Model):
for pick in shop.pickings:
pick_id=pick.id
pick_number=pick.number
st=get_model('clinic.setting').browse(1)
ct_ids=[]
for ct in st.product_categ_view:
ct_ids.append(ct.id)
for line in shop.lines:
prod=line.product_id
categ=line.categ_id
@ -906,8 +910,10 @@ class Shop(Model):
fee=0
dlz=0
mdc_names=[]
if categ.parent_id:
if categ.parent_id.code=='MDC':
#if categ.parent_id:
#if categ.parent_id.code=='MDC': #XXX
if categ:
if categ.id in ct_ids:
mdc+=amount
name=prod.name or ""
name=name.split("-")
@ -944,7 +950,7 @@ class Shop(Model):
'fee': fee,
'mdc': mdc,
'mdc_name': ','.join([n for n in mdc_names]),
'dlz_name': "", #XXX
'dlz_name': "",
'dlz_id': "",
'dlz': dlz,
'lab': lab,