【发布时间】:2016-09-20 09:54:26
【问题描述】:
我的自定义模块向导中有一个按钮。
当我点击向导时。
以下字段需要填写。
Service Product Name(Will get populated automatically)
Amount
Payment Method
Date
Description
Partner Name(Which will get populated automatically)
我在向导的页脚有一个名为 pay 的按钮。
When I click Pay Button, the following things to be done
1. Create a Invoice
2. Validate the invoice
3. Create a Customer Payment
4. Validate the Payment
5. Invoice Should be in the Paid State
我写过这样的代码。
def pay(self, cr, uid, ids, context=None):
if context is None:
context = {}
if context.get('active_id', False):
student_obj = self.pool.get('op.student')
student = student_obj.browse(cr, uid, context.get('active_id', False), context=context)
if student.fee_paid == False:
for fee in self.browse(cr, uid, ids, context=context):
if not student.partner_id:
raise Warning(_('Missing Error!'), _('Please select a customer in Assessment.'))
######### Invoice Creation with Student Line ######################
inv_vals = self._prepare_invoice_vals(cr, uid, student, fee, context=context)
inv_id = self.pool.get('account.invoice').create(cr, uid, inv_vals, context=context)
stud_line_vals = self._prepare_invoice_student_line_vals(cr, uid, fee, inv_id, context=context)
self.pool.get('account.invoice.line').create(cr, uid, stud_line_vals, context=context)
#######################################################################
if fee.transportation_needed == True:
tran_line_vals = self._prepare_invoice_trans_line_vals(cr, uid, fee, inv_id, context=context)
self.pool.get('account.invoice.line').create(cr, uid, tran_line_vals, context=context)
draft_to_open = self.pool.get('account.invoice').signal_workflow(cr, uid, [inv_id], 'invoice_open')
########### Account Voucher creation ######################
pay_vals = self._prepare_voucher_vals(cr, uid, student, fee, context=context)
pay_id = self.pool.get('account.voucher').create(cr, uid, pay_vals, context=context)
#####################################################################
open_to_paid = self.pool.get('account.voucher').signal_workflow(cr, uid, [pay_id], 'proforma_voucher')
student_obj.write(cr, uid, context.get('active_id', False),{'fee_paid': True,'fee_invoice_id' : inv_id}, context=context)
return {'type': 'ir.actions.act_window_close'}
这使得 ** 1. 创建和验证发票 2. 付款创建时没有 account_voucher_lines,但也经过验证 3.为两者创建日记帐分录 (i) 发票(验证状态) (ii) 付款(未发布状态)**
我想要
** 1. 发票创建和验证 2. 付款也使用付款行创建和验证 3.为已发布状态的两者创建的日记帐分录 4. 毕竟Invoice应该是Paid状态 **
提前致谢:-)
【问题讨论】:
标签: python-2.7 odoo-8 openerp-7