Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Account.invoice customization

By
mmycool
on 6/24/14, 4:33 PM 1,282 views

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'

mmycool
on 6/24/14, 4:52 PM

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

Leonardo Donelli
on 6/26/14, 11:49 AM

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

mmycool
on 8/11/14, 4:46 PM
5

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 8/12/14, 5:28 AM

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).

2

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 6/26/14, 11:35 AM

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.

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 6/24/14, 4:33 PM
Seen: 1282 times
Last updated: 3/16/15, 8:10 AM