Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant default on warnings on models implementing resource_mixin #311

Open
robinkeunen opened this issue Jan 26, 2024 · 1 comment
Open
Assignees

Comments

@robinkeunen
Copy link
Member

robinkeunen commented Jan 26, 2024

class ResourceMixin(models.AbstractModel):
_inherit = "resource.mixin"
# make this field read-only.
resource_calendar_id = fields.Many2one("resource.calendar", readonly=True)

This line has the side effect of issuing a warning for all models that inherit this mixin and set defaults to resource_calendar_id

2024-01-26 15:09:10,166 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.resource.calendar_id 
2024-01-26 15:09:10,170 69244 WARNING sixteen-odoo odoo.fields: Redundant default on hr.employee.resource_calendar_id 
2024-01-26 15:09:10,175 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.mixin.resource_calendar_id 
2024-01-26 15:09:10,362 69244 INFO sixteen-odoo odoo.modules.loading: loading spreadsheet_dashboard_hr_timesheet/data/dashboards.xml 
2024-01-26 15:09:10,555 69244 INFO sixteen-odoo odoo.modules.loading: Module spreadsheet_dashboard_hr_timesheet loaded in 0.52s, 26 queries (+26 other) 
2024-01-26 15:09:10,555 69244 INFO sixteen-odoo odoo.modules.loading: Loading module sale_management (54/62) 
2024-01-26 15:09:10,726 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.resource.calendar_id 
2024-01-26 15:09:10,730 69244 WARNING sixteen-odoo odoo.fields: Redundant default on hr.employee.resource_calendar_id 
2024-01-26 15:09:10,736 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.mixin.resource_calendar_id 
2024-01-26 15:09:11,037 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.resource.calendar_id 
2024-01-26 15:09:11,038 69244 WARNING sixteen-odoo odoo.fields: Redundant default on hr.employee.resource_calendar_id 
2024-01-26 15:09:11,102 69244 WARNING sixteen-odoo odoo.fields: Redundant default on resource.mixin.resource_calendar_id 
... and more

More information on the warning :

  # A readonly related field without an inverse method should not have a
  # default value, as it does not make sense.
  if self.default and self.readonly and not self.inverse:
      _logger.warning("Redundant default on %s", self)
@robinkeunen
Copy link
Member Author

From the readme :

This module also makes the working hours (resource calendar) of an employee always equal to the company’s working hours, and hides its field on the employee form view.

c’est donc pour éviter qu’on puisse le changer, sinon ça casse le fonctionnement du module. mais comme il est caché et que read-only est que pour les vues, on s’en fout en fait. ça date de mes débuts dans odoo, je pensais peut-être encore que read-only empêchait de le changer même en script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants