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.

1

Create new invoice by code

By
Patricia
on 4/18/13, 1:01 PM 2,149 views

Hi...I need to call the method write of account invoice from a button. I have a form with information and i want to create a draft invoice when the button is clicked passing the values for the invoice for parameter. Thanks

3

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/18/13, 1:21 PM

The method to create a new invoice is not write but create. Write is used to change values in existing record.

This is a basilar code to create an invoice

your_class_records = self.browse(cr, uid, ids)
for record in your_class_records:
    invoice_id = self.pool.get('account.invoice').create(cr, uid,{
        'name' : record.name,
        'date_invoice' : record.date,
    })
    for line in record.line:
        self.pool.get('account.invoice.line).create(cr, uid,{
            'invoice_id' : invoice_id,
            'name' : line.name,
            'product_id' : line.product_id.id,
        })

http://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html

0
Patricia
On 4/18/13, 5:35 PM

Thanks. It worked!

If my answer is the correct one, please, set it as correct so you can help user that will search the some problem in the future. If you want you can give a +1 to the answer, too...:)

Francesco OpenCode
on 4/19/13, 5:20 AM

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

0 follower(s)

Stats

Asked: 4/18/13, 1:01 PM
Seen: 2149 times
Last updated: 3/16/15, 8:10 AM