Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
157 Vizualizări

Hello everyone,


I am trying to inherit the followup_reminder_type field into my module in Odoo 18(odoo.sh). The field is located in the Contacts app in the Accounting tab, in the Reminders field, when a contact has been selected.


The code I have inserted:

from odoo import api, fields, models, _


class Partner(models.Model):

    _inherit = "res.partner"

    followup_reminder_type = fields.Selection(

        [

            ('automatic', 'Automatik'),

            ('auto', 'Automatik'),

            ('manual', 'Manuell')],

        string='Reminders',

        default='manual'

    ) 

I would like to change the default selection from automatic to manual. I would also like to know in which module the code for the field is stored. I created the code I inserted myself and did not copy it from any module.

Thank you in advance.

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

If you just want to change the default value to "manual", you don’t need to redefine the field completely. 

Example:

 from odoo import models, fields

class Partner(models.Model):

    _inherit = "res.partner"


    followup_reminder_type = fields.Selection(

        selection_add=[],

        default='manual',

    )



Hope it helps.

Imagine profil
Abandonează
Cel mai bun răspuns

Hello Martin,



  To change the default selection of the followup_reminder_type field from 'automatic' to 'manual' in your custom module, your approach is correct. However, ensure your module is properly installed or upgraded after making changes. Here's a step-by-step guide to troubleshoot and ensure your changes take effect:

  1. Verify that your custom module is correctly installed in your Odoo instance. If not, install it through the Apps menu.

  2. If your module is already installed, you may need to upgrade it for changes to take effect. Go to Apps > Update Apps List, then upgrade your custom module.

  3. Ensure there are no other modules that inherit and modify the followup_reminder_type field which might be overriding your default value. This can be checked by looking into the Odoo app dependencies and the inheritance chain.

  4. If the issue persists, consider checking the server logs for any errors related to the field definition or inheritance issues that might hint at what's going wrong.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

Imagine profil
Abandonează
Autor

Sorry,

it works, but I get this message:

2025-09-24 10:52:27,086 1347 WARNING opalsoluti-master-db-odoo18-1-testupgrade-fehlerbeh-23805500 odoo.fields: res.partner.followup_reminder_type: selection=[('automatic', 'Automatic'), ('manual', 'Manual')] overrides existing selection; use selection_add instead

How can I fix it?

Hello Martin,
The warning appears because you're replacing the entire field instead of just modifying it. Here's the simple fix:
Replace your current code with this:
pythonfrom odoo import api, fields, models, _

class Partner(models.Model):
_inherit = "res.partner"

followup_reminder_type = fields.Selection(
selection_add=[],
default='manual'
)
What this does:

selection_add=[] tells Odoo you're not adding new options, just modifying the existing field
default='manual' changes the default selection to manual
No more warning message!

Don't forget to:

Upgrade your module after making this change
The original field is in the account_followup module.

Hope this will Help!!

Autor

Hi, After the last change you sent me, I now get an bug:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/service/server.py", line 1361, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/tools/func.py", line 97, in locked
return func(inst, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 129, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 485, in load_modules
processed_modules += load_marked_modules(env, graph,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 365, in load_marked_modules
loaded, processed = load_module_graph(
^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 205, in load_module_graph
registry.setup_models(env.cr)
File "/usr/lib/python3/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/tools/func.py", line 97, in locked
return func(inst, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 355, in setup_models
model._setup_fields()
File "/home/odoo/src/odoo/odoo/models.py", line 3719, in _setup_fields
field.setup(self)
File "/home/odoo/src/odoo/odoo/fields.py", line 539, in setup
self.setup_nonrelated(model)
File "/home/odoo/src/odoo/odoo/fields.py", line 2843, in setup_nonrelated
assert self.selection is not None, "Field %s without selection" % self
^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Field res.partner.followup_reminder_type without selection

Thanks for your help.

Related Posts Răspunsuri Vizualizări Activitate
2
sept. 25
371
1
sept. 25
234
3
sept. 25
424
1
sept. 25
429
2
aug. 25
602