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

[SOLVED]: How to create product from custom module?

By
Dr Obx
on 5/3/16, 8:15 AM 520 views

Because quiet often importing data from external sources, decided to create a module as flexible as possible so I can change set of fields depending on CSV source and map it into product_template table columns.

So i have a source selector [ebay, opencart, stock, end more], choosing source, loading data from CSV,  (product_name=> name, price=>sale_price ... etc) into fields.

Once CSV is loaded i can use all the records to create new product by selectiong records from list or all in one go.

self.env['product.template'].create({'name': record.product_name,'sale_price': record.price,.......})

The only problem I have now is: if I add image_stream to the query/API it generate an error, once I remove image_stream everything works fine.

The question is: how can I use image binary stream(converted image) while new product is created?

Tried already a few methods but regardless of what I'm doing it still displaying error:

2016-05-11 08:18:05,679 49329 ERROR Farmore openerp.http: Exception during JSON request handling.

MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

0
Dr Obx
On 5/11/16, 4:23 AM

This is my import product page view and here the product image is displayed. Just abowe there is a button "ProCreator" clicking this button new product is created with all required data ...... unfortunately without image and I'm getting this error:

Creating product!

2016-05-11 08:18:05,679 49329 ERROR Farmore openerp.http: Exception during JSON request handling.

MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

Maybe because the image is already converted and while product is created "create" method is trying to do it again ?

Apart of that it works pretty well ;)


Problem solved, another module causing this issue.

Now it works just fine!

Thank You Pawan!

0
Matthieu
On 5/4/16, 3:11 AM

I'm interested by the response cause I want to do the same thing.

0

michel Guénard

--michel Guénard--
1033
| 5 5 8
VIROFLAY, France
--michel Guénard--

VP operations & finance Social entrepreneur Certified Public Accountant Past Chief internal auditor

michel Guénard
On 5/5/16, 6:31 PM

If your question is how to create products by importing a csv file then the answer is yes.I do it frequently. 


The matching of the csv file columns with the Odoo field names is essential;

to avoid errors, start exporting a list of articles with all the fields that you need for the import. Some fields are mandatory (name etc...); they are colored in blue in the exporting interface.

Then reuse this exported format with your new products.

You will import product, not variants


Read changed post above.

Dr Obx
on 5/11/16, 11:28 AM

When you importing data from CSV into your products, what is the content of the image column ? Is it a link yo file ? is it an image itself ?

Dr Obx
on 5/15/16, 5:48 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

1 follower(s)

Stats

Asked: 5/3/16, 8:15 AM
Seen: 520 times
Last updated: 5/15/16, 5:37 PM