[IMP][REF] website_customer, website_event, website_livechat, website_sale_delivery,
website_slides: use the recently introduced website.published.mixin to replace the website_published and website_url fields defined in various remaining modules. In slides, some templates have been updated because share_url was basically website_url and has been replaced.
This commit is contained in:
@@ -14,6 +14,7 @@ class res_partner(osv.Model):
|
||||
class res_partner_tags(osv.Model):
|
||||
_description = 'Partner Tags - These tags can be used on website to find customers by sector, or ... '
|
||||
_name = 'res.partner.tag'
|
||||
_inherit = 'website.published.mixin'
|
||||
|
||||
def get_selection_class(self, cr, uid, context=None):
|
||||
classname = ['default', 'primary', 'success', 'warning', 'danger']
|
||||
@@ -23,7 +24,6 @@ class res_partner_tags(osv.Model):
|
||||
'name': fields.char('Category Name', required=True, translate=True),
|
||||
'partner_ids': fields.many2many('res.partner', 'res_partner_res_partner_tag_rel', id1='tag_id', id2='partner_id', string='Partners'),
|
||||
'classname': fields.selection(get_selection_class, 'Class', help="Bootstrap class to customize the color of the tag", required=True),
|
||||
'website_published': fields.boolean('Publish', help="The publish field allows you to show the tag on website."),
|
||||
'active': fields.boolean('Active'),
|
||||
}
|
||||
_defaults = {
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
|
||||
# from openerp.osv import osv, fields
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.models import NewId
|
||||
|
||||
# from openerp.tools.translate import _
|
||||
import re
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.addons.website.models.website import slug
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ from openerp import models, fields
|
||||
|
||||
|
||||
class im_livechat_channel(models.Model):
|
||||
_name = 'im_livechat.channel'
|
||||
_inherit = ['im_livechat.channel', 'website.published.mixin']
|
||||
|
||||
_inherit = 'im_livechat.channel'
|
||||
|
||||
website_published = fields.Boolean("Website published", default=False, help="If checked, the channel and its ratings will be display on your website")
|
||||
website_description = fields.Html("Website description", default=False, help="Description of the channel displayed on the website page")
|
||||
|
||||
@@ -6,9 +6,10 @@ from openerp.addons import decimal_precision
|
||||
|
||||
|
||||
class delivery_carrier(orm.Model):
|
||||
_inherit = 'delivery.carrier'
|
||||
_name = 'delivery.carrier'
|
||||
_inherit = ['delivery.carrier', 'website.published.mixin']
|
||||
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website', copy=False),
|
||||
'website_description': fields.text('Description for the website'),
|
||||
}
|
||||
_defaults = {
|
||||
|
||||
@@ -260,7 +260,7 @@ class website_slides(http.Controller):
|
||||
return {
|
||||
'img_src': '/website/image/slide.slide/%s/image_thumb' % (slide.id),
|
||||
'caption': slide.name,
|
||||
'url': slide.share_url
|
||||
'url': slide.website_url
|
||||
}
|
||||
vals = map(slide_mapped_dict, slide.get_related_slides(slides_to_suggest))
|
||||
add_more_slide = slides_to_suggest - len(vals)
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td style="width: 600px; vertical-align:top; text-align:center; background-color:#FFFFF; color:#414141">
|
||||
<a href="${object.share_url}" style="color: #a24689;">
|
||||
<a href="${object.website_url}" style="color: #a24689;">
|
||||
<img alt="${object.name}" src="${ctx['base_url']}/website/image/slide.slide/${object.id}/image" style="height:auto; width:500px; background-color: #cccccc; margin: 16px;">
|
||||
</a>
|
||||
<p style="font-size:24px; font-weight:bold"><a href="${object.share_url}">${object.name}</a></p>
|
||||
<p style="font-size:24px; font-weight:bold"><a href="${object.website_url}">${object.name}</a></p>
|
||||
<p style="color: #ccc;">Published on ${object.write_date}</p>
|
||||
<p><a href="${object.share_url}">Click here to open the ${object.slide_type}</a></p>
|
||||
<p><a href="${object.website_url}">Click here to open the ${object.slide_type}</a></p>
|
||||
</td>
|
||||
</tr></tbody>
|
||||
</table>
|
||||
@@ -56,7 +56,7 @@
|
||||
<table cellpadding="0" cellspacing="0" style="margin: 10px 0px 0px 0px; vertical-align: top;padding: 0px; font-family:arial; font-size:12px; color: #ffffff; background-color:#8f8f8f;">
|
||||
<tbody><tr>
|
||||
<td style="width: 600px; font-size:12px; text-align:center; padding-top:10px; color:#a24689; padding-bottom:5px">
|
||||
<a href="${object.share_url}" style="color:#a24689">View in browser</a> |
|
||||
<a href="${object.website_url}" style="color:#a24689">View in browser</a> |
|
||||
<a href="/page/contactus" style="color:#a24689">Contact</a>
|
||||
</td>
|
||||
</tr></tbody>
|
||||
@@ -93,13 +93,13 @@
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td style="width: 600px; vertical-align:top; text-align:center; background-color:#FFFFF; color:#414141">
|
||||
<a href="${object.share_url}" style="color: #a24689;">
|
||||
<a href="${object.website_url}" style="color: #a24689;">
|
||||
<img alt="${object.name}" src="${ctx['base_url']}/website/image/slide.slide/${object.id}/image"
|
||||
style="height:auto; width:500px; background-color: #cccccc; margin: 16px;">
|
||||
</a>
|
||||
<p style="font-size:24px; font-weight:bold"><a href="${object.share_url}">${object.name}</a></p>
|
||||
<p style="font-size:24px; font-weight:bold"><a href="${object.website_url}">${object.name}</a></p>
|
||||
<p style="color: #ccc;">Published on ${object.write_date}</p>
|
||||
<p><a href="${object.share_url}">Click here to open the ${object.slide_type}</a></p>
|
||||
<p><a href="${object.website_url}">Click here to open the ${object.slide_type}</a></p>
|
||||
</td>
|
||||
</tr></tbody>
|
||||
</table>
|
||||
@@ -108,7 +108,7 @@
|
||||
<table cellpadding="0" cellspacing="0" style="margin: 10px 0px 0px 0px; vertical-align: top;padding: 0px; font-family:arial; font-size:12px; color: #ffffff; background-color:#8f8f8f;">
|
||||
<tbody><tr>
|
||||
<td style="width: 600px; font-size:12px; text-align:center; padding-top:10px; color:#a24689; padding-bottom:5px">
|
||||
<a href="${object.share_url}" style="color:#a24689">View in browser</a> |
|
||||
<a href="${object.website_url}" style="color:#a24689">View in browser</a> |
|
||||
<a href="/page/contactus" style="color:#a24689">Contact</a>
|
||||
</td>
|
||||
</tr></tbody>
|
||||
|
||||
@@ -21,7 +21,7 @@ class Channel(models.Model):
|
||||
channels. """
|
||||
_name = 'slide.channel'
|
||||
_description = 'Channel for Slides'
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_inherit = ['mail.thread', 'website.seo.metadata', 'website.published.mixin']
|
||||
_order = 'sequence, id'
|
||||
_order_by_strategy = {
|
||||
'most_viewed': 'total_views desc',
|
||||
@@ -30,7 +30,6 @@ class Channel(models.Model):
|
||||
}
|
||||
|
||||
name = fields.Char('Name', translate=True, required=True)
|
||||
website_published = fields.Boolean('Published', help="Published on the website", copy=False)
|
||||
description = fields.Html('Description', translate=True)
|
||||
sequence = fields.Integer(default=10, help='Display order')
|
||||
category_ids = fields.One2many('slide.category', 'channel_id', string="Categories")
|
||||
@@ -115,6 +114,14 @@ class Channel(models.Model):
|
||||
self.can_see_full = self.visibility == 'public' or bool(self.group_ids & self.env.user.groups_id)
|
||||
self.can_upload = self.can_see and (not self.upload_group_ids or bool(self.upload_group_ids & self.env.user.groups_id))
|
||||
|
||||
@api.multi
|
||||
@api.depends('name')
|
||||
def _website_url(self, name, arg):
|
||||
res = super(Channel, self)._website_url(name, arg)
|
||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
res.update({(channel.id, '%s/slides/%s' % (base_url, slug(channel))) for channel in self})
|
||||
return res
|
||||
|
||||
@api.onchange('visibility')
|
||||
def change_visibility(self):
|
||||
if self.visibility == 'public':
|
||||
@@ -202,7 +209,7 @@ class Slide(models.Model):
|
||||
Slide has various statistics like view count, embed count, like, dislikes """
|
||||
|
||||
_name = 'slide.slide'
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_inherit = ['mail.thread', 'website.seo.metadata', 'website.published.mixin']
|
||||
_description = 'Slides'
|
||||
|
||||
_PROMOTIONAL_FIELDS = [
|
||||
@@ -267,7 +274,6 @@ class Slide(models.Model):
|
||||
setattr(self, key, value)
|
||||
|
||||
# website
|
||||
website_published = fields.Boolean('Published', help="Published on the website", copy=False)
|
||||
date_published = fields.Datetime('Publish Date')
|
||||
website_message_ids = fields.One2many(
|
||||
'mail.message', 'res_id',
|
||||
@@ -286,13 +292,6 @@ class Slide(models.Model):
|
||||
for record in self:
|
||||
record.total_views = record.slide_views + record.embed_views
|
||||
|
||||
share_url = fields.Char('Share URL', readonly=True, compute='_get_share_url')
|
||||
|
||||
def _get_share_url(self):
|
||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
for record in self:
|
||||
record.share_url = "%s/slides/slide/%s" % (base_url, slug(record))
|
||||
|
||||
embed_code = fields.Text('Embed Code', readonly=True, compute='_get_embed_code')
|
||||
|
||||
def _get_embed_code(self):
|
||||
@@ -310,6 +309,15 @@ class Slide(models.Model):
|
||||
else:
|
||||
record.embed_code = False
|
||||
|
||||
@api.multi
|
||||
@api.depends('name')
|
||||
def _website_url(self, name, arg):
|
||||
res = super(Slide, self)._website_url(name, arg)
|
||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
res.update({(slide.id, '%s/slides/slide/%s' % (base_url, slug(slide))) for slide in self})
|
||||
return res
|
||||
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if not values.get('index_content'):
|
||||
|
||||
@@ -27,16 +27,16 @@
|
||||
<!-- Tools template: share on social networkds -->
|
||||
<template id='slides_share' name="Slides Media Share">
|
||||
<div class="form-group">
|
||||
<a target="_Blank" t-attf-href="https://www.facebook.com/sharer/sharer.php?u=#{slide.share_url}">
|
||||
<a target="_Blank" t-attf-href="https://www.facebook.com/sharer/sharer.php?u=#{slide.website_url}">
|
||||
<i class="fa fa-facebook-square fa-2x"></i>
|
||||
</a>
|
||||
<a target="_Blank" t-attf-href="https://twitter.com/intent/tweet?text=#{slide.name}&url=#{slide.share_url}">
|
||||
<a target="_Blank" t-attf-href="https://twitter.com/intent/tweet?text=#{slide.name}&url=#{slide.website_url}">
|
||||
<i class="fa fa-twitter-square fa-2x"></i>
|
||||
</a>
|
||||
<a target="_Blank" t-attf-href="http://www.linkedin.com/shareArticle?mini=true&url=#{slide.share_url}&title=#{slide.name}&">
|
||||
<a target="_Blank" t-attf-href="http://www.linkedin.com/shareArticle?mini=true&url=#{slide.website_url}&title=#{slide.name}&">
|
||||
<i class="fa fa-linkedin-square fa-2x"></i>
|
||||
</a>
|
||||
<a target="_Blank" t-attf-href="https://plus.google.com/share?url=#{slide.share_url}">
|
||||
<a target="_Blank" t-attf-href="https://plus.google.com/share?url=#{slide.website_url}">
|
||||
<i class="fa fa-google-plus-square fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -381,7 +381,7 @@
|
||||
<t t-if="not private">
|
||||
<meta property="og:title" t-att-content="slide.name" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" t-att-content="slide.share_url" />
|
||||
<meta property="og:url" t-att-content="slide.website_url" />
|
||||
<meta property="og:image" t-attf-content="#{request.httprequest.host_url}/website/image/slide.slide/#{slide.id}/image_thumb"/>
|
||||
<meta property="og:description" t-att-content="slide.description" />
|
||||
</t>
|
||||
@@ -731,7 +731,7 @@
|
||||
<h4 class="mt0">Share on Social Networks</h4>
|
||||
<t t-call="website_slides.slides_share"/>
|
||||
<h4 class="mt0">Share Link</h4>
|
||||
<input type="text" class="form-control" t-att-value="slide.share_url" readonly="readonly" onClick="this.select();"/>
|
||||
<input type="text" class="form-control" t-att-value="slide.website_url" readonly="readonly" onClick="this.select();"/>
|
||||
<span class="help-block">Use permanent link to share in social media</span>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
<form string="Slide">
|
||||
<sheet>
|
||||
<field name="image" widget="image" class="oe_left oe_avatar" options='{"preview_image": "image_thumb"}'/>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button class="oe_inline oe_stat_button" name="open_website_url"
|
||||
type="object" icon="fa-globe">
|
||||
<field name="website_published" widget="website_button"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title oe_left">
|
||||
<div class="oe_edit_only">
|
||||
<label for="name" string="Name"/>
|
||||
@@ -51,13 +57,10 @@
|
||||
</h1>
|
||||
<field name="tag_ids" widget="many2many_tags" placeholder="Tags..."/>
|
||||
</div>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<field name="website_published" class="pull-right" widget="website_button"/>
|
||||
</div>
|
||||
<group>
|
||||
<field name="channel_id"/>
|
||||
<field name="category_id" context="{'default_channel_id': channel_id}"/>
|
||||
<field name="share_url"/>
|
||||
<field name="website_url"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Description">
|
||||
@@ -201,7 +204,10 @@
|
||||
</h1>
|
||||
</div>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<field name="website_published" class="pull-right" widget="website_button"/>
|
||||
<button class="oe_inline oe_stat_button" name="open_website_url"
|
||||
type="object" icon="fa-globe">
|
||||
<field name="website_published" widget="website_button"/>
|
||||
</button>
|
||||
</div>
|
||||
<field name="category_ids" widget="many2many_tags" placeholder="Categories" context="{'default_channel_id': active_id}"
|
||||
domain="[('channel_id','=', active_id)]"/>
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-sm-4 col-xs-4 text-left">
|
||||
<div class="oe_slides_ellipsis">
|
||||
<a target="_new" t-att-href="slide.share_url">
|
||||
<a target="_new" t-att-href="slide.website_url">
|
||||
<span t-esc="slide.name" t-attf-title="#{slide.name}"/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -152,7 +152,7 @@
|
||||
<div id="slide_suggest" class="oe_slide_embed_option">
|
||||
<t t-foreach="related_slides" t-as="suggest_slide">
|
||||
<div class="col-md-4 col-sm-4 col-xs-4 oe_slides_suggestion_media">
|
||||
<a t-att-href="suggest_slide.share_url" target="_new">
|
||||
<a t-att-href="suggest_slide.website_url" target="_new">
|
||||
<div class="oe_slides_suggestion_caption">
|
||||
<h4><t t-esc="suggest_slide.name"/></h4>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user