[IMP] Improve Multi-Website Functionalities:-

- Affected Modules:
    website_sale, website_blog, website_partner, website_crm_partner_assign,
    website_customer, website_slides, website_links, website_membership,
    website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
    website_forum, website_event

- Remove unnecessary model `website.product.pricelist` from website_sale,
  All its mechanism already transferd to existing model `product.pricelist`

- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
  As user can choose that same pricelist can be used in multiple websites

- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
  almost all affected modules (mentioned above!!)

- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
  User have to set `website_published` mechanism `on` (if it's available for that model/object),
  Also have to set/assign different websites in `website_ids` field as per needs
This commit is contained in:
Siddharth Bhalgami 2018-02-06 15:13:31 +05:30
parent 2b42b1b300
commit e088762a21
53 changed files with 310 additions and 276 deletions

View File

@ -24,7 +24,7 @@ class WebsiteBlog(http.Controller):
dom = blog and [('blog_id', '=', blog.id)] or [] dom = blog and [('blog_id', '=', blog.id)] or []
if not request.env.user.has_group('website.group_website_designer'): if not request.env.user.has_group('website.group_website_designer'):
dom += [('post_date', '<=', fields.Datetime.now()), dom += [('post_date', '<=', fields.Datetime.now()),
'|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)] ("website_ids", "in", request.website.id)]
groups = request.env['blog.post']._read_group_raw( groups = request.env['blog.post']._read_group_raw(
dom, dom,
['name', 'post_date'], ['name', 'post_date'],
@ -64,7 +64,7 @@ class WebsiteBlog(http.Controller):
page=page, page=page,
step=self._blog_post_per_page, step=self._blog_post_per_page,
) )
posts = BlogPost.search(['|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page) posts = BlogPost.search([('website_ids', 'in', request.website.id)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page)
blog_url = QueryURL('', ['blog', 'tag']) blog_url = QueryURL('', ['blog', 'tag'])
return request.render("website_blog.latest_blogs", { return request.render("website_blog.latest_blogs", {
'posts': posts, 'posts': posts,
@ -114,16 +114,16 @@ class WebsiteBlog(http.Controller):
domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)] domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)]
if request.env.user.has_group('website.group_website_designer'): if request.env.user.has_group('website.group_website_designer'):
count_domain = domain + [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())] count_domain = domain + [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())]
published_count = BlogPost.search_count(count_domain) published_count = BlogPost.search_count(count_domain)
unpublished_count = BlogPost.search_count(domain) - published_count unpublished_count = BlogPost.search_count(domain) - published_count
if state == "published": if state == "published":
domain += [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())] domain += [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())]
elif state == "unpublished": elif state == "unpublished":
domain += ['|', ("website_published", "=", False), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", ">", fields.Datetime.now())] domain += ['|', ("website_published", "=", False), ("website_ids", "in", request.website.id), ("post_date", ">", fields.Datetime.now())]
else: else:
domain += [("post_date", "<=", fields.Datetime.now()), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)] domain += [("post_date", "<=", fields.Datetime.now()), ("website_ids", "in", request.website.id)]
blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end) blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end)
@ -198,6 +198,10 @@ class WebsiteBlog(http.Controller):
- 'nav_list': a dict [year][month] for archives navigation - 'nav_list': a dict [year][month] for archives navigation
- 'next_post': next blog post, to direct the user towards the next interesting post - 'next_post': next blog post, to direct the user towards the next interesting post
""" """
if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in blog_post.website_ids.ids:
return request.render('website.404')
BlogPost = request.env['blog.post'] BlogPost = request.env['blog.post']
date_begin, date_end = post.get('date_begin'), post.get('date_end') date_begin, date_end = post.get('date_begin'), post.get('date_end')
@ -225,7 +229,7 @@ class WebsiteBlog(http.Controller):
tags = request.env['blog.tag'].search([]) tags = request.env['blog.tag'].search([])
# Find next Post # Find next Post
all_post = BlogPost.search([('blog_id', '=', blog.id)]) all_post = BlogPost.search([('blog_id', '=', blog.id), ("website_published", "=", True), ("website_ids", "in", request.website.id)])
if not request.env.user.has_group('website.group_website_designer'): if not request.env.user.has_group('website.group_website_designer'):
all_post = all_post.filtered(lambda r: r.post_date <= fields.Datetime.now()) all_post = all_post.filtered(lambda r: r.post_date <= fields.Datetime.now())
@ -331,7 +335,7 @@ class WebsiteBlog(http.Controller):
#check current user belongs to website publisher group #check current user belongs to website publisher group
publish = request.env.user.has_group('website.group_website_publisher') publish = request.env.user.has_group('website.group_website_publisher')
if not publish: if not publish:
domain.append(('website_published', '=', True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)) domain.append(('website_published', '=', True), ("website_ids", "in", request.website.id))
messages = request.env['mail.message'].sudo().search(domain, count=count) messages = request.env['mail.message'].sudo().search(domain, count=count)
if count: if count:
return messages.ids return messages.ids

View File

@ -16,7 +16,6 @@
<field name="blog_id" ref="blog_blog_1"/> <field name="blog_id" ref="blog_blog_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/> <field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="published_date" eval="time.strftime('%Y-%m-%d %H:%M:%S')"/> <field name="published_date" eval="time.strftime('%Y-%m-%d %H:%M:%S')"/>
<field name="website_meta_keywords">Flectra, email</field> <field name="website_meta_keywords">Flectra, email</field>
<field name="website_meta_description">The Future of Emails</field> <field name="website_meta_description">The Future of Emails</field>
@ -132,7 +131,6 @@
<field name="subtitle">Building your company's website and selling your products online easy.</field> <field name="subtitle">Building your company's website and selling your products online easy.</field>
<field name="blog_id" ref="blog_blog_1"/> <field name="blog_id" ref="blog_blog_1"/>
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="published_date" eval="time.strftime('%Y-%m-%d %H:%M:%S')"/> <field name="published_date" eval="time.strftime('%Y-%m-%d %H:%M:%S')"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1'), ref('blog_tag_2')])]"/> <field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1'), ref('blog_tag_2')])]"/>
<field name="cover_properties">{"background-image": "url(/web/image/website_blog.blog_post_cover_02)", "resize_class": "cover container-fluid cover_full", "background-color": "oe_black", "opacity": "0.0"}</field> <field name="cover_properties">{"background-image": "url(/web/image/website_blog.blog_post_cover_02)", "resize_class": "cover container-fluid cover_full", "background-color": "oe_black", "opacity": "0.0"}</field>

View File

@ -127,6 +127,10 @@ class BlogPost(models.Model):
</section> </section>
''' '''
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
name = fields.Char('Title', required=True, translate=True, default='') name = fields.Char('Title', required=True, translate=True, default='')
subtitle = fields.Char('Sub Title', translate=True) subtitle = fields.Char('Sub Title', translate=True)
author_id = fields.Many2one('res.partner', 'Author', default=lambda self: self.env.user.partner_id) author_id = fields.Many2one('res.partner', 'Author', default=lambda self: self.env.user.partner_id)
@ -155,9 +159,10 @@ class BlogPost(models.Model):
ranking = fields.Float(compute='_compute_ranking', string='Ranking') ranking = fields.Float(compute='_compute_ranking', string='Ranking')
website_ids = fields.Many2many('website', 'website_blog_pub_rel', website_ids = fields.Many2many('website', 'website_blog_pub_rel',
'website_id', 'blog_id', 'website_id', 'blog_id',
default=_default_website,
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which ' help='List of websites in which '
'Blog Post is published.') 'Blog Post will published.')
@api.multi @api.multi
@api.depends('content', 'teaser_manual') @api.depends('content', 'teaser_manual')

View File

@ -17,7 +17,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
- if someone subscribe to the post or comment it, it become follower - if someone subscribe to the post or comment it, it become follower
and receive notification for future comments. """ and receive notification for future comments. """
self.website = self.env['website'].browse(1) website = self.env['website'].browse(1)
# Create a new blog, subscribe the employee to the blog # Create a new blog, subscribe the employee to the blog
test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({ test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({
'name': 'New Blog', 'name': 'New Blog',
@ -40,7 +40,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
'website_blog: subscribing to a blog should not subscribe to its posts') 'website_blog: subscribing to a blog should not subscribe to its posts')
# Publish the blog # Publish the blog
test_blog_post.write({'website_published': True, 'website_ids': [(6, 0, [self.website.id])]}) test_blog_post.write({'website_published': True, 'website_ids': [(6, 0, [website.id])]})
# Check publish message has been sent to blog followers # Check publish message has been sent to blog followers
publish_message = next((m for m in test_blog_post.blog_id.message_ids if m.subtype_id.id == self.ref('website_blog.mt_blog_blog_published')), None) publish_message = next((m for m in test_blog_post.blog_id.message_ids if m.subtype_id.id == self.ref('website_blog.mt_blog_blog_published')), None)

View File

@ -133,7 +133,7 @@
</p> </p>
</div> </div>
<div t-foreach="blog_posts" t-as="blog_post" class="mb32" name="blog_post" t-attf-data-publish="#{not blog_post.website_ids or website in blog_post.website_ids and 'on' or 'off'}"> <div t-foreach="blog_posts" t-as="blog_post" class="mb32" name="blog_post" t-att-data-publish="blog_post.website_published and website in blog_post.website_ids and 'on' or 'off'">
<a t-attf-href="/blog/#{ slug(blog_post.blog_id) }/post/#{ slug(blog_post) }"> <a t-attf-href="/blog/#{ slug(blog_post.blog_id) }/post/#{ slug(blog_post) }">
<h2 t-field="blog_post.name" class="mb4 o_blog_post_title">Untitled Post</h2> <h2 t-field="blog_post.name" class="mb4 o_blog_post_title">Untitled Post</h2>
</a> </a>

View File

@ -185,14 +185,14 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
yield {'loc': '/partners'} yield {'loc': '/partners'}
Grade = env['res.partner.grade'] Grade = env['res.partner.grade']
dom = [('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False)] dom = [('website_published', '=', True), ('website_ids', 'in', request.website.id)]
dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name) dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name)
for grade in env['res.partner.grade'].search(dom): for grade in env['res.partner.grade'].search(dom):
loc = '/partners/grade/%s' % slug(grade) loc = '/partners/grade/%s' % slug(grade)
if not qs or qs.lower() in loc: if not qs or qs.lower() in loc:
yield {'loc': loc} yield {'loc': loc}
partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False), ('grade_id.website_published', '=', True)] partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id), ('grade_id.website_published', '=', True)]
dom += sitemap_qs2dom(qs=qs, route='/partners/country/') dom += sitemap_qs2dom(qs=qs, route='/partners/country/')
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id') countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
for country in countries: for country in countries:
@ -219,9 +219,9 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
country_obj = request.env['res.country'] country_obj = request.env['res.country']
search = post.get('search', '') search = post.get('search', '')
base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)] base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id)]
if not request.env['res.users'].has_group('website.group_website_publisher'): if not request.env['res.users'].has_group('website.group_website_publisher'):
base_partner_domain += [('grade_id.website_published', '=', True), '|', ('grade_id.website_ids', 'in', request.website.id), ('grade_id.website_ids', '=', False)] base_partner_domain += [('grade_id.website_published', '=', True), ('grade_id.website_ids', 'in', request.website.id)]
if search: if search:
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)] base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]
@ -327,7 +327,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
if partner_id: if partner_id:
partner = request.env['res.partner'].sudo().browse(partner_id) partner = request.env['res.partner'].sudo().browse(partner_id)
is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher') is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher')
if partner.exists() and ((partner.website_published and request.website in partner.website_ids) or is_website_publisher): if partner.exists() and ((partner.website_published and request.website in partner.website_ids) or is_website_publisher):
values = { values = {
'main_object': partner, 'main_object': partner,
'partner': partner, 'partner': partner,

View File

@ -3,19 +3,15 @@
<data noupdate="1"> <data noupdate="1">
<record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade"> <record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade">
<field name="website_published" eval="True" /> <field name="website_published" eval="True" />
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade"> <record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade">
<field name="website_published" eval="True" /> <field name="website_published" eval="True" />
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade"> <record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade">
<field name="website_published" eval="True" /> <field name="website_published" eval="True" />
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade"> <record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade">
<field name="website_published" eval="True" /> <field name="website_published" eval="True" />
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.partner_demo_portal" model="res.partner"> <record id="base.partner_demo_portal" model="res.partner">
<field name="grade_id" ref="website_crm_partner_assign.res_partner_grade_platinium"/> <field name="grade_id" ref="website_crm_partner_assign.res_partner_grade_platinium"/>

View File

@ -9,6 +9,10 @@ class ResPartnerGrade(models.Model):
_name = 'res.partner.grade' _name = 'res.partner.grade'
_inherit = ['website.published.mixin'] _inherit = ['website.published.mixin']
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_published = fields.Boolean(default=True) website_published = fields.Boolean(default=True)
sequence = fields.Integer('Sequence') sequence = fields.Integer('Sequence')
active = fields.Boolean('Active', default=lambda *args: 1) active = fields.Boolean('Active', default=lambda *args: 1)
@ -18,8 +22,9 @@ class ResPartnerGrade(models.Model):
website_ids = fields.Many2many('website', 'website_partner_grade_pub_rel', website_ids = fields.Many2many('website', 'website_partner_grade_pub_rel',
'website_id', 'partner_grade_id', 'website_id', 'partner_grade_id',
string='Websites', copy=False, string='Websites', copy=False,
default=_default_website,
help='List of websites in which ' help='List of websites in which '
'Partner Grade is published.') 'Partner Grade will published.')
@api.multi @api.multi
def _compute_website_url(self): def _compute_website_url(self):

View File

@ -162,7 +162,7 @@
<template id="grade_in_detail" inherit_id="website_partner.partner_detail"> <template id="grade_in_detail" inherit_id="website_partner.partner_detail">
<xpath expr="//*[@id='partner_name']" position="after"> <xpath expr="//*[@id='partner_name']" position="after">
<h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published and (website in partner.grade_id.website_ids or not partner.grade_id.website_ids)"> <h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published and website in partner.grade_id.website_ids">
<span t-field="partner.grade_id"/> Partner</h3> <span t-field="partner.grade_id"/> Partner</h3>
</xpath> </xpath>
</template> </template>
@ -171,7 +171,7 @@
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])"> <t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
<h3 id="references">References</h3> <h3 id="references">References</h3>
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media"> <div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
<t t-if="(not reference.website_ids or website in reference.website_ids) and reference.website_published"> <t t-if="website in reference.website_ids and reference.website_published">
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}"> <a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/> <span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
</a> </a>

