Skip to Content
Menu
This question has been flagged
11 Replies
6223 Views

Hi Odoo community, I have quite a specific question regarding the unique values Odoo assigns to products created (for example __export__.product_template_ and internal IDs)

We always start with our main Excel file where we keep all our data updated. From there we import products, their characteristics, prices, and later quantities in Odoo. When importing, Odoo assigns a unique ID to every single product. That means if we import 1000 articles Odoo will generate 1000 unique IDs. 

What I wonder is how these IDs are used through Odoo and the sale process. We mostly use POS for sales so what if an item from within our 1000 products list is sold and processed through the invoice system (for example Products => POS => Payment => Invoice), how will the unique ID influence all this?

The reason I ask because we are at the beginning of setting up our system so this 1000 product list will change to regularly add more articles from Excel. So our next import might be 1500 but then it's possible the unique ID from the item that was sold through the POS before will be overwritten with another item taking over that unique ID (because items were not added at the bottom of our product list but they were sorted alphabetically so lines are added in between).

Conclusion, should we be careful with the internal IDs created in Odoo or can they just be overwritten with other products regardless if they are already sold or not?? What's the influence further down the line?...

Hopefully I could explain myself properly, if not please ask me for more info...


Thanks in advance

Avatar
Discard
Best Answer

You say that "Odoo assigns a unique ID to every single product",, its definitely wrong
Beacause when importing data,, odoo will not creating external id ,, but it's created right before you exporting the record.

https://www.odoo.com/forum/help-1/question/what-is-an-external-id-and-what-is-its-uses-95070

if i'm right,, you import data from excel file without "id" columns ,, right ??

if you not defined "id" values in csv/excel file wich you import,, then odoo would not register external id record

But why when you exporting the data odoo will show "id" column with values wich formated __export__.product_template_{number} ?it because when you export the record, odoo will check is record already has external_id ? if it not,, odoo will create external id for the record first,,

External id stored in ir.model.data,, on the backend ui,  you can access it by activating developer mode,, then go to "Settings"->technical->Sequence&Identifiers->External Identifier"

For explanation maybe you can try this step:

  1. Import an example data (without "id" column) for product.template, for example try this

    one (product.template.csv) :

    name,default_code,sale_ok,purchase_ok,list_price
    TEST PRODUCT,TEST001,1,1,25000
  2. Get your new database id data and search it on "external identifier" menu ( ir.model.data),,  find by model and record id,, see are its created after importing #1 ?

  3. Try export the data that you import,, the file will contains external id (generated by odoo)

  4. Search it on External Identifier menu,,  it should new external id generated because you imported non defined external id records

But if you try to import data with defining "id" column,, it will generate ir.model.data record when importing the record from external sources (csv/excel)

Ex (defining id in file to import):

id,name,default_code,sale_ok,purchase_ok,list_price
product_template_test001,TEST PRODUCT 1,TEST001,1,1,26000



Should be carefull ?yes,, worry will overwrite data,, but if you has a good plan for structure it very usefull

For using external sources data,, i suggest you to define the external id on spreadsheet input file to be write in odoo, because your your record stored on odoo depends by your spreadsheet/excel input,, so you need to have a same identifier between both of dabatabses (spreadsheet and pgsql/odoo) 


 

Regards..

Avatar
Discard
Author

Great info, thanks for your reply! I understand the uses of external ids better now. If the records exist they will be updated and if they don't it will be inserted and automatically assigned an ID. That's good because in any case, the new info will be there. However we use Odoo always from importing Excel to Odoo so exporting these IDs is not needed in our case (one way).

I think the only question remaining is whether updating the product info from an Excel has influence through the POS or finance system. I don't understand how Odoo processes that in relation to the products list. I'll try to explain again with my example of the fruit before.

If I make a sale in the POS/Sales of my cherries which has ID 2. If I then update my list (import newest version) and now blueberry has ID 2 will the POS/Sale orders get messed up with that new data?

And what about if I disregard the ID and import without, will the sale process be influenced?

What is you mean with "ID" ??database id or external id ??

