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

Many2One relationships from non-transient Model to TransientModel are forbidden

By
Lebanonsky
on 1/29/14, 5:35 AM 2,400 views

I am developing a custom module that adds a team of users to task. I've based my code on project.task.work model.

Here is my code for the team:

class paga_task_team(osv.Model):
    _name = 'paga_task_team'

    _columns = {
        'paga_task_id': fields.many2one('project.task', string="Task", ondelete="set null", select="1"),
        'paga_user_id': fields.many2one('res.users','User', required=True),
        'paga_booking': fields.selection(
            (('OK','OK'),
            ('UN','Pending'),
            ('NO','Declined')),
            'Booking'),
        'paga_mail': fields.boolean('Mail?'),
        'paga_sms': fields.boolean('SMS?'),
    }

    _default = {
        'paga_booking': 'UN',
        'paga_mail': False,
        'paga_sms': False,
        }

paga_task_team()

And this parts extends the project.task

class paga_task_booking(osv.Model):

    _name = "project.task"
    _inherit = ["project.task", "mail.compose.message"]

    _columns = {
        'date_deadline': fields.datetime('Deadline',select=True),
        'paga_task_duration': fields.float('Duration'),
        'paga_team_size': fields.integer('Team Size'),
        'paga_team_ids': fields.one2many('paga_task_team','paga_task_id','Team', 
        states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
    }

paga_task_booking()

These codes only works if I make paga_task_team into a TransientModel, but then the datas are not saved permanently. If it is cvs.Model I get the error "Many2One relationships from non-transient Model to TransientModel are forbidden". I cannot see what is wrong, since this should be quite simple structure...

in both models you need to have a name field or provide something like for eg:

_rec_name ='date_deadline'

Subhin P V
on 1/29/14, 7:02 AM

I added a field called 'name' to paga_task_team -model, but it does not change the error. I assume project.task has a name field already. Also tried with _rec_name.

Lebanonsky
on 1/29/14, 7:11 AM

I hope someone will be able to help me with this - I have been banging my head into it for a month and running out of ideas. Any additional information will provided if needed!

Lebanonsky
on 1/30/14, 6:42 AM

I think that you will have to put osv.memory instead of osv.model.

Krupesh Laiya
on 1/31/14, 1:50 AM
0
Lebanonsky
On 1/30/14, 1:47 PM

Resolved my own problem, which was the inherited TransitionModel "mail.compose.message" apparently the model type was also inherited. Removed the mail wizard model and it works.

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: 1/29/14, 5:35 AM
Seen: 2400 times
Last updated: 3/16/15, 8:10 AM