from pprint import pprint from netforce.model import Model, fields, get_model class AccountPayment(Model): _inherit="account.payment" _fields={ 'number': fields.Char("Number",required=True,search=True), } 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, } 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_ids': ids, 'convert': 'pdf', }, } AccountPayment.register()