Skip to Content
Menu
This question has been flagged
6 Replies
2729 Views

update: replaces "concept" with "draft" after first answer.

Hi,

I want to connect an administrative system to Odoo 12. I want to be able to create draft invoices from the data in the other system.

How can I retrieve a list of possible models in my server instance?

Is there somewhere code available to create a draft invvoice I can use as a basis to start developing from?

Kind regards,

Jeroen  Baten

Avatar
Discard

What is a concept invoice?

Author

Hi. I am a newbie in Odoo but I seem to be able to make an invoice and not make it final yet. To make it final I need to click on the "make final" or something similar button. So if I could somehow send data to Odoo and create a , what I call, "concept invoice" I can then edit it further in Odoo before making it a final invoice. Maybe I am wrong. In that case, how can I make an invoice using Odoorpc calls?

Author

Hm, based on Ermins answer, maybe I should put some nuance on my "newbie" term. I'm 56 and 40 year of programming experience. (I love Python). I do not consider myself a newbie on a lot of subjects but I AM new at interfacing with Python into Odoo.

Nothing personal, but if you want to create what you originally named "concept", you should know the default workflow and its stages and terms, such as "draft invoice", which is what you were looking for from a functional perspective.

... by the way, I'm also 56 and started at age of 16 with BASIC and Assembler ;-)

Author

Me too! What was your system? Mine was a Tandy TRS-80 at school.

Best Answer

example code
import odoorpc  # Prepare the connection to the server
odoo = odoorpc.ODOO('localhost', port=8069)

# Check available databases
print(odoo.db.list())

# Login
odoo.login('db_name', 'user', 'passwd')

# Current user
user = odoo.env.user
print(user.name)            # name of the user connected
print(user.company_id.name) # the name of its company

# Simple 'raw' query
user_data = odoo.execute('res.users', 'read', [user.id])
print(user_data)

# Use all methods of a model
if 'sale.order' in odoo.env:
    Order = odoo.env['sale.order']
    order_ids = Order.search([])
    for order in Order.browse(order_ids):
        print(order.name)
        products = [line.product_id.name for line in order.order_line]
        print(products)

# Update data through a record
user.name = "Brian Jones"
\https://pythonhosted.org/OdooRPC/
Avatar
Discard
Author Best Answer

I found the answer. Strangely enough they first give a lot of examples on this page but further down the page you will find the answer to this question: how to query the ir.model: https://www.odoo.com/documentation/12.0/webservices/odoo.html

Avatar
Discard
Author

I don't have the karma (yet) to upvote Rehan's answer but kudos to him and big thanks!

Best Answer

When you create a new invoice in Odoo, it is in "Draft" state by default. Before you start coding, you should learn Odoo first: Odoo Documentation

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
133
2
May 24
1049
0
Mar 23
863
1
Mar 23
1833
0
Feb 23
1266