Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

what happens to relations when objects are archived

By
Alexander Soare
on 8/12/16, 9:54 AM 200 views

odoo 9.0

The setup:

I have two records in res.partner C and E. For context C is a company and E is an employee.

Record C has a many2many relation to record E called x_employee_ids. E reciprocates this relation with x_company_ids.

I have a functionality which allows me to archive record C and have E archived along with it automatically (if and only if no other relations to E exist elsewhere in res.partner). This works by checking C's field x_employee_ids and archiving what is found there.

What I want to achieve:

I want to make it possible to do the opposite. If I unarchive C I want E to also be unarchived.

The problem:

When E is archived it doesn't show up when checking the field x_employee_ids in C. So even when I unarchive C I can't see the relationship. I would assume that the relationship is deleted but I have demonstrated that it is not.

Knowing who E is during testing, I can unarchive E myself. When I do this it reappears in the x_employee_ids field of C. So this means that Odoo stores the relationship somewhere. But where? If I know where I can make my unarchive functionality work.

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 8/13/16, 3:11 AM

Hi,

If I got you well. I think to add your archive functionality by overriding the write method of the model of 'x_employee_ids'.

you can check the vals variable in the write signature if it contains the key 'active' , since the archiving update this field 'active' to be false. 

Hope this could helps ...

I'm not sure this answers my question. When I archive C at the start, I lose the foreign key to E, so from this point on I've effectively lost E unless I can find the relationship stored elsewhere.

Alexander Soare
on 8/16/16, 5:22 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/12/16, 9:54 AM
Seen: 200 times
Last updated: 8/13/16, 3:11 AM