Skip to Content
Menu
This question has been flagged
2 Replies
1625 Views

odoo version 16.

How can I AUTO CONFIRM quotations if the Tab quotation:

Other info > Tracking > Source Document (field: origin) have the string "auto_confirm"?


I try to create an Automate Actions with the next values:

Model: Quotation Template

Trigger: On 

Creation Apply on: all records
Action To Do: Execute Python CodePython 

Code: /ORIGIN = 'auto_confirm'if record.origin: record['origin'] = ORIGIN self.action_confirm()



Thanks! 

Avatar
Discard
Best Answer

Hello Jhon,

Try this:


Avatar
Discard
Author Best Answer

Hi Julien,

please, how you get 3 records on the option "Apply on"?

I click on button "EDIT DOMAIN" and write:

# Code editor
[("source_id", "=", "auto_confirm")]

But appears "0 RECORD(S)" and doesn't work.

thanks a lot!

Avatar
Discard

The number of records vary as you might be on different databases.

Also, you might need the model to be sale order if you want to confirm a quotation to an order and maybe try 'contains' rather than '='

Author

Hi Jaideep,
thanks, now I understand how works the domains button. But I doesn't work for quotation.
I am flexible, for example I can use other file like:
"Sale Team",
"Sale Person",
"Customer Reference"
etc...
but also doesn't work.
The quotations options oly there for "Template" and not for "New Quotation", here is my problem.
thanks somuch.

Please let me know if you can find some solution for new quotation.
Regards.

The model you need to select is 'Sale Order' and you would be all set.

Quotation and sale order are the same, quotation template is a different model which you can navigate from Sales > Configuration > Quotation Templates

Hey Jhon,

I edited my answer for the quotation case.

Author

Hi Julien,
I am using Odoo 16, then like you can see, I haven't the option "Sale order". I have:
"Sale order line "
see the pictures:
https://prnt.sc/7rBHf-Hto47q
https://prnt.sc/los2DJX5gdda

Also I can't find "Source" (notice the file name is "origin") in the button "EDIT DOMAIN", please share your code to paste here:
https://prnt.sc/jjYHnngOwWdT

However, for testing, I save the Action without any domain filter, and after try to create and save the Quotation the status don't change:
https://prnt.sc/1bkgRbTPMYj5

Thanks Julien and Jaideep.

sale.order 2nd option in your screenshot.

Post selecting the model, click 'Edit Domain' followed by '+Add Filter' button to select source_id

Author

you are true, now works, and the Order are created :)
But for some reason, now the Quantity on Hand of my items doesn't decrease.
Looks my postman error mesage (if I delete the action is working with 200 OK):

{
"success": false,
"message": "ERROR: UserError('No rule has been found to replenish \"[FURN_8888] Office Lamp\" in \"Physical Locations/Transit between warehouses\".\\nVerify the routes configuration on the product.') {}",
"responseCode": 500,
"object_name": "sale.order",
"permisssions": {
"read": true,
"write": true,
"delete": true,
"create": true
},
"model_id": 697
}

Postman:
https://prnt.sc/SblyBW-8zq8F
https://prnt.sc/PJ-_gAHLW1gz

Quotation created right:
https://prnt.sc/aH1fTYePFBUb

Quantity on Hand doesn't decrease:
https://prnt.sc/RDaNHLqf78KY

Thanks!

Qty on hand would reduce only when you deliver the product .. interestingly this sale order did not create a delivery order!

Would you be able to create another sale order with the same product manually (without triggering the automated action i.e keeping the source_id field empty perhaps) to check if a delivery order is created?

Also, there is a field 'Sale Workflow', I don't believe this is on the base sale order. Would you know if this is something you need to provide as the error is pointing Inter warehouse transit location

Author

Works!
Video to Auto Confirm Quotation:
https://youtu.be/VmaQ43vgZFI

yes Jaideep, you right.
Here is the resume:
In Automated Action use "Salesperson" insted Source. I create a user with the ID 6 and EDIT DOMAIN with this code:
# Code editor
[("user_id", "=", "Magento")]

Using the Julien executed Python:
record.action_confirm()

Without this Code The order never are confirmed, also the workflow addons is not working.

After with the paid addon: sh_sale_auto_invoice_workflow
In postman I setup the field to do process automatic the workflow AFTER confirm quotation:
"workflow_id":1,

This scenario allow the team staff do manually Quotation and the API websites process automated and discount the stock, it's just I need.

API Postman:
{
"partner_id": 10,
"user_id":6,
"workflow_id":1,
"order_line":[
[0,0,{"product_id":6, "product_uom_qty":1}],
[0,0, {"product_id":7, "product_uom_qty":1}]
]}

Deeply thanks Jaideep and Julien.