This question has been flagged
2 Replies
1130 Views

When my Opportunity goes from the stage new to qualified, I need odoo to create a project containing certain tasks following a given template. 

For that I tried to create a product "Project creation", which is a service and whose sale should create a project following my template. Therefore, the stage change on my opportunity should create a sale order, on which a quotation template is defined and for which the customer is the same as the opportunity's customer. 

This is where I have a problem, if i try to set sale_order.partner_id = record.partner_id.  I get this error : 

psycopg2.ProgrammingError: can't adapt type 'res.partner' 

If I do not set this line, I also get an error as a sale cannot be created without a customer. 


Where does this error come from ? Is there another way to do this ? 

Avatar
Discard
Author Best Answer

The inital problem with the customer was solved. 

However, now my quotation is well created, and the quotation template is well saved. But it does not have any effect on my order lines (The product in the template is not added on the sale order). And my project is therefore not created like it should. How can I automatically sell this product ? 

Avatar
Discard
Author

To solve this problem, I created an automated action that creates an order line with the product.produt ID of the item I wanted to sale on my sale order and I set the Order as record.id. This completes my sale order and validate it automatically and creates the project.

The last step was to add a related field on the project that takes the opportunity set on the sale order that was created automatically. And then create a smart button on the opportunity to connect it with this field.

Author

I also created a filter to avoid having these empty sale orders in my sale order list view

Best Answer

instead sale_order.partner_id = record.partner_id 

try to set sale_order.partner_id.id= record.partner_id.id

Avatar
Discard