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.

image-20260828-091453.png

Step 2: Create a Scheduled Action in Odoo

First, enable Developer Mode in Odoo:

  1. Open Settings.
  2. Scroll down to Developer Tools.
  3. 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:

  1. Click Search More in the Model dropdown.
  2. Search for Direct Print Account.
  3. If necessary, search by the technical model name printnode.account.
  4. Select Direct Print Account from the search results.
Screenshot 2026-09-07 at 23.28.51.png

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.

Screenshot 2026-08-28 at 12.46.46.png

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:

  1. Open the Direct Print settings and verify that the connection is active.
  2. Check that your existing printers are still available.
  3. Pay particular attention to your Report Settings / Print Rules and verify that the existing printing routes are unchanged.
  4. 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.