[FIX] sale_management: ignore quotation template on eCommerce sales

Quotation templates feature simplifies creating Sale Order on backend.
To make the process even faster, Odoo allows set up Default Quotation Template,
which is applied automatically on every new quotation. However, it doesn't make
sense to apply quotation templates for orders created by eCommerce users.
Particularly, it leads to an error if quotation template has recurrence.

Fix by ignoring default quotation template on eCommerce sale orders.

STEPS

1. Create a sale template with a recurrence
2. Set this sale template as the default sale template in settings
3. Go to /shop page and add any product to cart that is not recurring
-> The sales order will be created with the default template's recurrence
4. Try to pay & confirm the order
-> Error when trying to make an order with recurrence and no recurring product

opw-3115232

closes odoo/odoo#116913

X-original-commit: 1d083cad6fe9a5e2356e53ac922c8ff9e75d52f6
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
This commit is contained in:
Ivan Yelizariev
2023-03-30 10:53:56 +02:00
parent 52a02c81fc
commit 81ec49ef38
@@ -34,6 +34,9 @@ class SaleOrder(models.Model):
for order in self:
company_template = order.company_id.sale_order_template_id
if company_template and order.sale_order_template_id != company_template:
if 'website_id' in self._fields and order.website_id:
# don't apply quotation template for order created via eCommerce
continue
order.sale_order_template_id = order.company_id.sale_order_template_id.id
@api.depends('partner_id', 'sale_order_template_id')