Odoo Help

2

how to create a 'project' on action, conditionally?

By
remi mores
on 7/12/13, 8:11 AM 1,418 views

Hi, i'm trying to extend the workflow of sale.order.basic to create a project when a sales order was confirmed.

class sale_order(osv.osv):
    _name = 'sale.order'
    _inherit = 'sale.order'
    _columns = {
        'customfield': fields.boolean('my custom field'),
    }

    def action_project_create(self,cr,uid,ids,context=None):
        project_project = self.pool.get('project.project')
        vals = {}
        project = project_project.create(cr,uid,vals,context=context)
        if(project == None):
            raise Exception('Create project failed!')   
        else:
            raise Exception('Create project failed!')

sale_order()

But i'm struggling with the call to create a new project. Each time i confirm the sales order, i get a dialog with the following error:


Integrity Error The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set [object with reference: alias_model_id - alias.model.id]


I know i will have to adjust the call to 'create', but my question is: how?

did you ever figure this out. I'm looking for the exact same solution! thanks!

Andrew
on 10/31/14, 4:52 PM
0
Ludo - Neobis
On 11/3/14, 6:26 AM

If you create an object from another object within Odoo, note that the mandatory fields that do not have default values on the object to be created are supplied. In the case of project, a name field is mandatory, but has no default (logically). You will need to manually supply these.

In the above case, vals is just an empty dictionary.

The alias_id in this case might be a relation to the project from an analytic account, but I'm not quite sure about that.

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 7/12/13, 8:11 AM
Seen: 1418 times
Last updated: 3/16/15, 8:10 AM