[IMP] website_quote: define default order quote template coming in settings
Using a real ir.values default that user can customize in settings is better for user experience than an hardcoded template using an xml_id. Betcha.
This commit is contained in:
@@ -92,6 +92,10 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<function id="ir_values_set_sale_order_default_template_id"
|
||||
model="ir.values" name="set_default"
|
||||
eval="('sale.order', 'template_id', ref('website_quote_template_default'))"/>
|
||||
|
||||
<record id="confirmation_mail" model="mail.template">
|
||||
<field name="name">Online Quote: confirmation e-mail</field>
|
||||
<field name="email_from">${(object.user_id.email or object.company_id.email or 'noreply@localhost')|safe}</field>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import sale_order
|
||||
from . import sale_quote
|
||||
from . import product_template
|
||||
from .import sale_order
|
||||
from .import sale_quote
|
||||
from .import product_template
|
||||
from .import sale_config_settings
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleConfiguration(models.TransientModel):
|
||||
_inherit = 'sale.config.settings'
|
||||
|
||||
default_template_id = fields.Many2one('sale.quote.template', default_model='sale.order', string='Default Template')
|
||||
@@ -52,15 +52,12 @@ class SaleOrder(models.Model):
|
||||
if so.state not in ['sale', 'done']:
|
||||
so.website_url = '/quote/%s' % (so.id)
|
||||
|
||||
def _get_default_template_id(self):
|
||||
return self.env.ref('website_quote.website_quote_template_default', raise_if_not_found=False)
|
||||
|
||||
access_token = fields.Char(
|
||||
'Security Token', copy=False, default=lambda self: str(uuid.uuid4()),
|
||||
required=True)
|
||||
template_id = fields.Many2one(
|
||||
'sale.quote.template', 'Quotation Template',
|
||||
default=_get_default_template_id, readonly=True,
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
|
||||
website_description = fields.Html('Description', sanitize_attributes=False, translate=html_translate)
|
||||
options = fields.One2many(
|
||||
|
||||
@@ -22,7 +22,9 @@ class SaleQuoteTemplate(models.Model):
|
||||
(1, 'Immediate after website order validation'),
|
||||
(2, 'Immediate after website order validation and save a token'),
|
||||
], 'Payment', help="Require immediate payment by the customer when validating the order from the website quote")
|
||||
mail_template_id = fields.Many2one('mail.template', 'Confirmation Mail',
|
||||
mail_template_id = fields.Many2one(
|
||||
'mail.template', 'Confirmation Mail',
|
||||
domain=[('model', '=', 'sale.order')],
|
||||
help="This e-mail template will be sent on confirmation. Leave empty to send nothing.")
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
<odoo>
|
||||
|
||||
<record id="sale_config_settings_view_form_inherit_website_quote" model="ir.ui.view">
|
||||
<field name="name">sale.config.settings.inherit.website.quote</field>
|
||||
<field name="name">sale.config.settings.view.form.inherit.website.quote</field>
|
||||
<field name="model">sale.config.settings</field>
|
||||
<field name="inherit_id" ref="sale.sale_config_settings_view_form_inherit_sale"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='website_quote']" position="replace">
|
||||
<div class="mt16" attrs="{'invisible': [('module_website_quote','=',False)]}">
|
||||
<label for="default_template_id" class="o_light_label"/>
|
||||
<field name="default_template_id" class="oe_inline"/>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('module_website_quote','=',False)]}">
|
||||
<button name="%(website_quote.action_sale_quotation_template)d" icon="fa-arrow-right" type="action" string="Quotation Templates" class="btn-link"/>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('module_website_quote','=',False)]}">
|
||||
|
||||
Reference in New Issue
Block a user