跳至內容
選單
此問題已被標幟
2 回覆
5557 瀏覽次數

I am trying to adjust the workflow of an invoice... that is a custom user (in my case, an equivalent of Finance Administrator) must approve before it is paid.

How do i differentiate an invoice for 'sale' and one for 'purchase' ? That is, a supplier payment out must be validated...but not a customer payment (receivable). Here's a snippet:

if not self.pool['res.users'].has_group(cr, uid, 'purchase_requisition.cdn_proculator'):
                raise openerp.exceptions.AccessError(_("Only CDN Proculator can approve."))

tried:

if not self.pool['res.users'].has_group(cr, uid, 'purchase_requisition.cdn_proculator') and invoice.type == 'purchase':
                raise openerp.exceptions.AccessError(_("Only CDN Proculator can approve."))

but didn't work. How can i differentiate the account.invoice ?

頭像
捨棄
作者

I get the error: File "/opt/openerp/v7/addons/purchase_requisition_analytic/account_voucher.py", line 129, in invoice_pay_customer raise osv.except_osv(_('Warning'),_('The Proculator must have appropriate comments for invoice')) AttributeError: 'browse_record_list' object has no attribute 'type'

That's because it's a list and not a single browse_record. Try iterating over the result, or taking the first one.

作者

@Leanardo, could you please give an example snippet...

最佳答案

Hi,

In account.invoice there are four types.

'out_invoice': Customer Invoice, 'in_invoice': Supplier Invoice, 'out_refund': Customer Returns(Sales Returns), 'in_refund': Supplier Returns(Purchase Returns).

頭像
捨棄
最佳答案

The invoice types are not purchase or sales, but they are:

  •  in_invoice
  •  in_refund
  •  out_refund
  •  out_invoice

try using that in your comparison.

 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 21
2733
1
1月 25
1060
2
3月 21
8732
1
6月 16
4074
8
8月 15
9006