[IMP] website_quote: quote templates are now archivable

We also:
- reorder a bit the form view for quote templates
- change the way default templates are selected for sales order
  (inactive quote templates are not selected) while keeping
  customizability through ir.values
This commit is contained in:
dip-odoo
2017-08-04 14:58:03 +02:00
committed by Richard Mathot
parent 65e810269a
commit 9dafd7f47e
4 changed files with 24 additions and 8 deletions
@@ -91,11 +91,7 @@
</section>
</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>
+6 -1
View File
@@ -47,10 +47,15 @@ class SaleOrderLine(models.Model):
class SaleOrder(models.Model):
_inherit = 'sale.order'
def _get_default_template(self):
template = self.env.ref('website_quote.website_quote_template_default', raise_if_not_found=False)
return template and template.active and template or False
template_id = fields.Many2one(
'sale.quote.template', 'Quotation Template',
readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
default=_get_default_template)
website_description = fields.Html('Description', sanitize_attributes=False, translate=html_translate)
options = fields.One2many(
'sale.order.option', 'order_id', 'Optional Products Lines',
+2 -1
View File
@@ -26,7 +26,8 @@ class SaleQuoteTemplate(models.Model):
'mail.template', 'Confirmation Mail',
domain=[('model', '=', 'sale.order')],
help="This e-mail template will be sent on confirmation. Leave empty to send nothing.")
active = fields.Boolean(default=True, help="If unchecked, it will allow you to hide the quotation template without removing it.")
@api.multi
def open_template(self):
self.ensure_one()
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_sale_quote_template_search" model="ir.ui.view">
<field name="name">sale.quote.template.search</field>
<field name="model">sale.quote.template</field>
<field name="arch" type="xml">
<search string="Search Quotation Template">
<filter string="Archived" name="inactive" domain="[('active','=', False)]"/>
</search>
</field>
</record>
<record model="ir.ui.view" id="view_sale_quote_template_form">
<field name="name">sale.quote.template.form</field>
<field name="model">sale.quote.template</field>
@@ -7,7 +16,12 @@
<field name="arch" type="xml">
<form string="Sale Quotation Template">
<sheet>
<button string="Edit Template" type="object" name="open_template" class="oe_highlight oe_right"/>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
<button string="Edit Template" type="object" name="open_template" class="oe_stat_button" icon="fa-pencil"/>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1>