我的自定义模块向导中有一个按钮。
当我点击向导时。
以下字段需要填写。
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.毕竟发票应该处于付费状态 **
提前致谢: - )
答案 0 :(得分:0)
** 1.Invoice Created:您可以使用工作流程和日记帐验证发票条目将创建并发布状态自动
draft_to_open = self.pool.get('account.invoice').signal_workflow(cr, uid, [inv_id], 'invoice_open')
instead:
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
2.Payment Created:查找发票的'move_line_id'(记录是应收帐款),然后在凭证行的'move_line_id'字段中定义它,并设置'Full Reconcile'为true且'Amount Allocation'等于'Open Balance '用于创建凭证行并验证凭证以单击button_proforma_voucher
self.pool.get('account.voucher').button_proforma_voucher(cr, uid, pay_id, context=None)
3.journal的凭证条目不会发布状态自动,您必须在日记条目页面按下发布按钮