clinic/netforce_clinic/models/account_payment.py

55 lines
1.5 KiB
Python
Raw Permalink Normal View History

2015-08-11 05:13:04 +00:00
from pprint import pprint
2014-10-23 08:21:29 +00:00
from netforce.model import Model, fields, get_model
class AccountPayment(Model):
_inherit="account.payment"
2015-02-04 14:10:41 +00:00
_fields={
2015-03-18 01:39:03 +00:00
'number': fields.Char("Number",required=True,search=True),
2015-02-04 14:10:41 +00:00
}
2015-03-18 01:39:03 +00:00
def _get_number(self,context={}):
type=context.get("type")
if type=="in":
seq_type="pay_in"
elif type=="out":
seq_type="pay_out"
else:
return
seq_id=get_model("sequence").find_sequence(type=seq_type,context=context) # force to use context
if not seq_id:
return None
while 1:
num=get_model("sequence").get_next_number(seq_id,context=context)
res=self.search([["number","=",num]])
if not res:
return num
get_model("sequence").increment_number(seq_id,context=context)
_defaults={
'number': _get_number,
}
2016-03-08 11:07:50 +00:00
2014-10-23 08:21:29 +00:00
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,
2017-12-26 08:00:07 +00:00
'payment_ids': ids,
2015-08-26 03:09:34 +00:00
'convert': 'pdf',
2014-10-23 08:21:29 +00:00
},
}
AccountPayment.register()