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.

2

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

By
remi mores
on 7/12/13, 8:11 AM 1,090 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

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

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.

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

2 follower(s)

Stats

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