Skip to content

[BUG] l10n_it_riba_oca: RiBa collection fees setting not persisted in multi-company #5211

@mmircoli-nexapp

Description

@mmircoli-nexapp

Module

l10n_it_riba_oca

Current behavior

When configuring the RiBa collection fees service product (due_cost_service_id) in Settings → Accounting → RiBa Collection Fees in a multi-company environment, the setting does not persist correctly.

The value shown in the settings form always reflects the user's main company (self.env.user.company_id), not the company currently selected in the settings form.

Steps to reproduce

  1. Have a multi-company setup (Company A, Company B)
  2. Log in as a user whose main company is Company A
  3. Switch to Company B in the settings
  4. Set a product for "RiBa Collection Fees" → Save
  5. Reopen settings for Company B → the value shows Company A's setting (or blank)

Root cause

The default_get override in ResConfigSettings (models/account_config.py) hardcodes self.env.user.company_id.due_cost_service_id:

@api.model
def default_get(self, fields_list):
    res = super().default_get(fields_list)
    if res:
        res["due_cost_service_id"] = self.env.user.company_id.due_cost_service_id.id
    return res

This ignores the company_id field on the settings form (which reflects the company being configured). The related="company_id.due_cost_service_id" field already handles reading/writing to the correct company — the default_get override is a legacy pattern that conflicts with this mechanism.

Expected behavior

The setting should correctly read from and write to the company selected in the settings form, working seamlessly in multi-company environments.

Proposed fix

Remove the default_get override entirely. The related field handles everything correctly on its own.

Version

18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions