Odoo从代码验证发票 [英] Odoo validate invoice from code

查看:157
本文介绍了Odoo从代码验证发票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从其他模型创建发票,但想获得验证而不是草稿 但是我的代码没有生成内部编号和总数.

I creating an invoice from another model, and want to get validated not draft But internal number and total are not generated with my code.

invoice_id = self.pool.get('account.invoice').create(cr, uid,{
                                  'partner_id':self.supplier.id,
                                  'name' : 'Faltante mercaderia',
                                  'journal_id': journal_id,
                                  'account_id':account_id,
                                  'type': 'in_refund',
                                    })
self.pool.get('account.invoice.line').create(cr, uid,{
                'invoice_id' : invoice_id,
                'name' : 'Faltante mercaderia %s: %s' %(self.type,self.number),
                'quantity' : self.dif_final,
                'price_unit':self.tarifa_dif / 1000,
            })
a = self.env['account.invoice'].browse([invoice_id])
a.invoice_validate()

我还尝试添加a.action_number()

I also try adding a.action_number()

推荐答案

此代码应为您工作:

inv_obj = self.pool.get('account.invoice')
inv_obj.button_compute(cr, uid, [invoice_id], context=context, set_total=True)
inv_obj.action_date_assign(cr, uid, invoice_id, context=context)
inv_obj.action_move_create(cr, uid, invoice_id, context=context)
inv_obj.action_number(cr, uid, invoice_id, context=context)
inv_obj.invoice_validate(cr, uid, invoice_id, context=context)

您可以通过调用上述所有方法进行检查,并告诉我.

You can check by calling all above methods and let me know.

这篇关于Odoo从代码验证发票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