How to Safely Replace the Direct Print API Key Without Losing Settings
When replacing the Direct Print API key, you should not manually paste the new key into the Direct Print settings in Odoo. Doing so may reset existing printers, print rules, default printers, and other printing settings.
Follow the steps below to update the API key while preserving your existing Direct Print configuration.
Step 1: Generate a New API Key
Sign in to the Direct Print portal and open Account → Credentials:
https://print.ventor.tech/profile/credentials
In the API key section, click Issue a new key anyway and copy the newly generated API key.
Step 2: Create a Scheduled Action in Odoo
First, enable Developer Mode in Odoo:
- Open Settings.
- Scroll down to Developer Tools.
- Click Activate the developer mode.
Alternatively, add ?debug=1 to your Odoo URL and reload the page.
Then go to Settings → Technical → Scheduled Actions and create a new Scheduled Action.
Configure it as follows:
- Model: Direct Print Account
- Action: Execute Code
- Active: Disabled
Depending on your Odoo version, Direct Print Account may not appear immediately in the Model dropdown. If you cannot find it:
- Click Search More in the Model dropdown.
- Search for Direct Print Account.
- If necessary, search by the technical model name
printnode.account. - Select Direct Print Account from the search results.
Important: Make sure the Scheduled Action is not active before saving it. It should only be executed manually.
Add the following Python code:
NEW_KEY = '<new key>'
account = env['printnode.account'].sudo().get_main_printnode_account()
env.cr.execute(
'UPDATE printnode_account SET api_key = %s WHERE id = %s',
(NEW_KEY, account.id),
)Replace <new key> with the API key generated in Step 1.
Step 3: Update the API Key
Click Run Manually to execute the Scheduled Action.
The API key should now be updated for the existing Direct Print account without recreating it or resetting your printing configuration.
After the update:
- Open the Direct Print settings and verify that the connection is active.
- Check that your existing printers are still available.
- Pay particular attention to your Report Settings / Print Rules and verify that the existing printing routes are unchanged.
- Run a test print to confirm that printing works correctly.
Once you have confirmed that the new API key works and all settings are preserved, delete the Scheduled Action.
This also removes the new API key from the Scheduled Action code.