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

Server error when merging partner if an abstract model has a reference field in the registry #21137

Closed
Creamaster opened this issue Nov 22, 2017 · 4 comments
Labels
10.0 Confirmed the bug was confirmed by testers Framework General frontend/backend framework issues

Comments

@Creamaster
Copy link

Impacted versions: v10

Steps to reproduce:
have an abstract model with a reference field

Current behavior:
SQL exception (search on non existing table due to the abstract nature of the model)

Expected behavior:
No error ?!

Video/Screenshot:
error merge

I could create a merge request but I want some kind of validation on this issue

Analyze
the method _update_reference_fields (click to follow)
search all the reference fields

records = self.env['ir.model.fields'].search([('ttype', '=', 'reference')])

and try to search on the model containing the field:

records_ref = Model.sudo().search([(record.name, '=', 'res.partner,%d' % partner.id)])
values = {
    record.name: 'res.partner,%d' % dst_partner.id,
}

But, as the model containing the reference field is an abstract model, the table does not exist, illustration for my custom code:

SELECT "activity_rule_execution".id FROM "activity_rule_execution" WHERE ("activity_rule_execution"."trigger_id" = "res.partner,41") ORDER BY "activity_rule_execution"."id"

ERROR: relation "activity_rule_execution" does not exist

fix/proposition
test if the model has a table

for partner in src_partners:
    **if Model._table:**
        records_ref = Model.sudo().search([(record.name, '=', 'res.partner,%d' % partner.id)])
        values = {
           record.name: 'res.partner,%d' % dst_partner.id,
        }
     records_ref.sudo().write(values)

Thank you for having taken the time to read

@Yenthe666 Yenthe666 added 10.0 Framework General frontend/backend framework issues labels Nov 22, 2017
@Elkasitu
Copy link
Contributor

Hi @Creamaster I cannot confirm your issue as your steps to reproduce are a bit vague, you can try reproducing it on the runbot or clarifying the steps to reproduce (http://runbot.odoo.com/runbot)

You're free to create a PR nevertheless, the fix seems okay to me, I'd probably change if Model._table to if Model._abstract.

Also, unless I'm missing something, there's no need to do the check inside the loop

@Creamaster
Copy link
Author

Hi @Elkasitu,

There is indeed no need to test inside the loop.

Regarding the attribute to use, I'm not sure, but, is it possible to tweek the method auto_init to obtain a regular model without a table, or an abstract model with a table ?

It's hard to reproduce the error from the UI. But from inside Odoo, there are tree steps

  1. Create an abstract model
  2. Add a reference field on this model
  3. And, of course, merge some res.partner

I will try to find an abstract model on the runbot, adding some x_field (type Reference) via the UI

@Elkasitu
Copy link
Contributor

@Creamaster I've confirmed the issue, you can make the PR 👍

@C3POdoo
Copy link
Contributor

C3POdoo commented Mar 30, 2023

Dear @Creamaster,

Thank you for your report but we are closing it due to inactivity.
We apology if we could not look at your request in time.
If your report still makes sense, don't hesitate to reopen a new one. We will try to check it as soon as possible.

This is an automated message.

@C3POdoo C3POdoo closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.0 Confirmed the bug was confirmed by testers Framework General frontend/backend framework issues
Projects
None yet
Development

No branches or pull requests

4 participants