Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Create new invoice by code

Avatar
odoo
1 Comment
Avatar
Discard
Avatar
odoo
-

Thanks. It worked!

1 Answer
0
Avatar
odoo
Best Answer

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

1 Comment
Avatar
Discard
Avatar
odoo
-

HI. When i try this i get an error cr is undefined. How do I solve this