if you mean is database id,, is id on pgsql or the spreadsheet ?? i

Maybe you can show more detail data/structure that you implement,,,

If the record in odoo has "external_id", then you try to update it with importing by spreadsheet/csv file wich in those file you define an external id (id) value, it will overwrite the record (in your question that cherry will update to blueberry)

will messed up ?i think it depends on your purpose and your sale report to be expected..

if you disregard the id it will create new record.

and 1more, dont forget to checklist my answer (:-D)

Thanks and Regards

La Jayuhni Yarsyah

Author

I mean database ID. The ID Odoo creates to have a unique value for every product. Let's focus on what I mean with the sale process.

I'll explain our situation better. We have a system selling spare parts and we are importing all items into Odoo part by part as we count them. So today it is a list of 500 items, next week maybe 1000 items. The list always grows. We keep everything correct in Excel first before importing into Odoo. Soon we want to start importing our first part into Odoo for a small scale test. So we are importing about 200 items with the correct name, quantity, price and barcode. Printing the barcodes and sticking them onto the items allows us to use the POS system in Odoo for registering orders. So the item gets scanned first and then registered in the POS before it is sold.

This means once a sale is done there is a POS order linked to that article, right. Hence my question how all these orders are linked to the products?

If a certain product is linked to a sale and later by importing a new list this certain item gets a new internal ID (overwritten) will we still be able to see the initial item linked to the POS order?

Yes it should still linked to overwritted product..

So for example:

Product (import spreadsheet):

ID = product_1, Name="Monitor", Barcode="P.001", SalePrice=200

Then the imported product will got database id=1

Then when you do transaction with odoo POS module (Sale Order Line example data):

Customer ID=100,Product ID=1,UnitPrice=200,Qty=2,Total=400

And Then, a few weeks latter you update / change product description with importing spreadsheet file , ex:

ID = product_1, Name="LED Monitor", Barcode="P.001A", SalePrice=200

When after updating the product, the current related product from sale_order_line table will still related to product_id=1,, but when you open in odoo interface, in product fields will show the current product description,,

Hope it done your questions

Regards

La Jayuhni Yarsyah

Best Answer

Internal ID are numbers set automaticaly by Postgresql (the database engine), they will not be reused : Postgresql will allways increase the number.

As Erwin said, don't touch database (internal) IDs. But don't worry, you can't modify them without good Postgresql knowledge. I've forced internal IDs for specific needs, and after it was (hardly) done I've found a better, simpler and quicker solution.
Avatar
Discard
Best Answer

Never touch database (internal) IDs. Only use external IDs. You can export your products to see what happens to the IDs. Both IDs are IDs, they identify objects and are not influenced by processes.

Avatar
Discard
Author

Hi Ermin, thanks for your quick answer and clarification. Do you see where my worry is? What if something is sold having a specific internal ID and then after I import a new list with more products added and the IDs change? Will Odoo have troubles mapping IDs to the new items when values are overwritten and are you sure it does not influence the sale orders and accounting stuff already created on the first ID value?

If you buy and sell apples, you define a product "Apple". This product has a database ID and an external ID. The IDs remain the same regardless if you buy or sell apples. You do not have an ID for single individual apples. If you import data with an external ID and this ID already exists, the existing data gets updated, if it does not exist, a new object (product) will be created.

If you buy and sell apples, you define a product "Apple". This product has a database ID and an external ID. The IDs remain the same regardless if you buy or sell apples. You do not have an ID for single individual apples. If you import data with an external ID and this ID already exists, the existing data gets updated, if it does not exist, a new object (product) will be created.

If you want to use identifications for each singular apple individually, you have to use serial numbers.

Author

I'll take your example: if I have import a list of 3 articles; apples, cherries and oranges (alphabetically sorted) respectively having internal ID 1, 2 and 3 (automatically given by Odoo). If I import a new list later that adds item blueberry in between apples and cherries will the IDs shift like 1-apples 2-blueberry 3-cherries 4-oranges or will it keep the order of before and give blueberry number 4?

Are the internal IDs coupled to the the other fields or how does Odoo process this exactly?