philips
philips

Reputation: 465

How can I automate importing an excel file into an custom Odoo 10 module?

Goal:

I am using Odoo 10 as a front end view only system for remote staff.

I want to:

  1. regularly export an (excel) file containing a complete data-set from the main production database (SQL Server),
  2. delete all records in Odoo and
  3. import the new data.

The data-set is about +400K records.

I know

I do not know

I believe I can accomplish this through the bulit-in Scheduled Actions function in Odoo but I am stumped on how to actually use it and write the needed python code. (I know VBA and learning Python now.)

I am also open to suggestions if there i a better way to do.

Upvotes: 0

Views: 1108

Answers (1)

aekis.dev
aekis.dev

Reputation: 2764

It will be better if you directly connect from Odoo to your MSSQL Server in order to query the data to get it inserted into an Odoo model table. To delete all records of an Odoo model table is as simple as use this statement:

self.env['custom.model'].search([]).unlink()

You could put that code among the records import/create statements into a model method that could be executed in an Odoo Cron task to be scheduled and executed. You could find the Odoo Crons Menu in the Settings/Technical/Automation/Scheduled Actions menu when you activate the Odoo developer mode.

Also there are some modules to allow you to directly connect to external db source like MSSQL Server so you could directly interact with your main DB.

https://github.com/OCA/server-tools/tree/10.0/base_external_dbsource

https://github.com/OCA/server-tools/tree/10.0/base_external_dbsource_mssql

Of course all of this will require a little deep knowledge of Odoo internals to be able to get that running.

Upvotes: 1

Related Questions