View File

@ -47,7 +47,7 @@ class WebsiteCustomer(http.Controller):
Partner = request.env['res.partner'] Partner = request.env['res.partner']
search_value = post.get('search') search_value = post.get('search')
domain = [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)] domain = [('website_published', '=', True), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)]
if search_value: if search_value:
domain += [ domain += [
'|', '|', '|', '|',
@ -118,7 +118,7 @@ class WebsiteCustomer(http.Controller):
google_map_partner_ids = ','.join(str(it) for it in partners.ids) google_map_partner_ids = ','.join(str(it) for it in partners.ids)
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key') google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
tags = Tag.search([('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC') tags = Tag.search([('website_published', '=', True), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC')
tag = tag_id and Tag.browse(tag_id) or False tag = tag_id and Tag.browse(tag_id) or False
values = { values = {
@ -145,7 +145,7 @@ class WebsiteCustomer(http.Controller):
_, partner_id = unslug(partner_id) _, partner_id = unslug(partner_id)
if partner_id: if partner_id:
partner = request.env['res.partner'].sudo().browse(partner_id) partner = request.env['res.partner'].sudo().browse(partner_id)
if partner.exists() and partner.website_published and (request.website in partner.website_ids or not partner.website_ids): if partner.exists() and partner.website_published and request.website in partner.website_ids:
values = {} values = {}
values['main_object'] = values['partner'] = partner values['main_object'] = values['partner'] = partner
return request.render("website_customer.details", values) return request.render("website_customer.details", values)

View File

@ -4,7 +4,6 @@
<record id="base.res_partner_2" model="res.partner"> <record id="base.res_partner_2" model="res.partner">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="website_short_description">Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.</field> <field name="website_short_description">Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.</field>
<field name="website_description" type="xml"> <field name="website_description" type="xml">
<p> <p>
@ -35,7 +34,6 @@
</record> </record>
<record id="base.res_partner_3" model="res.partner"> <record id="base.res_partner_3" model="res.partner">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="website_short_description">A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).</field> <field name="website_short_description">A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).</field>
<field name="website_description" type="xml"> <field name="website_description" type="xml">
<p> <p>
@ -64,7 +62,6 @@
</record> </record>
<record id="base.res_partner_4" model="res.partner"> <record id="base.res_partner_4" model="res.partner">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="website_short_description">Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.</field> <field name="website_short_description">Agrolait designs, develops, integrates and supports HR and Supply Chain processes in order to make our customers more productive, responsive and profitable.</field>
<field name="website_description" type="xml"> <field name="website_description" type="xml">
<p> <p>
@ -95,7 +92,6 @@
</record> </record>
<record id="base.res_partner_3" model="res.partner"> <record id="base.res_partner_3" model="res.partner">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
<field name="website_short_description">A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).</field> <field name="website_short_description">A non-profit international educational and scientific organisation, hosting three departments (aeronautics and aerospace, environmental and applied fluid dynamics, and turbomachinery and propulsion).</field>
<field name="website_description" type="xml"> <field name="website_description" type="xml">
<p> <p>

View File

@ -22,6 +22,10 @@ class Tags(models.Model):
classname = ['default', 'primary', 'success', 'warning', 'danger'] classname = ['default', 'primary', 'success', 'warning', 'danger']
return [(x, str.title(x)) for x in classname] return [(x, str.title(x)) for x in classname]
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
name = fields.Char('Category Name', required=True, translate=True) name = fields.Char('Category Name', required=True, translate=True)
partner_ids = fields.Many2many('res.partner', 'res_partner_res_partner_tag_rel', 'tag_id', 'partner_id', string='Partners') partner_ids = fields.Many2many('res.partner', 'res_partner_res_partner_tag_rel', 'tag_id', 'partner_id', string='Partners')
classname = fields.Selection(get_selection_class, 'Class', default='default', help="Bootstrap class to customize the color", required=True) classname = fields.Selection(get_selection_class, 'Class', default='default', help="Bootstrap class to customize the color", required=True)
@ -30,5 +34,6 @@ class Tags(models.Model):
website_ids = fields.Many2many('website', 'website_partner_tag_pub_rel', website_ids = fields.Many2many('website', 'website_partner_tag_pub_rel',
'website_id', 'partner_tag_id', 'website_id', 'partner_tag_id',
string='Websites', copy=False, string='Websites', copy=False,
default=_default_website,
help='List of websites in which ' help='List of websites in which '
'Partner Tag is published.') 'Partner Tag will published.')

View File

@ -37,7 +37,6 @@
<field name="name"/> <field name="name"/>
<field name="classname"/> <field name="classname"/>
<field name="website_published"/> <field name="website_published"/>
<field name="website_ids" widget="many2many_tags"/>
<field name="active"/> <field name="active"/>
</tree> </tree>
</field> </field>

View File

@ -189,7 +189,7 @@
</template> </template>
<template id="implemented_by_block" name="Partner Implemented By Block"> <template id="implemented_by_block" name="Partner Implemented By Block">
<t t-if="partner.assigned_partner_id and partner.assigned_partner_id.website_published and (website in partner.assigned_partner_id.website_ids or not partner.assigned_partner_id.website_ids)"> <t t-if="partner.assigned_partner_id and partner.assigned_partner_id.website_published and website in partner.assigned_partner_id.website_ids">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h4>Implemented By</h4> <h4>Implemented By</h4>
@ -198,7 +198,7 @@
<h4> <h4>
<a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}"> <a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}">
<span t-field="partner.assigned_partner_id"/> <span t-field="partner.assigned_partner_id"/>
<span class="small"> (<t t-esc="len([p for p in partner.assigned_partner_id.implemented_partner_ids if p.website_published and (p.website_ids or website in p.website_ids)])"/> reference(s))</span> <span class="small"> (<t t-esc="len([p for p in partner.assigned_partner_id.implemented_partner_ids if p.website_published and website in p.website_ids])"/> reference(s))</span>
</a> </a>
</h4> </h4>
<div><a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}" <div><a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}"
@ -221,7 +221,7 @@
<t t-if="any([p.website_published and (website in p.website_ids or not p.website_ids) for p in partner.implemented_partner_ids])"> <t t-if="any([p.website_published and (website in p.website_ids or not p.website_ids) for p in partner.implemented_partner_ids])">
<h3 id="references">References</h3> <h3 id="references">References</h3>
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media"> <div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
<t t-if="reference.website_published and (website in reference.website_ids or not reference.website_ids)"> <t t-if="reference.website_published and website in reference.website_ids">
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}"> <a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/> <span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
</a> </a>

View File

@ -83,7 +83,7 @@ class WebsiteEventController(http.Controller):
def dom_without(without): def dom_without(without):
domain = [('state', "in", ['draft', 'confirm', 'done'])] domain = [('state', "in", ['draft', 'confirm', 'done'])]
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)] if \ domain += [('website_id', '=', request.website.id)] if \
not request.env.user.has_group('website.group_website_publisher') else [] not request.env.user.has_group('website.group_website_publisher') else []
for key, search in domain_search.items(): for key, search in domain_search.items():
if key != without: if key != without:
@ -171,6 +171,9 @@ class WebsiteEventController(http.Controller):
@http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True, sitemap=False) @http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True, sitemap=False)
def event_register(self, event, **post): def event_register(self, event, **post):
if not request.env.user.has_group('website.group_website_publisher') \
and request.website != event.website_id:
return request.render('website.404')
values = { values = {
'event': event, 'event': event,
'main_object': event, 'main_object': event,
@ -257,7 +260,6 @@ class WebsiteEventController(http.Controller):
for registration in registrations: for registration in registrations:
registration['event_id'] = event registration['event_id'] = event
registration['website_id'] = request.website.id
Attendees += Attendees.sudo().create( Attendees += Attendees.sudo().create(
Attendees._prepare_attendee_values(registration)) Attendees._prepare_attendee_values(registration))

View File

@ -3,12 +3,11 @@
<record id="base.res_partner_1" model="res.partner"> <record id="base.res_partner_1" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="event.event_0" model="event.event"> <record id="event.event_0" model="event.event">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/> <field name="website_id" ref="website.default_website"/>
<field name="twitter_hashtag">flectra</field> <field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[ <field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_02);"> <section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_02);">
@ -165,11 +164,10 @@
<record id="base.res_partner_3" model="res.partner"> <record id="base.res_partner_3" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="event.event_1" model="event.event"> <record id="event.event_1" model="event.event">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/> <field name="website_id" ref="website.default_website"/>
<field name="twitter_hashtag">flectra</field> <field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[ <field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_01);"> <section class="s_text_block_image_fw oe_img_bg" style="background-position: 50% 100%; background-image: url(/web/image/website.s_background_image_01);">
@ -326,25 +324,22 @@
<record id="base.res_partner_4" model="res.partner"> <record id="base.res_partner_4" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="event.event_2" model="event.event"> <record id="event.event_2" model="event.event">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/> <field name="website_id" ref="website.default_website"/>
<field name="twitter_hashtag">flectra</field> <field name="twitter_hashtag">flectra</field>
</record> </record>
<record id="base.res_partner_2" model="res.partner"> <record id="base.res_partner_2" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_address_4" model="res.partner"> <record id="base.res_partner_address_4" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="event.event_3" model="event.event"> <record id="event.event_3" model="event.event">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/> <field name="website_id" ref="website.default_website"/>
<field name="twitter_hashtag">flectra</field> <field name="twitter_hashtag">flectra</field>
<field name="description"><![CDATA[ <field name="description"><![CDATA[
<section class="s_text_block_image_fw oe_img_bg oe_custom_bg" style="background-image: url(/web/image/website.s_cover_default_image); background-position: 50% 100%"> <section class="s_text_block_image_fw oe_img_bg oe_custom_bg" style="background-image: url(/web/image/website.s_cover_default_image); background-position: 50% 100%">

View File

@ -17,11 +17,11 @@ class Event(models.Model):
_inherit = ['event.event', 'website.seo.metadata', 'website.published.mixin'] _inherit = ['event.event', 'website.seo.metadata', 'website.published.mixin']
website_published = fields.Boolean(track_visibility='onchange') website_published = fields.Boolean(track_visibility='onchange')
website_ids = fields.Many2many('website', 'website_event_pub_rel', website_id = fields.Many2one('website', string='Website', copy=False,
'website_id', 'event_id', default=lambda self: self.env.ref(
string='Websites', copy=False, 'website.default_website'),
help='List of websites in which ' help='Website in which '
'Event is published.') 'Event will published.')
is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating") is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating")
@ -136,29 +136,3 @@ class Event(models.Model):
'target': 'new', 'target': 'new',
'url': '/report/html/%s/%s?enable_editor' % ('event.event_event_report_template_badge', self.id), 'url': '/report/html/%s/%s?enable_editor' % ('event.event_event_report_template_badge', self.id),
} }
class EventRegistration(models.Model):
_inherit = 'event.registration'
website_id = fields.Many2one('website', string="Website")
@api.model
def _prepare_attendee_values(self, registration):
""" Method preparing the values to create new attendees based on a
sale order line. It takes some registration data (dict-based) that are
optional values coming from an external input like a web page. This method
is meant to be inherited in various addons that sell events. """
partner_id = registration.pop('partner_id', self.env.user.partner_id)
event_id = registration.pop('event_id', False)
data = {
'name': registration.get('name', partner_id.name),
'phone': registration.get('phone', partner_id.phone),
'email': registration.get('email', partner_id.email),
'partner_id': partner_id.id,
'website_id': registration.get('website_id', partner_id.email),
'event_id': event_id and event_id.id or False,
}
data.update({key: registration[key] for key in registration.keys() if key in self._fields})
return data

View File

@ -53,12 +53,12 @@
</div> </div>
<ul class="media-list"> <ul class="media-list">
<li t-foreach="event_ids" t-as="event" class="media"> <li t-foreach="event_ids" t-as="event" class="media">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body" t-attf-data-publish="#{not event.website_ids or website in event.website_ids and 'on' or 'off'}"> <div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body" t-att-data-publish="event.website_published and website.id in event.website_id.ids and 'on' or 'off'">
<h4 class="media-heading"> <h4 class="media-heading">
<a itemprop="url" t-att-class="event.state == 'done' and 'text-success'" t-attf-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register' or ''}"><span itemprop="name" t-field="event.name"> </span></a> <a itemprop="url" t-att-class="event.state == 'done' and 'text-success'" t-attf-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register' or ''}"><span itemprop="name" t-field="event.name"> </span></a>
<small t-if="event.is_participating" class="label label-info">Participating</small> <small t-if="event.is_participating" class="label label-info">Participating</small>
<small t-if="not event.is_online" class="label label-info">Online</small> <small t-if="event.is_online" class="label label-info">Online</small>
<small t-if="not event.website_published and (not event.website_ids or website not in event.website_ids)" class="label label-danger">unpublished</small> <small t-if="not event.website_published" class="label label-danger">unpublished</small>
</h4> </h4>
<div> <div>
<t t-if="event.organizer_id"> <t t-if="event.organizer_id">
@ -680,7 +680,7 @@
<h4><b>Upcoming Events</b></h4> <h4><b>Upcoming Events</b></h4>
</t> </t>
<div t-foreach="events[:5]" t-as="event_dict" class="oe_website_overflow_ellipsis mb8"> <div t-foreach="events[:5]" t-as="event_dict" class="oe_website_overflow_ellipsis mb8">
<t t-if="not event_dict['event'].website_published and (website not in event_dict['event'].wesite_ids or not event_dict['event'].wesite_ids)"> <t t-if="not event_dict['event'].website_published and not event_dict['event'].website_id">
<span class="label label-danger"><i class="fa fa-ban"></i></span> <span class="label label-danger"><i class="fa fa-ban"></i></span>
</t> </t>
<t t-if="event_dict['event'].address_id"> <t t-if="event_dict['event'].address_id">

View File

@ -55,20 +55,9 @@
string="Edit Badges"/> string="Edit Badges"/>
</xpath> </xpath>
<xpath expr="//field[@name='auto_confirm']" position="before"> <xpath expr="//field[@name='auto_confirm']" position="before">
<field name="website_ids" widget="many2many_tags"/> <field name="website_id"/>
</xpath> </xpath>
</field> </field>
</record> </record>
<record model="ir.ui.view" id="view_event_registration_form_inherit">
<field name="name">view.event.registration.form.inherit</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="website_id"/>
</field>
</field>
</record>
</flectra> </flectra>

View File

@ -83,7 +83,7 @@ class WebsiteForum(http.Controller):
def forum(self, **kwargs): def forum(self, **kwargs):
domain = [] domain = []
if not request.env.user.has_group('website.group_website_designer'): if not request.env.user.has_group('website.group_website_designer'):
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)] domain += [('website_ids', 'in', request.website.id)]
forums = request.env['forum.forum'].search(domain) forums = request.env['forum.forum'].search(domain)
return request.render("website_forum.forum_all", {'forums': forums}) return request.render("website_forum.forum_all", {'forums': forums})
@ -119,8 +119,10 @@ class WebsiteForum(http.Controller):
], type='http', auth="public", website=True, sitemap=sitemap_forum) ], type='http', auth="public", website=True, sitemap=sitemap_forum)
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post): def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post):
Post = request.env['forum.post'] Post = request.env['forum.post']
if not request.env.user.has_group('website.group_website_publisher') \
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), '|', ('website_id', '=', request.website.id), ('website_id', '=', False)] and request.website.id not in forum.website_ids.ids:
return request.render('website.404')
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), ('website_id', '=', request.website.id)]
if search: if search:
domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)] domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)]
if tag: if tag:
@ -237,6 +239,10 @@ class WebsiteForum(http.Controller):
@http.route(['''/forum/<model("forum.forum"):forum>/question/<model("forum.post", "[('forum_id','=',forum[0]),('parent_id','=',False),('can_view', '=', True)]"):question>'''], type='http', auth="public", website=True) @http.route(['''/forum/<model("forum.forum"):forum>/question/<model("forum.post", "[('forum_id','=',forum[0]),('parent_id','=',False),('can_view', '=', True)]"):question>'''], type='http', auth="public", website=True)
def question(self, forum, question, **post): def question(self, forum, question, **post):
if not request.env.user.has_group('website.group_website_publisher') \
and request.website != question.website_id:
return request.render('website.404')
# Hide posts from abusers (negative karma), except for moderators # Hide posts from abusers (negative karma), except for moderators
if not question.can_view: if not question.can_view:
raise werkzeug.exceptions.NotFound() raise werkzeug.exceptions.NotFound()
@ -411,7 +417,7 @@ class WebsiteForum(http.Controller):
'name': kwargs.get('post_name'), 'name': kwargs.get('post_name'),
'content': kwargs.get('content'), 'content': kwargs.get('content'),
'content_link': kwargs.get('content_link'), 'content_link': kwargs.get('content_link'),
'website_id': request.website.id, 'website_id': request.website and request.website.id,
} }
post.write(vals) post.write(vals)
question = post.parent_id if post.parent_id else post question = post.parent_id if post.parent_id else post
@ -555,9 +561,9 @@ class WebsiteForum(http.Controller):
def users(self, forum, page=1, **searches): def users(self, forum, page=1, **searches):
User = request.env['res.users'] User = request.env['res.users']
step = 30 step = 30
tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)]) tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), ('website_ids', 'in', request.website.id)])
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30) pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)], limit=step, offset=pager['offset'], order='karma DESC') user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), ('website_ids', 'in', request.website.id)], limit=step, offset=pager['offset'], order='karma DESC')
# put the users in block of 3 to display them as a table # put the users in block of 3 to display them as a table
users = [[] for i in range(len(user_obj) // 3 + 1)] users = [[] for i in range(len(user_obj) // 3 + 1)]
for index, user in enumerate(user_obj): for index, user in enumerate(user_obj):

View File

@ -28,7 +28,6 @@
<!-- Questions --> <!-- Questions -->
<record id="question_0" model="forum.post"> <record id="question_0" model="forum.post">
<field name="name">How to configure alerts for employee contract expiration</field> <field name="name">How to configure alerts for employee contract expiration</field>
<field name="website_id" ref="website.default_website"/>
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="post_type">question</field> <field name="post_type">question</field>
<field name="views">3</field> <field name="views">3</field>
@ -36,7 +35,6 @@
</record> </record>
<record id="question_1" model="forum.post"> <record id="question_1" model="forum.post">
<field name="name">CMS replacement for ERP and eCommerce</field> <field name="name">CMS replacement for ERP and eCommerce</field>
<field name="website_id" ref="website.default_website"/>
<field name="views">8</field> <field name="views">8</field>
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="content"><![CDATA[<p>I use Wordpress as a CMS and eCommerce platform. The developing in Wordpress is quite easy and solid but it missing ERP feature (there is single plugin to integrate with Frontaccounting) so I wonder: <field name="content"><![CDATA[<p>I use Wordpress as a CMS and eCommerce platform. The developing in Wordpress is quite easy and solid but it missing ERP feature (there is single plugin to integrate with Frontaccounting) so I wonder:
@ -51,7 +49,6 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
<!-- Answer --> <!-- Answer -->
<record id="answer_0" model="forum.post"> <record id="answer_0" model="forum.post">
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="website_id" ref="website.default_website"/>
<field name="content"><![CDATA[<p>Just for posterity so other can see. Here are the steps to set automatic alerts on any contract.. i.e. HR Employee, or Fleet for example. I will use fleet as an example.</p> <field name="content"><![CDATA[<p>Just for posterity so other can see. Here are the steps to set automatic alerts on any contract.. i.e. HR Employee, or Fleet for example. I will use fleet as an example.</p>
<ul> <ul>
<li>Step 1. As a user who has access rights to Technical Features, go to Settings --> Automated Actions. Create A new Automated Action. For the Related Document Model choose.. Contract information on a vehicle (you can also type in the actual model name.. fleet.vehicle.log.contract ) . Set the trigger date to ... Contract Expiration Date. The Next Field (Delay After Trigger Date) is a bit ridiculous. Who wants to be reminded of a contract expiration AFTER the fact? The field should say Days Before Date to Fire Action and the number should be converted to a negative. IMHO. Any way... to get a workable solution you must enter in the number in the negative. So for instance like me if you want to be warned 35 days BEFORE the expiration... put in Delay After Trigger Date.. the number -35 But the sake of testing, right now just put in -1 for 1 day before. Save the Action. <li>Step 1. As a user who has access rights to Technical Features, go to Settings --> Automated Actions. Create A new Automated Action. For the Related Document Model choose.. Contract information on a vehicle (you can also type in the actual model name.. fleet.vehicle.log.contract ) . Set the trigger date to ... Contract Expiration Date. The Next Field (Delay After Trigger Date) is a bit ridiculous. Who wants to be reminded of a contract expiration AFTER the fact? The field should say Days Before Date to Fire Action and the number should be converted to a negative. IMHO. Any way... to get a workable solution you must enter in the number in the negative. So for instance like me if you want to be warned 35 days BEFORE the expiration... put in Delay After Trigger Date.. the number -35 But the sake of testing, right now just put in -1 for 1 day before. Save the Action.
@ -64,7 +61,6 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
</record> </record>
<record id="answer_1" model="forum.post"> <record id="answer_1" model="forum.post">
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="website_id" ref="website.default_website"/>
<field name="content"><![CDATA[ <field name="content"><![CDATA[
<p>Flectra v8 (next release) provides a web module and an e-commerce module: www.flectra.com/page/website-builder <p>Flectra v8 (next release) provides a web module and an e-commerce module: www.flectra.com/page/website-builder
The CMS editor in Flectra web is nice but I prefer Drupal for customization and there is a Drupal module for Flectra. I think WP is better than Flectra web too. The CMS editor in Flectra web is nice but I prefer Drupal for customization and there is a Drupal module for Flectra. I think WP is better than Flectra web too.
@ -77,7 +73,6 @@ The CMS editor in Flectra web is nice but I prefer Drupal for customization and
<record id="article_0" model="forum.post"> <record id="article_0" model="forum.post">
<field name="content_link">https://www.flectra.com</field> <field name="content_link">https://www.flectra.com</field>
<field name="name">Discover Flectra, an open source ERP.</field> <field name="name">Discover Flectra, an open source ERP.</field>
<field name="website_id" ref="website.default_website"/>
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="post_type">link</field> <field name="post_type">link</field>
<field name="views">6</field> <field name="views">6</field>
@ -87,7 +82,6 @@ The CMS editor in Flectra web is nice but I prefer Drupal for customization and
<!-- Discussion--> <!-- Discussion-->
<record id="discussion_0" model="forum.post"> <record id="discussion_0" model="forum.post">
<field name="name">How to setup a regular PostgreSQL database backup</field> <field name="name">How to setup a regular PostgreSQL database backup</field>
<field name="website_id" ref="website.default_website"/>
<field name="content">I'm not familiar with PostgreSQL database administration , so I figured I might ask for help from someone more knowledgeable on the subject. <field name="content">I'm not familiar with PostgreSQL database administration , so I figured I might ask for help from someone more knowledgeable on the subject.
What would you recommend in order to setup a regular (daily) OpenERP database backup? What would you recommend in order to setup a regular (daily) OpenERP database backup?
@ -104,7 +98,6 @@ Are there any automation scripts available I might use?
<record id="reply_1" model="forum.post"> <record id="reply_1" model="forum.post">
<field name="forum_id" ref="website_forum.forum_help"/> <field name="forum_id" ref="website_forum.forum_help"/>
<field name="website_id" ref="website.default_website"/>
<field name="content"><![CDATA[<p>I use the following setup:</p> <field name="content"><![CDATA[<p>I use the following setup:</p>
<ol> <ol>
<li>Backup-Script</li> <li>Backup-Script</li>

View File

@ -41,6 +41,10 @@ class Forum(models.Model):
with misc.file_open('website_forum/data/forum_default_faq.html', 'r') as f: with misc.file_open('website_forum/data/forum_default_faq.html', 'r') as f:
return f.read() return f.read()
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
# description and use # description and use
name = fields.Char('Forum Name', required=True, translate=True) name = fields.Char('Forum Name', required=True, translate=True)
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
@ -131,8 +135,9 @@ class Forum(models.Model):
website_ids = fields.Many2many('website', 'website_forum_pub_rel', website_ids = fields.Many2many('website', 'website_forum_pub_rel',
'website_id', 'forum_id', 'website_id', 'forum_id',
string='Websites', copy=False, string='Websites', copy=False,
default=_default_website,
help='List of websites in which ' help='List of websites in which '
'Forum is published.') 'Forum will published.')
@api.one @api.one
@api.constrains('allow_question', 'allow_discussion', 'allow_link', 'default_post_type') @api.constrains('allow_question', 'allow_discussion', 'allow_link', 'default_post_type')
@ -276,8 +281,8 @@ class Post(models.Model):
can_post = fields.Boolean('Can Automatically be Validated', compute='_get_post_karma_rights') can_post = fields.Boolean('Can Automatically be Validated', compute='_get_post_karma_rights')
can_flag = fields.Boolean('Can Flag', compute='_get_post_karma_rights') can_flag = fields.Boolean('Can Flag', compute='_get_post_karma_rights')
can_moderate = fields.Boolean('Can Moderate', compute='_get_post_karma_rights') can_moderate = fields.Boolean('Can Moderate', compute='_get_post_karma_rights')
website_id = fields.Many2one('website', string="Website",
website_id = fields.Many2one('website', string="Website") default=lambda self: self.env.ref('website.default_website'))
def _search_can_view(self, operator, value): def _search_can_view(self, operator, value):
if operator not in ('=', '!=', '<>'): if operator not in ('=', '!=', '<>'):

View File

@ -4,26 +4,31 @@
<record id="hr.employee_niv" model="hr.employee"> <record id="hr.employee_niv" model="hr.employee">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="public_info">Designer, UI Expert</field> <field name="public_info">Designer, UI Expert</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="hr.employee_root" model="hr.employee"> <record id="hr.employee_root" model="hr.employee">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="public_info">Lean Management Expert</field> <field name="public_info">Lean Management Expert</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="hr.employee_qdp" model="hr.employee"> <record id="hr.employee_qdp" model="hr.employee">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="public_info">Designer, UI Expert</field> <field name="public_info">Designer, UI Expert</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="hr.employee_fpi" model="hr.employee"> <record id="hr.employee_fpi" model="hr.employee">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="public_info">Customer Service Oriented</field> <field name="public_info">Customer Service Oriented</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="hr.employee_al" model="hr.employee"> <record id="hr.employee_al" model="hr.employee">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="public_info">Like Coding</field> <field name="public_info">Like Coding</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="hr.employee_jgo" model="hr.employee"> <record id="hr.employee_jgo" model="hr.employee">

View File

@ -7,11 +7,17 @@ class HrEmployee(models.Model):
_name = 'hr.employee' _name = 'hr.employee'
_inherit = ['hr.employee', 'website.published.mixin'] _inherit = ['hr.employee', 'website.published.mixin']
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
public_info = fields.Char(string='Public Info') public_info = fields.Char(string='Public Info')
website_ids = fields.Many2many('website', 'website_hr_emp_pub_rel', website_ids = fields.Many2many('website', 'website_hr_emp_pub_rel',
'website_id', 'emp_id', 'website_id', 'emp_id',
default=_default_website,
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which Employee is published.') help='List of websites in which Employee '
'will published.')
@api.multi @api.multi
def _compute_website_url(self): def _compute_website_url(self):

View File

@ -11,7 +11,7 @@
<xpath expr="//div[hasclass('oe_structure')]" position="after"> <xpath expr="//div[hasclass('oe_structure')]" position="after">
<section class="container" id="team"> <section class="container" id="team">
<t t-set="is_publisher" t-value="request.env['res.users'].has_group('website.group_website_publisher')" /> <t t-set="is_publisher" t-value="request.env['res.users'].has_group('website.group_website_publisher')" />
<t t-set="employees_domain" t-value="[] if is_publisher else [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', website)]" /> <t t-set="employees_domain" t-value="[] if is_publisher else [('website_published', '=', True), ('website_ids', 'in', website)]" />
<t t-set="employees" t-value="request.env['hr.employee'].search(employees_domain)" /> <t t-set="employees" t-value="request.env['hr.employee'].search(employees_domain)" />
<div class="col-sm-12 text-center" t-if="len(employees)"> <div class="col-sm-12 text-center" t-if="len(employees)">
<h2>Our Team</h2> <h2>Our Team</h2>
@ -22,7 +22,7 @@
<t t-set="publish_edit" t-value="True"/> <t t-set="publish_edit" t-value="True"/>
</t> </t>
<div class="clearfix"/> <div class="clearfix"/>
<div class="emp" t-attf-data-publish="#{employee.website_published &amp; (not employee.website_ids or website in employee.website_ids) and 'on' or 'off'}"> <div class="emp" t-att-data-publish="employee.website_published and website in employee.website_ids and 'on' or 'off'}">
<img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow img-rounded"/> <img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow img-rounded"/>
<div class="mt8"> <div class="mt8">
<strong t-field="employee.name"></strong> <strong t-field="employee.name"></strong>

View File

@ -30,7 +30,7 @@ class WebsiteHrRecruitment(http.Controller):
# List jobs available to current UID # List jobs available to current UID
job_ids = Jobs.search([], order="website_published desc,no_of_recruitment desc").ids job_ids = Jobs.search([], order="website_published desc,no_of_recruitment desc").ids
if not request.env['res.users'].has_group('website.group_website_publisher'): if not request.env['res.users'].has_group('website.group_website_publisher'):
job_ids = Jobs.search(['|',('website_ids', '=', False), ('website_ids', 'in', request.website.id)], order="website_published desc, no_of_recruitment desc").ids job_ids = Jobs.search([('website_ids', 'in', request.website.id)], order="website_published desc, no_of_recruitment desc").ids
# Browse jobs as superuser, because address is restricted # Browse jobs as superuser, because address is restricted
jobs = Jobs.sudo().browse(job_ids) jobs = Jobs.sudo().browse(job_ids)
@ -81,6 +81,9 @@ class WebsiteHrRecruitment(http.Controller):
@http.route('/jobs/detail/<model("hr.job"):job>', type='http', auth="public", website=True) @http.route('/jobs/detail/<model("hr.job"):job>', type='http', auth="public", website=True)
def jobs_detail(self, job, **kwargs): def jobs_detail(self, job, **kwargs):
if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in job.website_ids.ids:
return request.render('website.404')
return request.render("website_hr_recruitment.detail", { return request.render("website_hr_recruitment.detail", {
'job': job, 'job': job,
'main_object': job, 'main_object': job,

View File

@ -3,6 +3,7 @@
<record id="hr.job_marketing" model="hr.job"> <record id="hr.job_marketing" model="hr.job">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="website_description" type="html"> <field name="website_description" type="html">
<section class="mt16 mb16 oe_dark"> <section class="mt16 mb16 oe_dark">
<div class="container"> <div class="container">
@ -135,6 +136,7 @@
<record id="hr.job_developer" model="hr.job"> <record id="hr.job_developer" model="hr.job">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="website_description" type="html"> <field name="website_description" type="html">
<section class="mt16 mb16 oe_dark"> <section class="mt16 mb16 oe_dark">
<div class="container"> <div class="container">
@ -268,6 +270,7 @@
<record id="hr.job_consultant" model="hr.job"> <record id="hr.job_consultant" model="hr.job">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="website_description" type="html"> <field name="website_description" type="html">
<section class="mt16 mb16 oe_dark"> <section class="mt16 mb16 oe_dark">
<div class="container"> <div class="container">

View File

@ -29,6 +29,7 @@ class RecruitmentSource(models.Model):
class Applicant(models.Model): class Applicant(models.Model):
_inherit = 'hr.applicant' _inherit = 'hr.applicant'
website_id = fields.Many2one('website', string="Website") website_id = fields.Many2one('website', string="Website")
def website_form_input_filter(self, request, values): def website_form_input_filter(self, request, values):
@ -46,11 +47,17 @@ class Job(models.Model):
default_description = self.env["ir.model.data"].xmlid_to_object("website_hr_recruitment.default_website_description") default_description = self.env["ir.model.data"].xmlid_to_object("website_hr_recruitment.default_website_description")
return (default_description.render() if default_description else "") return (default_description.render() if default_description else "")
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Html('Website description', translate=html_translate, sanitize_attributes=False, default=_get_default_website_description) website_description = fields.Html('Website description', translate=html_translate, sanitize_attributes=False, default=_get_default_website_description)
website_ids = fields.Many2many('website', 'website_hr_job_pub_rel', website_ids = fields.Many2many('website', 'website_hr_job_pub_rel',
'website_id', 'job_id', 'website_id', 'job_id',
default=_default_website,
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which Job is published.') help='List of websites in which Job '
'will published.')
@api.multi @api.multi
def _compute_website_url(self): def _compute_website_url(self):

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from flectra import models, fields, api, _ from flectra import models, fields
class LinkTracker(models.Model): class LinkTracker(models.Model):
_inherit = "link.tracker" _inherit = "link.tracker"
website_id = fields.Many2one('website', string="Link For Website") website_id = fields.Many2one('website', string='Website',
help='Define website in which this '
'link will enabled!')

View File

@ -12,24 +12,17 @@
</field> </field>
</record> </record>
<record id="view_link_tracker_filter" model="ir.ui.view"> <!-- Search -->
<field name="name">view.link.tracker.filter</field> <record id="view_link_tracker_filter_website" model="ir.ui.view">
<field name="name">Links</field>
<field name="model">link.tracker</field> <field name="model">link.tracker</field>
<field name="inherit_id" ref="link_tracker.view_link_tracker_filter"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Search Link Tracker"> <xpath expr="//field[@name='title']" position="after">
<separator/>
<filter name="website_id" string="Website" <filter name="website_id" string="Website"
context="{'group_by':'website_id'}"/> context="{'group_by':'website_id'}"/>
</search> </xpath>
</field> </field>
</record> </record>
<!-- Action for website links-->
<record model="ir.actions.act_window" id="link_tracker.action_link_tracker">
<field name="name">Link Tracker</field>
<field name="res_model">link.tracker</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="search_view_id" ref="view_link_tracker_filter"/>
</record>
</flectra> </flectra>

View File

@ -84,7 +84,6 @@
<label class="col-sm-3 control-label text-left hidden"> <label class="col-sm-3 control-label text-left hidden">
Website Website
</label> </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="hidden" id="website_id" class="form-control" t-att-value="website.id"/> <input type="hidden" id="website_id" class="form-control" t-att-value="website.id"/>
</div> </div>

View File

@ -43,7 +43,7 @@ class WebsiteMembership(http.Controller):
# base domain for groupby / searches # base domain for groupby / searches
base_line_domain = [ base_line_domain = [
("partner.website_published", "=", True), ('state', '=', 'paid'), ("partner.website_published", "=", True), ('state', '=', 'paid'),
'|', ('partner.website_ids', '=', False), ('partner.website_ids', 'in', request.website.id), ('partner.website_ids', 'in', request.website.id),
('date_to', '>=', today), ('date_from', '<=', today) ('date_to', '>=', today), ('date_from', '<=', today)
] ]
if membership_id and membership_id != 'free': if membership_id and membership_id != 'free':
@ -64,7 +64,7 @@ class WebsiteMembership(http.Controller):
if post_name: if post_name:
country_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)] country_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)]
countries = Partner.sudo().read_group(country_domain + [("website_published", "=", True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)], ["id", "country_id"], groupby="country_id", orderby="country_id") countries = Partner.sudo().read_group(country_domain + [("website_published", "=", True), ('website_ids', 'in', request.website.id)], ["id", "country_id"], groupby="country_id", orderby="country_id")
countries_total = sum(country_dict['country_id_count'] for country_dict in countries) countries_total = sum(country_dict['country_id_count'] for country_dict in countries)
line_domain = list(base_line_domain) line_domain = list(base_line_domain)
@ -107,7 +107,7 @@ class WebsiteMembership(http.Controller):
if request.env.ref('website_membership.opt_index_google_map').customize_show: if request.env.ref('website_membership.opt_index_google_map').customize_show:
google_map_partner_ids = MembershipLine.search(line_domain).get_published_companies(limit=2000) google_map_partner_ids = MembershipLine.search(line_domain).get_published_companies(limit=2000)
search_domain = [('membership_state', '=', 'free'), ('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id),] search_domain = [('membership_state', '=', 'free'), ('website_published', '=', True), ('website_ids', 'in', request.website.id)]
if post_name: if post_name:
search_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)] search_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)]
if country_id: if country_id:
@ -168,7 +168,7 @@ class WebsiteMembership(http.Controller):
_, partner_id = unslug(partner_id) _, partner_id = unslug(partner_id)
if partner_id: if partner_id:
partner = request.env['res.partner'].sudo().browse(partner_id) partner = request.env['res.partner'].sudo().browse(partner_id)
if partner.exists() and partner.website_published and not partner.website_ids or request.website in partner.website_ids: # TODO should be done with access rules if partner.exists() and partner.website_published and request.website in partner.website_ids: # TODO should be done with access rules
values = {} values = {}
values['main_object'] = values['partner'] = partner values['main_object'] = values['partner'] = partner
return request.render("website_membership.partner", values) return request.render("website_membership.partner", values)

View File

@ -13,6 +13,9 @@ class WebsitePartnerPage(http.Controller):
_, partner_id = unslug(partner_id) _, partner_id = unslug(partner_id)
if partner_id: if partner_id:
partner_sudo = request.env['res.partner'].sudo().browse(partner_id) partner_sudo = request.env['res.partner'].sudo().browse(partner_id)
if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in partner_sudo.website_ids.ids:
return request.render('website.404')
is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher') is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher')
if partner_sudo.exists() and (partner_sudo.website_published or is_website_publisher): if partner_sudo.exists() and (partner_sudo.website_published or is_website_publisher):
values = { values = {

View File

@ -3,56 +3,45 @@
<record id="base.partner_root" model="res.partner"> <record id="base.partner_root" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.partner_demo" model="res.partner"> <record id="base.partner_demo" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_12" model="res.partner"> <record id="base.res_partner_12" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_12" model="res.partner"> <record id="base.res_partner_12" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_2" model="res.partner"> <record id="base.res_partner_2" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_1" model="res.partner"> <record id="base.res_partner_1" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_12" model="res.partner"> <record id="base.res_partner_12" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_3" model="res.partner"> <record id="base.res_partner_3" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_3" model="res.partner"> <record id="base.res_partner_3" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_2" model="res.partner"> <record id="base.res_partner_2" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_18" model="res.partner"> <record id="base.res_partner_18" model="res.partner">
<field name="website_published">True</field> <field name="website_published">True</field>
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
</record> </record>
<record id="base.res_partner_10" model="res.partner"> <record id="base.res_partner_10" model="res.partner">

View File

@ -8,13 +8,18 @@ class WebsiteResPartner(models.Model):
_name = 'res.partner' _name = 'res.partner'
_inherit = ['res.partner', 'website.seo.metadata', 'website.published.mixin'] _inherit = ['res.partner', 'website.seo.metadata', 'website.published.mixin']
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Html('Website Partner Full Description', strip_style=True) website_description = fields.Html('Website Partner Full Description', strip_style=True)
website_short_description = fields.Text('Website Partner Short Description') website_short_description = fields.Text('Website Partner Short Description')
website_ids = fields.Many2many('website', 'website_partner_pub_rel', website_ids = fields.Many2many('website', 'website_partner_pub_rel',
'website_id', 'partner_id', 'website_id', 'partner_id',
string='Websites', copy=False, string='Websites', copy=False,
default=_default_website,
help='List of websites in which ' help='List of websites in which '
'Partner is published.') 'Partner will published.')
@api.multi @api.multi
def _compute_website_url(self): def _compute_website_url(self):

View File

@ -5,6 +5,6 @@ from flectra import fields, models
class PaymentAcquirer(models.Model): class PaymentAcquirer(models.Model):
_inherit = "payment.acquirer" _inherit = "payment.acquirer"
website_id = fields.Many2many('website', 'website_payment_rel', website_id = fields.Many2one('website', string='Website', copy=False,
'website_id', 'payment_id', help='Define website in which Payment '
string='Website') 'Gateway will published.')

View File

@ -25,7 +25,7 @@
<field name="inherit_id" ref="payment.acquirer_form"/> <field name="inherit_id" ref="payment.acquirer_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='provider']" position='after'> <xpath expr="//field[@name='provider']" position='after'>
<field name="website_id" widget="many2many_tags"/> <field name="website_id"/>
</xpath> </xpath>
<xpath expr="//group[@name='acquirer_left']" position="after"> <xpath expr="//group[@name='acquirer_left']" position="after">
<group nama="acquirer_right"> <group nama="acquirer_right">

View File

@ -191,7 +191,7 @@ class WebsiteSale(http.Controller):
if attrib: if attrib:
domain += [('attribute_line_ids.value_ids', 'in', ids)] domain += [('attribute_line_ids.value_ids', 'in', ids)]
if not request.env.user.has_group('website.group_website_publisher'): if not request.env.user.has_group('website.group_website_publisher'):
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)] domain += [('website_ids', 'in', request.website.id)]
if tag_values: if tag_values:
domain += [('tag_ids', 'in', tag_values)] domain += [('tag_ids', 'in', tag_values)]
@ -245,10 +245,8 @@ class WebsiteSale(http.Controller):
post["search"] = search post["search"] = search
if category: if category:
category = request.env['product.public.category'].browse(int(category)) category = request.env['product.public.category'].browse(int(category))
website = [] if not category.website_ids or \
for web in category.website_ids: request.website.id not in category.website_ids.ids:
website.append(web.id)
if request.website.id not in website:
return request.render('website.404') return request.render('website.404')
url = "/shop/category/%s" % slug(category) url = "/shop/category/%s" % slug(category)
if attrib_list: if attrib_list:
@ -320,6 +318,9 @@ class WebsiteSale(http.Controller):
@http.route(['/shop/product/<model("product.template"):product>'], type='http', auth="public", website=True) @http.route(['/shop/product/<model("product.template"):product>'], type='http', auth="public", website=True)
def product(self, product, category='', search='', **kwargs): def product(self, product, category='', search='', **kwargs):
if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in product.website_ids.ids:
return request.render('website.404')
product_context = dict(request.env.context, product_context = dict(request.env.context,
active_id=product.id, active_id=product.id,
partner=request.env.user.partner_id) partner=request.env.user.partner_id)
@ -364,7 +365,7 @@ class WebsiteSale(http.Controller):
@http.route(['/shop/change_pricelist/<model("product.pricelist"):pl_id>'], type='http', auth="public", website=True) @http.route(['/shop/change_pricelist/<model("product.pricelist"):pl_id>'], type='http', auth="public", website=True)
def pricelist_change(self, pl_id, **post): def pricelist_change(self, pl_id, **post):
if (pl_id.website_id or pl_id == request.env.user.partner_id.property_product_pricelist) \ if (pl_id.selectable or pl_id == request.env.user.partner_id.property_product_pricelist) \
and request.website.is_pricelist_available(pl_id.id): and request.website.is_pricelist_available(pl_id.id):
request.session['website_sale_current_pl'] = pl_id.id request.session['website_sale_current_pl'] = pl_id.id
request.website.sale_get_order(force_pricelist=pl_id.id) request.website.sale_get_order(force_pricelist=pl_id.id)
@ -790,7 +791,7 @@ class WebsiteSale(http.Controller):
) )
acquirers = request.env['payment.acquirer'].search( acquirers = request.env['payment.acquirer'].search(
[('website_published', '=', True), ('company_id', '=', order.company_id.id), '|', ('website_id', '=', False), ('website_id', '=', request.website.id)] [('website_published', '=', True), ('company_id', '=', order.company_id.id), ('website_id', '=', request.website.id)]
) )
values['access_token'] = order.access_token values['access_token'] = order.access_token
@ -798,7 +799,7 @@ class WebsiteSale(http.Controller):
values['s2s_acquirers'] = [acq for acq in acquirers if acq.payment_flow == 's2s' and acq.registration_view_template_id] values['s2s_acquirers'] = [acq for acq in acquirers if acq.payment_flow == 's2s' and acq.registration_view_template_id]
values['tokens'] = request.env['payment.token'].search( values['tokens'] = request.env['payment.token'].search(
[('partner_id', '=', order.partner_id.id), [('partner_id', '=', order.partner_id.id),
('acquirer_id', 'in', [acq.id for acq in values['s2s_acquirers']])]) ('acquirer_id', 'in', acquirers.ids)])
for acq in values['form_acquirers']: for acq in values['form_acquirers']:
acq.form = acq.with_context(submit_class='btn btn-primary', submit_txt=_('Pay Now')).sudo().render( acq.form = acq.with_context(submit_class='btn btn-primary', submit_txt=_('Pay Now')).sudo().render(

View File

@ -29,6 +29,11 @@
<field name="salesteam_id" ref="sales_team.salesteam_website_sales"/> <field name="salesteam_id" ref="sales_team.salesteam_website_sales"/>
</record> </record>
<record model="product.pricelist" id="product.list0">
<field name="selectable" eval="False" />
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record>
</data> </data>
<data> <data>
<record id="sale.model_sale_order" model="ir.model"> <record id="sale.model_sale_order" model="ir.model">

View File

@ -630,75 +630,99 @@ Weight: 31 grams</field>
<record id="product.product_product_1_product_template" model="product.template"> <record id="product.product_product_1_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_2_product_template" model="product.template"> <record id="product.product_product_2_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_3_product_template" model="product.template"> <record id="product.product_product_3_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_4_product_template" model="product.template"> <record id="product.product_product_4_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_5_product_template" model="product.template"> <record id="product.product_product_5_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_5b_product_template" model="product.template"> <record id="product.product_product_5b_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Speakers')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Speakers')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_6_product_template" model="product.template"> <record id="product.product_product_6_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Screen')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Screen')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_7_product_template" model="product.template"> <record id="product.product_product_7_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Headset')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Headset')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_8_product_template" model="product.template"> <record id="product.product_product_8_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_9_product_template" model="product.template"> <record id="product.product_product_9_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_10_product_template" model="product.template"> <record id="product.product_product_10_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_11_product_template" model="product.template"> <record id="product.product_product_11_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Computer_all_in_one')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_12_product_template" model="product.template"> <record id="product.product_product_12_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_13_product_template" model="product.template"> <record id="product.product_product_13_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_16_product_template" model="product.template"> <record id="product.product_product_16_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_17_product_template" model="product.template"> <record id="product.product_product_17_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_20_product_template" model="product.template"> <record id="product.product_product_20_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_22_product_template" model="product.template"> <record id="product.product_product_22_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_24_product_template" model="product.template"> <record id="product.product_product_24_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_25_product_template" model="product.template"> <record id="product.product_product_25_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_product_27_product_template" model="product.template"> <record id="product.product_product_27_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_delivery_02_product_template" model="product.template"> <record id="product.product_delivery_02_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('External_Hard_Drive')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('External_Hard_Drive')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_order_01_product_template" model="product.template"> <record id="product.product_order_01_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Software')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Software')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_delivery_01_product_template" model="product.template"> <record id="product.product_delivery_01_product_template" model="product.template">
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/> <field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
<record id="product.product_attribute_value_3" model="product.attribute.value"> <record id="product.product_attribute_value_3" model="product.attribute.value">
<field name="html_color">#FFFFFF</field> <field name="html_color">#FFFFFF</field>
@ -709,7 +733,8 @@ Weight: 31 grams</field>
<record model="product.pricelist" id="product.list0"> <record model="product.pricelist" id="product.list0">
<field name="name">USD</field> <field name="name">USD</field>
<!--<field name="website_id" eval="[(6, 0, [ref('website.default_website').id])]"/>--> <field name="selectable" eval="True" />
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="sequence">3</field> <field name="sequence">3</field>
<field name="currency_id" ref="base.USD"/> <field name="currency_id" ref="base.USD"/>
</record> </record>
@ -722,7 +747,8 @@ Weight: 31 grams</field>
<record id="list_christmas" model="product.pricelist"> <record id="list_christmas" model="product.pricelist">
<field name="name">Christmas</field> <field name="name">Christmas</field>
<!--<field name="website_id" eval="[(6, 0, [ref('website.default_website').id])]"/>--> <field name="selectable" eval="False" />
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="country_group_ids" eval="[(6,0,[ref('base.europe')])]" /> <field name="country_group_ids" eval="[(6,0,[ref('base.europe')])]" />
<field name="sequence">20</field> <field name="sequence">20</field>
</record> </record>
@ -735,7 +761,8 @@ Weight: 31 grams</field>
<record id="list_benelux" model="product.pricelist"> <record id="list_benelux" model="product.pricelist">
<field name="name">Benelux</field> <field name="name">Benelux</field>
<!--<field name="website_id" eval="[(6, 0, [ref('website.default_website').id])]"/>--> <field name="selectable" eval="False" />
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="country_group_ids" eval="[(6,0,[ref('benelux')])]" /> <field name="country_group_ids" eval="[(6,0,[ref('benelux')])]" />
<field name="sequence">2</field> <field name="sequence">2</field>
</record> </record>
@ -750,7 +777,8 @@ Weight: 31 grams</field>
<record id="list_europe" model="product.pricelist"> <record id="list_europe" model="product.pricelist">
<field name="name">EUR</field> <field name="name">EUR</field>
<!--<field name="website_id" eval="[(6, 0, [ref('website.default_website').id])]"/>--> <field name="selectable" eval="False" />
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
<field name="country_group_ids" eval="[(6,0,[ref('base.europe')])]" /> <field name="country_group_ids" eval="[(6,0,[ref('base.europe')])]" />
<field name="sequence">3</field> <field name="sequence">3</field>
<field name="currency_id" ref="base.EUR"/> <field name="currency_id" ref="base.EUR"/>

View File

@ -10,10 +10,11 @@ from flectra.tools import float_is_zero
class ProductTags(models.Model): class ProductTags(models.Model):
_name = 'product.tags' _name = 'product.tags'
_description = 'Product Tags'
_order = 'sequence' _order = 'sequence'
sequence = fields.Integer(help="Gives the sequence order when " sequence = fields.Integer(help="Gives the sequence order when "
"displaying a list of rules.") "displaying a list of tags.")
name = fields.Char(string='Name', required=True, translate=True) name = fields.Char(string='Name', required=True, translate=True)
_sql_constraints = [('name_uniq', 'unique (name)', _sql_constraints = [('name_uniq', 'unique (name)',
@ -26,7 +27,7 @@ class ProductBrand(models.Model):
_order = 'sequence' _order = 'sequence'
sequence = fields.Integer(help="Gives the sequence order when displaying " sequence = fields.Integer(help="Gives the sequence order when displaying "
"a list of rules.") "a list of brands.")
name = fields.Char(string='Name', required=True, translate=True) name = fields.Char(string='Name', required=True, translate=True)
brand_image = fields.Binary(string='Brand Image') brand_image = fields.Binary(string='Brand Image')
@ -36,7 +37,7 @@ class ProductBrand(models.Model):
class ProductRibbon(models.Model): class ProductRibbon(models.Model):
_name = 'product.ribbon' _name = 'product.ribbon'
_description = 'Product Brand' _description = 'Product Ribbon'
_order = 'name' _order = 'name'
name = fields.Char(string='Name', size=20, required=True, translate=True) name = fields.Char(string='Name', size=20, required=True, translate=True)
@ -44,29 +45,30 @@ class ProductRibbon(models.Model):
ribbon_color_text = fields.Char(string='Font Color', required=True) ribbon_color_text = fields.Char(string='Font Color', required=True)
class ProductStyle(models.Model): class ProductViewLimit(models.Model):
_name = "product.style" _name = 'product.view.limit'
_order = 'sequence'
name = fields.Char(string='Style Name', required=True) sequence = fields.Integer(help="Gives the sequence order when "
html_class = fields.Char(string='HTML Classes') "displaying a list of rules.")
name = fields.Integer(string='Limit', required=True)
_sql_constraints = [('name', 'unique(name)', 'This must be unique!')]
class WebsitePriceList(models.Model):
_name = "website.product.pricelist"
pricelist_id = fields.Many2one('product.pricelist',
string='Website Pricelist')
website_id = fields.Many2one('website', string='Website')
selectable = fields.Boolean(string="selectable", default=True)
class ProductPricelist(models.Model): class ProductPricelist(models.Model):
_inherit = "product.pricelist" _inherit = "product.pricelist"
def _default_website(self): def _default_website(self):
return self.env['website'].search([], limit=1) default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_id = fields.One2many('website.product.pricelist', 'pricelist_id', string='Website') website_ids = fields.Many2many('website', 'website_pricelist_rule_rel',
'pricelist_id', 'website_id',
string="website", default=_default_website,
help='List of websites in which price-list '
'will published.')
selectable = fields.Boolean(help="Allow the end user to choose this price list")
code = fields.Char(string='E-commerce Promotional Code', groups="base.group_user") code = fields.Char(string='E-commerce Promotional Code', groups="base.group_user")
def clear_cache(self): def clear_cache(self):
@ -95,24 +97,16 @@ class ProductPricelist(models.Model):
return res return res
class WebsiteProductLimit(models.Model):
_name = 'product.view.limit'
_order = 'sequence'
sequence = fields.Integer(help="Gives the sequence order when "
"displaying a list of rules.")
name = fields.Integer(string='Limit', required=True)
_sql_constraints = [('name', 'unique(name)', 'This must be unique!')]
class ProductPublicCategory(models.Model): class ProductPublicCategory(models.Model):
_name = "product.public.category" _name = "product.public.category"
_inherit = ["website.seo.metadata"] _inherit = ["website.seo.metadata"]
_description = "Website Product Category" _description = "Website Product Category"
_order = "sequence, name" _order = "sequence, name"
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
name = fields.Char(required=True, translate=True) name = fields.Char(required=True, translate=True)
parent_id = fields.Many2one('product.public.category', string='Parent Category', index=True) parent_id = fields.Many2one('product.public.category', string='Parent Category', index=True)
child_id = fields.One2many('product.public.category', 'parent_id', string='Children Categories') child_id = fields.One2many('product.public.category', 'parent_id', string='Children Categories')
@ -133,15 +127,17 @@ class ProductPublicCategory(models.Model):
"Use this field anywhere a small image is required.") "Use this field anywhere a small image is required.")
website_ids = fields.Many2many('website', 'website_prod_public_categ_rel', website_ids = fields.Many2many('website', 'website_prod_public_categ_rel',
'website_id', 'category_id', 'website_id', 'category_id',
default=_default_website,
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which ' help='List of websites in which '
'category is published.') 'category will published.')
@api.model @api.model
def create(self, vals): def create(self, vals):
tools.image_resize_images(vals) tools.image_resize_images(vals)
res = super(ProductPublicCategory, self).create(vals) res = super(ProductPublicCategory, self).create(vals)
# @todo Check different test-case: child & parent category # @todo Flectra:
# Multi-Website: Check different test-cases for child & parent category
if res.parent_id: if res.parent_id:
res.parent_id.write({ res.parent_id.write({
'website_ids': [(4, website_id.id) for website_id in res.website_ids] 'website_ids': [(4, website_id.id) for website_id in res.website_ids]
@ -152,7 +148,8 @@ class ProductPublicCategory(models.Model):
def write(self, vals): def write(self, vals):
tools.image_resize_images(vals) tools.image_resize_images(vals)
res = super(ProductPublicCategory, self).write(vals) res = super(ProductPublicCategory, self).write(vals)
# @todo Check different test-case: child & parent category # @todo Flectra:
# Multi-Website: Check different test-cases for child & parent category
if self.parent_id and self.website_ids.ids: if self.parent_id and self.website_ids.ids:
self.parent_id.write({ self.parent_id.write({
'website_ids': [(4, website_id.id) for website_id in self.website_ids] 'website_ids': [(4, website_id.id) for website_id in self.website_ids]
@ -190,6 +187,10 @@ class ProductTemplate(models.Model):
_name = 'product.template' _name = 'product.template'
_mail_post_access = 'read' _mail_post_access = 'read'
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Html('Description for the website', sanitize_attributes=False, translate=html_translate) website_description = fields.Html('Description for the website', sanitize_attributes=False, translate=html_translate)
alternative_product_ids = fields.Many2many('product.template', 'product_alternative_rel', 'src_id', 'dest_id', alternative_product_ids = fields.Many2many('product.template', 'product_alternative_rel', 'src_id', 'dest_id',
string='Alternative Products', help='Suggest more expensive alternatives to ' string='Alternative Products', help='Suggest more expensive alternatives to '
@ -214,11 +215,12 @@ class ProductTemplate(models.Model):
website_ids = fields.Many2many('website', 'website_prod_pub_rel', website_ids = fields.Many2many('website', 'website_prod_pub_rel',
'website_id', 'product_id', 'website_id', 'product_id',
string='Websites', copy=False, string='Websites', copy=False,
default=_default_website,
help='List of websites in which ' help='List of websites in which '
'Product is published.') 'Product will published.')
ribbon_id = fields.Many2one('product.ribbon', string='Product Ribbon') ribbon_id = fields.Many2one('product.ribbon', string="Product Ribbon")
brand_id = fields.Many2one('product.brand', string="Product's Brand") brand_id = fields.Many2one('product.brand', string="Product Brand")
tag_ids = fields.Many2many('product.tags', string='Product Tags') tag_ids = fields.Many2many('product.tags', string="Product Tags")
def _website_price(self): def _website_price(self):
# First filter out the ones that have no variant: # First filter out the ones that have no variant:
@ -267,11 +269,6 @@ class ProductTemplate(models.Model):
class Product(models.Model): class Product(models.Model):
_inherit = "product.product" _inherit = "product.product"
def _get_default_website_ids(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_ids = fields.Many2many('website', string="Publish Product On Website", default=_get_default_website_ids)
website_price = fields.Float('Website price', compute='_website_price', digits=dp.get_precision('Product Price')) website_price = fields.Float('Website price', compute='_website_price', digits=dp.get_precision('Product Price'))
website_public_price = fields.Float('Website public price', compute='_website_price', digits=dp.get_precision('Product Price')) website_public_price = fields.Float('Website public price', compute='_website_price', digits=dp.get_precision('Product Price'))
website_price_difference = fields.Boolean('Website price difference', compute='_website_price') website_price_difference = fields.Boolean('Website price difference', compute='_website_price')

View File

@ -17,14 +17,12 @@ class Website(models.Model):
currency_id = fields.Many2one('res.currency', related='pricelist_id.currency_id', string='Default Currency') currency_id = fields.Many2one('res.currency', related='pricelist_id.currency_id', string='Default Currency')
salesperson_id = fields.Many2one('res.users', string='Salesperson') salesperson_id = fields.Many2one('res.users', string='Salesperson')
salesteam_id = fields.Many2one('crm.team', string='Sales Channel') salesteam_id = fields.Many2one('crm.team', string='Sales Channel')
pricelist_ids = fields.One2many('website.product.pricelist', compute="_compute_pricelist_ids", pricelist_ids = fields.One2many('product.pricelist', compute="_compute_pricelist_ids",
string='Price list available for this Ecommerce/Website') string='Price list available for this Ecommerce/Website')
@api.one @api.one
def _compute_pricelist_ids(self): def _compute_pricelist_ids(self):
for website in self: self.pricelist_ids = self.env["product.pricelist"].search([("website_ids", "in", self.id)])
website.pricelist_ids = website.env["website.product.pricelist"].search([("website_id", "=", website.id)])
# self.pricelist_ids = self.env["product.pricelist"].search([("website_id", "=", self.id)])
@api.multi @api.multi
def _compute_pricelist_id(self): def _compute_pricelist_id(self):
@ -34,8 +32,8 @@ class Website(models.Model):
website.pricelist_id = website.get_current_pricelist() website.pricelist_id = website.get_current_pricelist()
# This method is cached, must not return records! See also #8795 # This method is cached, must not return records! See also #8795
@tools.ormcache('self.env.uid', 'country_code', 'show_visible', 'website_pl', 'current_pl', 'all_pls', 'partner_pl', 'order_pl') @tools.ormcache('self.env.uid', 'country_code', 'show_visible', 'website_pl', 'current_pl', 'all_pl', 'partner_pl', 'order_pl')
def _get_pl_partner_order(self, country_code, show_visible, website_pl, current_pl, all_pls, partner_pl=False, order_pl=False): def _get_pl_partner_order(self, country_code, show_visible, website_pl, current_pl, all_pl, partner_pl=False, order_pl=False):
""" Return the list of pricelists that can be used on website for the current user. """ Return the list of pricelists that can be used on website for the current user.
:param str country_code: code iso or False, If set, we search only price list available for this country :param str country_code: code iso or False, If set, we search only price list available for this country
:param bool show_visible: if True, we don't display pricelist where selectable is False (Eg: Code promo) :param bool show_visible: if True, we don't display pricelist where selectable is False (Eg: Code promo)
@ -51,21 +49,19 @@ class Website(models.Model):
if country_code: if country_code:
for cgroup in self.env['res.country.group'].search([('country_ids.code', '=', country_code)]): for cgroup in self.env['res.country.group'].search([('country_ids.code', '=', country_code)]):
for group_pricelists in cgroup.pricelist_ids: for group_pricelists in cgroup.pricelist_ids:
if not show_visible or group_pricelists.website_id.filtered(lambda web_pl: web_pl.website_id == self.get_current_website() and web_pl.selectable) or group_pricelists.id in (current_pl, order_pl): if not show_visible or group_pricelists.selectable or group_pricelists.id in (current_pl, order_pl):
pricelists |= group_pricelists pricelists |= group_pricelists
partner = self.env.user.partner_id partner = self.env.user.partner_id
is_public = self.user_id.id == self.env.user.id is_public = self.user_id.id == self.env.user.id
if not is_public and (not pricelists or (partner_pl or partner.property_product_pricelist.id) != website_pl): if not is_public and (not pricelists or (partner_pl or partner.property_product_pricelist.id) != website_pl):
if partner.property_product_pricelist.website_id: if partner.property_product_pricelist.website_ids:
pricelists |= partner.property_product_pricelist pricelists |= partner.property_product_pricelist
if not pricelists: # no pricelist for this country, or no GeoIP if not pricelists: # no pricelist for this country, or no GeoIP
for all_pl in all_pls: pricelists |= all_pl.filtered(lambda pl: not show_visible or pl.selectable or pl.id in (current_pl, order_pl))
pricelists |= all_pl.pricelist_id.filtered(lambda pl: not show_visible or (all_pl.pricelist_id == pl and all_pl.selectable) or pl.id in (current_pl, order_pl))
else: else:
for all_pl in all_pls: pricelists |= all_pl.filtered(lambda pl: not show_visible and pl.sudo().code)
pricelists |= all_pl.pricelist_id.filtered(lambda pl: not show_visible and pl.sudo().code)
# This method is cached, must not return records! See also #8795 # This method is cached, must not return records! See also #8795
return pricelists.ids return pricelists.ids

View File

@ -18,9 +18,7 @@ access_account_tax_user,account.tax,account.model_account_tax,base.group_public,
access_product_image_public,product.image public,model_product_image,,1,0,0,0 access_product_image_public,product.image public,model_product_image,,1,0,0,0
access_product_image_publisher,product.image wbesite publisher,model_product_image,website.group_website_publisher,1,1,1,1 access_product_image_publisher,product.image wbesite publisher,model_product_image,website.group_website_publisher,1,1,1,1
access_product_image_sale,product.image sale,model_product_image,sales_team.group_sale_manager,1,1,1,1 access_product_image_sale,product.image sale,model_product_image,sales_team.group_sale_manager,1,1,1,1
access_website_product_pricelist,access_website_product_pricelist,model_website_product_pricelist,,1,0,0,0
access_product_view_limit,access_product_view_limit,model_product_view_limit,,1,0,0,0 access_product_view_limit,access_product_view_limit,model_product_view_limit,,1,0,0,0
access_product_ribbon,product_ribbon,model_product_ribbon,,1,0,0,0 access_product_ribbon,product_ribbon,model_product_ribbon,,1,0,0,0
access_product_tags,access_product_tags,model_product_tags,,1,0,0,0 access_product_tags,access_product_tags,model_product_tags,,1,0,0,0
access_product_brand,access_product_brand,model_product_brand,,1,0,0,0 access_product_brand,access_product_brand,model_product_brand,,1,0,0,0
access_product_style,access_product_style,model_product_style,,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
18 access_product_image_public product.image public model_product_image 1 0 0 0
19 access_product_image_publisher product.image wbesite publisher model_product_image website.group_website_publisher 1 1 1 1
20 access_product_image_sale product.image sale model_product_image sales_team.group_sale_manager 1 1 1 1
access_website_product_pricelist access_website_product_pricelist model_website_product_pricelist 1 0 0 0
21 access_product_view_limit access_product_view_limit model_product_view_limit 1 0 0 0
22 access_product_ribbon product_ribbon model_product_ribbon 1 0 0 0
23 access_product_tags access_product_tags model_product_tags 1 0 0 0
24 access_product_brand access_product_brand model_product_brand 1 0 0 0
access_product_style access_product_style model_product_style 1 0 0 0

View File

@ -19,33 +19,25 @@ class TestWebsitePriceList(TransactionCase):
self.website = self.env['website'].browse(1) self.website = self.env['website'].browse(1)
self.website.user_id = self.env.user self.website.user_id = self.env.user
self.env['product.pricelist'].search([]).write({'website_id': False}) self.env['product.pricelist'].search([]).write({'website_ids': []})
website_pls = ('list_benelux', 'list_christmas', 'list_europe') website_pls = ('list_benelux', 'list_christmas', 'list_europe')
for pl in website_pls: for pl in website_pls:
self.env['website.product.pricelist'].create({ self.env.ref('website_sale.' + pl).website_ids = [(6, 0, [self.website.id])]
'pricelist_id': self.env.ref('website_sale.' + pl).id, self.env.ref('product.list0').website_ids = [(6, 0, [self.website.id])]
'website_id': self.website.id, self.env.ref('website_sale.list_benelux').selectable = True
'selectable': False if pl == 'list_christmas' else True
})
self.env['website.product.pricelist'].create({
'pricelist_id': self.env.ref('product.list0').id,
'website_id': self.website.id
})
self.website.pricelist_id = self.ref('product.list0') self.website.pricelist_id = self.ref('product.list0')
ca_group = self.env['res.country.group'].create({ ca_group = self.env['res.country.group'].create({
'name': 'Canada', 'name': 'Canada',
'country_ids': [(6, 0, [self.ref('base.ca')])] 'country_ids': [(6, 0, [self.ref('base.ca')])]
}) })
ppl = self.env['product.pricelist'].create({ self.env['product.pricelist'].create({
'name': 'Canada', 'name': 'Canada',
'selectable': True,
'website_ids': [(6, 0, [self.website.id])],
'country_group_ids': [(6, 0, [ca_group.id])], 'country_group_ids': [(6, 0, [ca_group.id])],
'sequence': 10 'sequence': 10
}) })
self.env['website.product.pricelist'].create({
'pricelist_id': ppl.id,
'website_id': self.website.id
})
patcher = patch('flectra.addons.website_sale.models.website.Website.get_pricelist_available', wraps=self._get_pricelist_available) patcher = patch('flectra.addons.website_sale.models.website.Website.get_pricelist_available', wraps=self._get_pricelist_available)
patcher.start() patcher.start()
self.addCleanup(patcher.stop) self.addCleanup(patcher.stop)
@ -126,7 +118,7 @@ class TestWebsitePriceList(TransactionCase):
country_list = { country_list = {
False: ['USD', 'EUR', 'Benelux', 'Canada'], False: ['USD', 'EUR', 'Benelux', 'Canada'],
'BE': ['EUR', 'Benelux'], 'BE': ['EUR', 'Benelux'],
'IT': ['EUR'], 'IT': ['Benelux', 'USD', 'Canada'],
'CA': ['EUR', 'Canada'], 'CA': ['EUR', 'Canada'],
'US': ['USD', 'EUR', 'Benelux', 'Canada'] 'US': ['USD', 'EUR', 'Benelux', 'Canada']
} }

View File

@ -75,8 +75,8 @@
<field name="ribbon_id"/> <field name="ribbon_id"/>
<field name="tag_ids" widget="many2many_tags"/> <field name="tag_ids" widget="many2many_tags"/>
<field name="brand_id" options="{'no_create': True}"/> <field name="brand_id" options="{'no_create': True}"/>
<field name="website_ids" widget="many2many_tags"/>
</group> </group>
<field name="website_ids"/>
</group> </group>
<button name="toggle_active" position="before"> <button name="toggle_active" position="before">
<button class="oe_stat_button" name="website_publish_button" <button class="oe_stat_button" name="website_publish_button"
@ -197,12 +197,20 @@
<field name="model">product.pricelist</field> <field name="model">product.pricelist</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name='currency_id' position='after'> <field name='currency_id' position='after'>
<field name="website_id" string='Allow to use on '> <field name="selectable"/>
<tree editable='bottom' string="Website Store"> <field name="website_ids" string='Allow to use on '
<field name="website_id"/> widget="many2many_tags"/>
<field name="selectable"/> </field>
</tree> </field>
</field> </record>
<record id="website_sale_pricelist_tree_view" model="ir.ui.view">
<field name="name">product.pricelist.tree.inherit.product</field>
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view_tree"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="selectable" />
</field> </field>
</field> </field>
</record> </record>
@ -338,7 +346,6 @@
</field> </field>
</record> </record>
<!-- Product Brand Action --> <!-- Product Brand Action -->
<record id="product_by_brand_action" model="ir.actions.act_window"> <record id="product_by_brand_action" model="ir.actions.act_window">
<field name="name">Brands</field> <field name="name">Brands</field>

View File

@ -131,11 +131,6 @@
action="base.action_partner_customer_form" action="base.action_partner_customer_form"
parent="menu_orders" sequence="4"/> parent="menu_orders" sequence="4"/>
<!-- Product Limit Menu -->
<menuitem action="website_product_limit_action" id="menu_view_limit"
name="Website Product View Limit" parent="website_sale.menu_ecommerce_settings"/>
<!-- <menuitem id="menu_orders_invoices" name="Invoices" parent="menu_orders" action="action_invoices_ecommerce" sequence="4"/> --> <!-- <menuitem id="menu_orders_invoices" name="Invoices" parent="menu_orders" action="action_invoices_ecommerce" sequence="4"/> -->
<!-- Catalog sub-menus --> <!-- Catalog sub-menus -->
@ -156,11 +151,15 @@
<!-- Product Brands Menu --> <!-- Product Brands Menu -->
<menuitem action="product_by_brand_action" id="menu_product_by_brand" <menuitem action="product_by_brand_action" id="menu_product_by_brand"
parent="website_sale.menu_catalog"/> name="Brands" parent="website_sale.menu_product_settings"/>
<!-- Product Tags Menu --> <!-- Product Tags Menu -->
<menuitem action="product_tags_action" id="menu_product_tags" name="Tags" <menuitem action="product_tags_action" id="menu_product_tags"
parent="website_sale.menu_catalog"/> name="Tags" parent="website_sale.menu_product_settings"/>
<!-- Product Limit Menu -->
<menuitem action="website_product_limit_action" id="menu_view_limit"
name="Product View Limit per Page" parent="website_sale.menu_ecommerce_settings"/>
<!-- Configuration sub-menus --> <!-- Configuration sub-menus -->
<menuitem id="menu_ecommerce_payment_acquirers" <menuitem id="menu_ecommerce_payment_acquirers"

View File

@ -212,7 +212,7 @@
<t t-foreach="products" t-as="product"> <t t-foreach="products" t-as="product">
<div id="grid_list" <div id="grid_list"
class="col-md-4 oe_product oe_grid oe_product_cart oe-height-4" class="col-md-4 oe_product oe_grid oe_product_cart oe-height-4"
t-attf-data-publish="#{product.website_published &amp; (not product.website_ids or website in product.website_ids) and 'on' or 'off'}"> t-att-data-publish="product.website_published and website in product.website_ids and 'on' or 'off'">
<t t-call="website_sale.products_item"> <t t-call="website_sale.products_item">
</t> </t>
</div> </div>
@ -481,7 +481,7 @@
<template id="products_list_view" inherit_id="website_sale.products" name="List View" active="False"> <template id="products_list_view" inherit_id="website_sale.products" name="List View" active="False">
<xpath expr="//div[@id='products_grid']/t/div[@id='grid_list']" position="replace"> <xpath expr="//div[@id='products_grid']/t/div[@id='grid_list']" position="replace">
<div class="oe_product oe_list oe_product_cart" <div class="oe_product oe_list oe_product_cart"
t-attf-data-publish="#{product.website_published &amp; (not product.website_ids or website in product.website_ids) and 'on' or 'off'}"> t-att-data-publish="product.website_published and website in product.website_ids and 'on' or 'off'">
<t t-call="website_sale.products_item"> <t t-call="website_sale.products_item">
<t t-set="show_publish" t-value="True" /> <t t-set="show_publish" t-value="True" />
</t> </t>

View File

@ -2,5 +2,6 @@
<flectra> <flectra>
<record id="delivery.free_delivery_carrier" model="delivery.carrier"> <record id="delivery.free_delivery_carrier" model="delivery.carrier">
<field name="website_published" eval="True"/> <field name="website_published" eval="True"/>
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
</record> </record>
</flectra> </flectra>

View File

@ -8,7 +8,15 @@ class DeliveryCarrier(models.Model):
_name = 'delivery.carrier' _name = 'delivery.carrier'
_inherit = ['delivery.carrier', 'website.published.mixin'] _inherit = ['delivery.carrier', 'website.published.mixin']
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Text(related='product_id.description_sale', string='Description for Online Quotations') website_description = fields.Text(related='product_id.description_sale', string='Description for Online Quotations')
website_published = fields.Boolean(default=False) website_published = fields.Boolean(default=False)
website_ids = fields.Many2many('website', 'website_del_carrier_pub_rel', 'website_id', 'del_carrier_id', string='Websites', copy=False, website_ids = fields.Many2many('website', 'website_del_carrier_pub_rel',
help='List of websites in which Product is published.') 'website_id', 'del_carrier_id',
default=_default_website,
string='Websites', copy=False,
help='List of websites in which Delivery '
'Carrier will published.')

View File

@ -73,8 +73,8 @@ class SaleOrder(models.Model):
def _get_delivery_methods(self): def _get_delivery_methods(self):
address = self.partner_shipping_id address = self.partner_shipping_id
domain = self.env['website'].get_current_website() website = self.env['website'].get_current_website()
return self.env['delivery.carrier'].sudo().search([('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id)]).available_carriers(address) return self.env['delivery.carrier'].sudo().search([('website_published', '=', True), ('website_ids', 'in', website.id)]).available_carriers(address)
@api.multi @api.multi
def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0, **kwargs): def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0, **kwargs):

View File

@ -59,7 +59,7 @@ class WebsiteSlides(http.Controller):
""" """
domain = [] domain = []
if not request.env.user.has_group('website.group_website_designer'): if not request.env.user.has_group('website.group_website_designer'):
domain += ['|', ('website_ids', '=', False), ("website_ids", "in", request.website.id)] domain += [("website_ids", "in", request.website.id)]
channels = request.env['slide.channel'].search(domain, order='sequence, id') channels = request.env['slide.channel'].search(domain, order='sequence, id')
if not channels: if not channels:
return request.render("website_slides.channel_not_found") return request.render("website_slides.channel_not_found")
@ -98,7 +98,11 @@ class WebsiteSlides(http.Controller):
def channel(self, channel, category=None, tag=None, page=1, slide_type=None, sorting='creation', search=None, **kw): def channel(self, channel, category=None, tag=None, page=1, slide_type=None, sorting='creation', search=None, **kw):
user = request.env.user user = request.env.user
Slide = request.env['slide.slide'] Slide = request.env['slide.slide']
domain = [('channel_id', '=', channel.id)] if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in channel.website_ids.ids:
return request.render('website.404')
domain = [('channel_id', '=', channel.id),
('website_ids', 'in', request.website.id)]
pager_url = "/slides/%s" % (channel.id) pager_url = "/slides/%s" % (channel.id)
pager_args = {} pager_args = {}

View File

@ -32,6 +32,10 @@ class Channel(models.Model):
'latest': 'date_published desc', 'latest': 'date_published desc',
} }
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
name = fields.Char('Name', translate=True, required=True) name = fields.Char('Name', translate=True, required=True)
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
description = fields.Html('Description', translate=html_translate, sanitize_attributes=False) description = fields.Html('Description', translate=html_translate, sanitize_attributes=False)
@ -51,7 +55,7 @@ class Channel(models.Model):
@api.depends('custom_slide_id', 'promote_strategy', 'slide_ids.likes', @api.depends('custom_slide_id', 'promote_strategy', 'slide_ids.likes',
'slide_ids.total_views', "slide_ids.date_published") 'slide_ids.total_views', "slide_ids.date_published")
def _compute_promoted_slide_id(self): def _compute_promoted_slide_id(self):
domain = self.env['website'].get_current_website() website = self.env['website'].get_current_website()
for record in self: for record in self:
if record.promote_strategy == 'none': if record.promote_strategy == 'none':
record.promoted_slide_id = False record.promoted_slide_id = False
@ -59,7 +63,7 @@ class Channel(models.Model):
record.promoted_slide_id = record.custom_slide_id record.promoted_slide_id = record.custom_slide_id
elif record.promote_strategy: elif record.promote_strategy:
slides = self.env['slide.slide'].search( slides = self.env['slide.slide'].search(
[('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id), ('channel_id', '=', record.id)], [('website_published', '=', True), ('website_ids', 'in', website.id), ('channel_id', '=', record.id)],
limit=1, order=self._order_by_strategy[record.promote_strategy]) limit=1, order=self._order_by_strategy[record.promote_strategy])
record.promoted_slide_id = slides and slides[0] or False record.promoted_slide_id = slides and slides[0] or False
@ -72,9 +76,9 @@ class Channel(models.Model):
@api.depends('slide_ids.slide_type', 'slide_ids.website_published') @api.depends('slide_ids.slide_type', 'slide_ids.website_published')
def _count_presentations(self): def _count_presentations(self):
result = dict.fromkeys(self.ids, dict()) result = dict.fromkeys(self.ids, dict())
domain = self.env['website'].get_current_website() website = self.env['website'].get_current_website()
res = self.env['slide.slide'].read_group( res = self.env['slide.slide'].read_group(
[('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id), ('channel_id', 'in', self.ids)], [('website_published', '=', True), ('website_ids', 'in', website.id), ('channel_id', 'in', self.ids)],
['channel_id', 'slide_type'], ['channel_id', 'slide_type'], ['channel_id', 'slide_type'], ['channel_id', 'slide_type'],
lazy=False) lazy=False)
for res_group in res: for res_group in res:
@ -113,11 +117,12 @@ class Channel(models.Model):
can_see = fields.Boolean('Can See', compute='_compute_access', search='_search_can_see') can_see = fields.Boolean('Can See', compute='_compute_access', search='_search_can_see')
can_see_full = fields.Boolean('Full Access', compute='_compute_access') can_see_full = fields.Boolean('Full Access', compute='_compute_access')
can_upload = fields.Boolean('Can Upload', compute='_compute_access') can_upload = fields.Boolean('Can Upload', compute='_compute_access')
website_ids = fields.Many2many('website', 'website_slide_channel_pub_rel', website_ids = fields.Many2many('website', 'website_slide_channel_pub_rel',
'website_id', 'slide_channel_id', 'website_id', 'slide_channel_id',
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which Slide channel is published.') default=_default_website,
help='List of websites in which '
'Slide Channel will published.')
def _search_can_see(self, operator, value): def _search_can_see(self, operator, value):
if operator not in ('=', '!=', '<>'): if operator not in ('=', '!=', '<>'):
@ -209,7 +214,7 @@ class Category(models.Model):
result = dict.fromkeys(self.ids, dict()) result = dict.fromkeys(self.ids, dict())
domain = self.env['website'].get_current_website() domain = self.env['website'].get_current_website()
res = self.env['slide.slide'].read_group( res = self.env['slide.slide'].read_group(
[('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id), ('category_id', 'in', self.ids)], [('website_published', '=', True), ('website_ids', 'in', domain.id), ('category_id', 'in', self.ids)],
['category_id', 'slide_type'], ['category_id', 'slide_type'], ['category_id', 'slide_type'], ['category_id', 'slide_type'],
lazy=False) lazy=False)
for res_group in res: for res_group in res:
@ -282,6 +287,10 @@ class Slide(models.Model):
('name_uniq', 'UNIQUE(channel_id, name)', 'The slide name must be unique within a channel') ('name_uniq', 'UNIQUE(channel_id, name)', 'The slide name must be unique within a channel')
] ]
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
# description # description
name = fields.Char('Title', required=True, translate=True) name = fields.Char('Title', required=True, translate=True)
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
@ -296,9 +305,12 @@ class Slide(models.Model):
image = fields.Binary('Image', attachment=True) image = fields.Binary('Image', attachment=True)
image_medium = fields.Binary('Medium', compute="_get_image", store=True, attachment=True) image_medium = fields.Binary('Medium', compute="_get_image", store=True, attachment=True)
image_thumb = fields.Binary('Thumbnail', compute="_get_image", store=True, attachment=True) image_thumb = fields.Binary('Thumbnail', compute="_get_image", store=True, attachment=True)
website_ids = fields.Many2many('website', 'website_slide_pub_rel', 'website_id', 'slide_id', website_ids = fields.Many2many('website', 'website_slide_pub_rel',
'website_id', 'slide_id',
string='Websites', copy=False, string='Websites', copy=False,
help='List of websites in which Slide is published.') default=_default_website,
help='List of websites in which Slide '
'will published.')
@api.depends('image') @api.depends('image')
def _get_image(self): def _get_image(self):
@ -475,16 +487,16 @@ class Slide(models.Model):
return groups return groups
def get_related_slides(self, limit=20): def get_related_slides(self, limit=20):
domain = self.env['website'].get_current_website() website = self.env['website'].get_current_website()
domain = [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id), ('channel_id.visibility', '!=', 'private'), ('id', '!=', self.id)] domain = [('website_published', '=', True), ('website_ids', 'in', website.id), ('channel_id.visibility', '!=', 'private'), ('id', '!=', self.id)]
if self.category_id: if self.category_id:
domain += [('category_id', '=', self.category_id.id)] domain += [('category_id', '=', self.category_id.id)]
for record in self.search(domain, limit=limit): for record in self.search(domain, limit=limit):
yield record yield record
def get_most_viewed_slides(self, limit=20): def get_most_viewed_slides(self, limit=20):
domain = self.env['website'].get_current_website() website = self.env['website'].get_current_website()
for record in self.search([('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', domain.id), ('channel_id.visibility', '!=', 'private'), ('id', '!=', self.id)], limit=limit, order='total_views desc'): for record in self.search([('website_published', '=', True), ('website_ids', 'in', website.id), ('channel_id.visibility', '!=', 'private'), ('id', '!=', self.id)], limit=limit, order='total_views desc'):
yield record yield record
def _post_publication(self): def _post_publication(self):

View File

@ -39,7 +39,7 @@
<div class="row"> <div class="row">
<t t-foreach="channels" t-as="channel"> <t t-foreach="channels" t-as="channel">
<div t-if="channel_index % 3 == 0" class="clearfix"/> <div t-if="channel_index % 3 == 0" class="clearfix"/>
<div class="col-sm-4 mb32" t-attf-data-publish="#{channel.website_published &amp; (not channel.website_ids or website in channel.website_ids) and 'on' or 'off'}"> <div class="col-sm-4 mb32" t-att-data-publish="channel.website_published and website in channel.website_ids and 'on' or 'off'">
<div class="well well-sm"> <div class="well well-sm">
<div> <div>
<a t-attf-href="/slides/#{slug(channel)}"> <a t-attf-href="/slides/#{slug(channel)}">