2

My Odoo 11 system already has records created by users. When I create a new function to add new features to odoo application, the function only applies to new records created after the existence of the new function. To apply it to existing records, I must edit each old record,change the value of one the fields used by the function, and save.

My question: is there a way for a new function created in the python source to apply to all records automatically without needing to edit and save each old record?

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Maurice
  • 21
  • 2
  • I think for the first time it will do like you said i.e. will edit and save the old records too, but next time you it will apply to all records. – Adam Strauss Dec 18 '19 at 05:17

1 Answers1

0

You can just use ODOO (API) a simple script that do this can do the trick :

  1. connect to your server.
  2. search for all records.
  3. call the method for those IDs.

Get all the IDs of you database:

  ids  = models.execute_kw(db, uid, password, 'your.model.name', 'search',[[]])

Then call that method:

   models.execute_kw(db, uid, password, 'your.model.name', 'your_method_name', [ids])
Charif DZ
  • 14,415
  • 3
  • 21
  • 40