【问题标题】:Odoo: Customer Payment In Custom ModuleOdoo:自定义模块中的客户付款
【发布时间】: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


    【解决方案1】:

    **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'为真,'Amount Allocation'等于'未结余额' 用于创建凭证行并验证凭证以单击 button_proforma_voucher

    self.pool.get('account.voucher').button_proforma_voucher(cr, uid, pay_id, context=None)
    

    3.凭证的日记条目不会自动发布状态,您必须在日记条目页面中按下发布按钮

    1. 当您验证凭证并且发票的凭证行 (move_line_id) 完全对帐且“金额分配”等于“未结余额”时,发票将处于已付款状态

    对不起,我的英语太差了。 希望能帮到你。

    【讨论】:

      猜你喜欢
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2013-08-20
      • 2015-03-01
      • 2013-02-17
      • 2013-06-09
      • 2013-01-16
      相关资源
      最近更新 更多