conv_bal
watcha.h 2014-10-23 15:21:29 +07:00
parent e2bb209c5c
commit 3b5a68260d
6 changed files with 84 additions and 2 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="type">report_odt</field>
<field name="model">clinic.hd.case</field>
<field name="method">get_report_payment_data</field>
<field name="template">payment_form</field>
</action>

View File

@ -119,7 +119,22 @@
<field name="state"/> <field name="state"/>
</list> </list>
</field> </field>
<field name="payments" click_action="clinic_view_payment"/> <field name="payments" click_action="clinic_view_payment">
<list>
<head>
<button string="Reciept" method="run_report" type="default" icon="print"/>
</head>
<field name="number"/>
<field name="date"/>
<field name="partner_id"/>
<field name="type"/>
<field name="pay_type"/>
<field name="account_id"/>
<field name="ref"/>
<field name="amount_total"/>
<field name="state"/>
</list>
</field>
<field name="pickings" click_action="view_picking"/> <field name="pickings" click_action="view_picking"/>
<field name="comments"/> <field name="comments"/>
</related> </related>

View File

@ -38,3 +38,4 @@ from . import import_data_nhso
from . import import_data_sc from . import import_data_sc
from . import translate from . import translate
from . import payment from . import payment
from . import account_payment

View File

@ -0,0 +1,24 @@
from netforce.model import Model, fields, get_model
class AccountPayment(Model):
_inherit="account.payment"
def run_report(self,ids,context={}):
obj=self.browse(ids)[0]
hd_case_id=obj.related_id.id
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
# TODO
# set payment_id on hd case
# send to action print form payment
hd_case.write({
'payment_id': obj.id,
})
return {
'next': {
'name': 'report_clinic_payment_form',
'refer_id': hd_case_id,
'payment_id': obj.id,
},
}
AccountPayment.register()

View File

@ -2,7 +2,7 @@ import time
from datetime import datetime from datetime import datetime
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.utils import get_data_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
@ -72,6 +72,7 @@ class HDCase(Model):
'pay_amount': fields.Float("Amount",function="get_pay_amount"), 'pay_amount': fields.Float("Amount",function="get_pay_amount"),
'pay_date': fields.Date("Pay Date"), 'pay_date': fields.Date("Pay Date"),
'pay_account_id': fields.Many2One("account.account","Account"), 'pay_account_id': fields.Many2One("account.account","Account"),
'payment_id': fields.Many2One("account.payment","Payment"), # for print
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -580,4 +581,39 @@ class HDCase(Model):
'state': 'waiting_payment', 'state': 'waiting_payment',
}) })
def get_report_payment_data(self,context={}):
settings=get_model("settings").browse(1)
refer_id=context.get("refer_id")
payment_id=context.get("payment_id")
data={
'settings_address_text': settings.default_address_id and settings.default_address_id.get_address_text()[settings.default_address_id.id] or "",
'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))
partner_address_id=payment.partner_id.default_address_id
data['number']=payment.number
data['ref']=payment.related_id.number
data['date']=payment.date
data['partner_name']=payment.partner_id.name or 0
data['partner_address_text']=partner_address_id and partner_address_id.get_address_text()[partner_address_id.id] or "",
lines=[]
for line in payment.direct_lines:
lines.append({
'description': line.description or '',
'qty': line.qty,
'unit_price': line.unit_price or 0.0,
'amount': line.amount or 0.0,
})
data['lines']=lines
data['amount_subtotal']=payment.amount_subtotal or 0.0
data['amount_tax']=payment.amount_tax or 0.0
data['amount_total']=payment.amount_total or 0.0
return data
HDCase.register() HDCase.register()

Binary file not shown.