[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:
parent
2b42b1b300
commit
e088762a21
@ -24,7 +24,7 @@ class WebsiteBlog(http.Controller):
|
||||
dom = blog and [('blog_id', '=', blog.id)] or []
|
||||
if not request.env.user.has_group('website.group_website_designer'):
|
||||
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(
|
||||
dom,
|
||||
['name', 'post_date'],
|
||||
@ -64,7 +64,7 @@ class WebsiteBlog(http.Controller):
|
||||
page=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'])
|
||||
return request.render("website_blog.latest_blogs", {
|
||||
'posts': posts,
|
||||
@ -114,16 +114,16 @@ class WebsiteBlog(http.Controller):
|
||||
domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)]
|
||||
|
||||
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)
|
||||
unpublished_count = BlogPost.search_count(domain) - published_count
|
||||
|
||||
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":
|
||||
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:
|
||||
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)
|
||||
|
||||
@ -198,6 +198,10 @@ class WebsiteBlog(http.Controller):
|
||||
- 'nav_list': a dict [year][month] for archives navigation
|
||||
- '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']
|
||||
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([])
|
||||
|
||||
# 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'):
|
||||
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
|
||||
publish = request.env.user.has_group('website.group_website_publisher')
|
||||
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)
|
||||
if count:
|
||||
return messages.ids
|
||||
|
@ -16,7 +16,6 @@
|
||||
<field name="blog_id" ref="blog_blog_1"/>
|
||||
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
|
||||
<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="website_meta_keywords">Flectra, email</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="blog_id" ref="blog_blog_1"/>
|
||||
<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="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>
|
||||
|
@ -127,6 +127,10 @@ class BlogPost(models.Model):
|
||||
</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='')
|
||||
subtitle = fields.Char('Sub Title', translate=True)
|
||||
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')
|
||||
website_ids = fields.Many2many('website', 'website_blog_pub_rel',
|
||||
'website_id', 'blog_id',
|
||||
default=_default_website,
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which '
|
||||
'Blog Post is published.')
|
||||
'Blog Post will published.')
|
||||
|
||||
@api.multi
|
||||
@api.depends('content', 'teaser_manual')
|
||||
|
@ -17,7 +17,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
|
||||
- if someone subscribe to the post or comment it, it become follower
|
||||
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
|
||||
test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({
|
||||
'name': 'New Blog',
|
||||
@ -40,7 +40,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
|
||||
'website_blog: subscribing to a blog should not subscribe to its posts')
|
||||
|
||||
# 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
|
||||
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)
|
||||
|
@ -133,7 +133,7 @@
|
||||
</p>
|
||||
</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) }">
|
||||
<h2 t-field="blog_post.name" class="mb4 o_blog_post_title">Untitled Post</h2>
|
||||
</a>
|
||||
|
@ -185,14 +185,14 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
yield {'loc': '/partners'}
|
||||
|
||||
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)
|
||||
for grade in env['res.partner.grade'].search(dom):
|
||||
loc = '/partners/grade/%s' % slug(grade)
|
||||
if not qs or qs.lower() in 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/')
|
||||
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
|
||||
for country in countries:
|
||||
@ -219,9 +219,9 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
country_obj = request.env['res.country']
|
||||
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'):
|
||||
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:
|
||||
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]
|
||||
|
||||
@ -327,7 +327,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
|
||||
if partner_id:
|
||||
partner = request.env['res.partner'].sudo().browse(partner_id)
|
||||
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 = {
|
||||
'main_object': partner,
|
||||
'partner': partner,
|
||||
|
@ -3,19 +3,15 @@
|
||||
<data noupdate="1">
|
||||
<record id="website_crm_partner_assign.res_partner_grade_platinium" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_gold" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_silver" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="website_crm_partner_assign.res_partner_grade_bronze" model="res.partner.grade">
|
||||
<field name="website_published" eval="True" />
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="base.partner_demo_portal" model="res.partner">
|
||||
<field name="grade_id" ref="website_crm_partner_assign.res_partner_grade_platinium"/>
|
||||
|
@ -9,6 +9,10 @@ class ResPartnerGrade(models.Model):
|
||||
_name = 'res.partner.grade'
|
||||
_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)
|
||||
sequence = fields.Integer('Sequence')
|
||||
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_id', 'partner_grade_id',
|
||||
string='Websites', copy=False,
|
||||
default=_default_website,
|
||||
help='List of websites in which '
|
||||
'Partner Grade is published.')
|
||||
'Partner Grade will published.')
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
|
@ -162,7 +162,7 @@
|
||||
|
||||
<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
|
||||
<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>
|
||||
</xpath>
|
||||
</template>
|
||||
@ -171,7 +171,7 @@
|
||||
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
|
||||
<h3 id="references">References</h3>
|
||||
<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)}">
|
||||
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
|
||||
</a>
|
||||
|
@ -47,7 +47,7 @@ class WebsiteCustomer(http.Controller):
|
||||
Partner = request.env['res.partner']
|
||||
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:
|
||||
domain += [
|
||||
'|', '|',
|
||||
@ -118,7 +118,7 @@ class WebsiteCustomer(http.Controller):
|
||||
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')
|
||||
|
||||
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
|
||||
|
||||
values = {
|
||||
@ -145,7 +145,7 @@ class WebsiteCustomer(http.Controller):
|
||||
_, partner_id = unslug(partner_id)
|
||||
if 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['main_object'] = values['partner'] = partner
|
||||
return request.render("website_customer.details", values)
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner">
|
||||
<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_description" type="xml">
|
||||
<p>
|
||||
@ -35,7 +34,6 @@
|
||||
</record>
|
||||
<record id="base.res_partner_3" model="res.partner">
|
||||
<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_description" type="xml">
|
||||
<p>
|
||||
@ -64,7 +62,6 @@
|
||||
</record>
|
||||
<record id="base.res_partner_4" model="res.partner">
|
||||
<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_description" type="xml">
|
||||
<p>
|
||||
@ -95,7 +92,6 @@
|
||||
</record>
|
||||
<record id="base.res_partner_3" model="res.partner">
|
||||
<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_description" type="xml">
|
||||
<p>
|
||||
|
@ -22,6 +22,10 @@ class Tags(models.Model):
|
||||
classname = ['default', 'primary', 'success', 'warning', 'danger']
|
||||
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)
|
||||
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)
|
||||
@ -30,5 +34,6 @@ class Tags(models.Model):
|
||||
website_ids = fields.Many2many('website', 'website_partner_tag_pub_rel',
|
||||
'website_id', 'partner_tag_id',
|
||||
string='Websites', copy=False,
|
||||
default=_default_website,
|
||||
help='List of websites in which '
|
||||
'Partner Tag is published.')
|
||||
'Partner Tag will published.')
|
||||
|
@ -37,7 +37,6 @@
|
||||
<field name="name"/>
|
||||
<field name="classname"/>
|
||||
<field name="website_published"/>
|
||||
<field name="website_ids" widget="many2many_tags"/>
|
||||
<field name="active"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -189,7 +189,7 @@
|
||||
</template>
|
||||
|
||||
<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-heading">
|
||||
<h4>Implemented By</h4>
|
||||
@ -198,7 +198,7 @@
|
||||
<h4>
|
||||
<a t-attf-href="/partners/#{slug(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>
|
||||
</h4>
|
||||
<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])">
|
||||
<h3 id="references">References</h3>
|
||||
<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)}">
|
||||
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
|
||||
</a>
|
||||
|
@ -83,7 +83,7 @@ class WebsiteEventController(http.Controller):
|
||||
|
||||
def dom_without(without):
|
||||
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 []
|
||||
for key, search in domain_search.items():
|
||||
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)
|
||||
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 = {
|
||||
'event': event,
|
||||
'main_object': event,
|
||||
@ -257,7 +260,6 @@ class WebsiteEventController(http.Controller):
|
||||
|
||||
for registration in registrations:
|
||||
registration['event_id'] = event
|
||||
registration['website_id'] = request.website.id
|
||||
Attendees += Attendees.sudo().create(
|
||||
Attendees._prepare_attendee_values(registration))
|
||||
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
<record id="base.res_partner_1" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="event.event_0" model="event.event">
|
||||
<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="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);">
|
||||
@ -165,11 +164,10 @@
|
||||
|
||||
<record id="base.res_partner_3" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="event.event_1" model="event.event">
|
||||
<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="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);">
|
||||
@ -326,25 +324,22 @@
|
||||
|
||||
<record id="base.res_partner_4" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="event.event_2" model="event.event">
|
||||
<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>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="base.res_partner_address_4" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="event.event_3" model="event.event">
|
||||
<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="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%">
|
||||
|
@ -17,11 +17,11 @@ class Event(models.Model):
|
||||
_inherit = ['event.event', 'website.seo.metadata', 'website.published.mixin']
|
||||
|
||||
website_published = fields.Boolean(track_visibility='onchange')
|
||||
website_ids = fields.Many2many('website', 'website_event_pub_rel',
|
||||
'website_id', 'event_id',
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which '
|
||||
'Event is published.')
|
||||
website_id = fields.Many2one('website', string='Website', copy=False,
|
||||
default=lambda self: self.env.ref(
|
||||
'website.default_website'),
|
||||
help='Website in which '
|
||||
'Event will published.')
|
||||
|
||||
is_participating = fields.Boolean("Is Participating", compute="_compute_is_participating")
|
||||
|
||||
@ -136,29 +136,3 @@ class Event(models.Model):
|
||||
'target': 'new',
|
||||
'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
|
||||
|
@ -53,12 +53,12 @@
|
||||
</div>
|
||||
<ul class="media-list">
|
||||
<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">
|
||||
<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="not 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="event.is_online" class="label label-info">Online</small>
|
||||
<small t-if="not event.website_published" class="label label-danger">unpublished</small>
|
||||
</h4>
|
||||
<div>
|
||||
<t t-if="event.organizer_id">
|
||||
@ -680,7 +680,7 @@
|
||||
<h4><b>Upcoming Events</b></h4>
|
||||
</t>
|
||||
<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>
|
||||
</t>
|
||||
<t t-if="event_dict['event'].address_id">
|
||||
|
@ -55,20 +55,9 @@
|
||||
string="Edit Badges"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='auto_confirm']" position="before">
|
||||
<field name="website_ids" widget="many2many_tags"/>
|
||||
<field name="website_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</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>
|
||||
|
@ -83,7 +83,7 @@ class WebsiteForum(http.Controller):
|
||||
def forum(self, **kwargs):
|
||||
domain = []
|
||||
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)
|
||||
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)
|
||||
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post):
|
||||
Post = request.env['forum.post']
|
||||
|
||||
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), '|', ('website_id', '=', request.website.id), ('website_id', '=', False)]
|
||||
if not request.env.user.has_group('website.group_website_publisher') \
|
||||
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:
|
||||
domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)]
|
||||
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)
|
||||
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
|
||||
if not question.can_view:
|
||||
raise werkzeug.exceptions.NotFound()
|
||||
@ -411,7 +417,7 @@ class WebsiteForum(http.Controller):
|
||||
'name': kwargs.get('post_name'),
|
||||
'content': kwargs.get('content'),
|
||||
'content_link': kwargs.get('content_link'),
|
||||
'website_id': request.website.id,
|
||||
'website_id': request.website and request.website.id,
|
||||
}
|
||||
post.write(vals)
|
||||
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):
|
||||
User = request.env['res.users']
|
||||
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)
|
||||
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
|
||||
users = [[] for i in range(len(user_obj) // 3 + 1)]
|
||||
for index, user in enumerate(user_obj):
|
||||
|
@ -28,7 +28,6 @@
|
||||
<!-- Questions -->
|
||||
<record id="question_0" model="forum.post">
|
||||
<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="post_type">question</field>
|
||||
<field name="views">3</field>
|
||||
@ -36,7 +35,6 @@
|
||||
</record>
|
||||
<record id="question_1" model="forum.post">
|
||||
<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="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:
|
||||
@ -51,7 +49,6 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
|
||||
<!-- Answer -->
|
||||
<record id="answer_0" model="forum.post">
|
||||
<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>
|
||||
<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.
|
||||
@ -64,7 +61,6 @@ In simple words does Flectra became CMS+ERP platform?</p>]]></field>
|
||||
</record>
|
||||
<record id="answer_1" model="forum.post">
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="website_id" ref="website.default_website"/>
|
||||
<field name="content"><![CDATA[
|
||||
<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.
|
||||
@ -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">
|
||||
<field name="content_link">https://www.flectra.com</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="post_type">link</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-->
|
||||
<record id="discussion_0" model="forum.post">
|
||||
<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.
|
||||
|
||||
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">
|
||||
<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>
|
||||
<ol>
|
||||
<li>Backup-Script</li>
|
||||
|
@ -41,6 +41,10 @@ class Forum(models.Model):
|
||||
with misc.file_open('website_forum/data/forum_default_faq.html', 'r') as f:
|
||||
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
|
||||
name = fields.Char('Forum Name', required=True, translate=True)
|
||||
active = fields.Boolean(default=True)
|
||||
@ -131,8 +135,9 @@ class Forum(models.Model):
|
||||
website_ids = fields.Many2many('website', 'website_forum_pub_rel',
|
||||
'website_id', 'forum_id',
|
||||
string='Websites', copy=False,
|
||||
default=_default_website,
|
||||
help='List of websites in which '
|
||||
'Forum is published.')
|
||||
'Forum will published.')
|
||||
|
||||
@api.one
|
||||
@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_flag = fields.Boolean('Can Flag', 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):
|
||||
if operator not in ('=', '!=', '<>'):
|
||||
|
@ -4,26 +4,31 @@
|
||||
<record id="hr.employee_niv" model="hr.employee">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="public_info">Designer, UI Expert</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr.employee_root" model="hr.employee">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="public_info">Lean Management Expert</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr.employee_qdp" model="hr.employee">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="public_info">Designer, UI Expert</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr.employee_fpi" model="hr.employee">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="public_info">Customer Service Oriented</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr.employee_al" model="hr.employee">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="public_info">Like Coding</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="hr.employee_jgo" model="hr.employee">
|
||||
|
@ -7,11 +7,17 @@ class HrEmployee(models.Model):
|
||||
_name = 'hr.employee'
|
||||
_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')
|
||||
website_ids = fields.Many2many('website', 'website_hr_emp_pub_rel',
|
||||
'website_id', 'emp_id',
|
||||
default=_default_website,
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which Employee is published.')
|
||||
help='List of websites in which Employee '
|
||||
'will published.')
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
|
@ -11,7 +11,7 @@
|
||||
<xpath expr="//div[hasclass('oe_structure')]" position="after">
|
||||
<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="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)" />
|
||||
<div class="col-sm-12 text-center" t-if="len(employees)">
|
||||
<h2>Our Team</h2>
|
||||
@ -22,7 +22,7 @@
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
</t>
|
||||
<div class="clearfix"/>
|
||||
<div class="emp" t-attf-data-publish="#{employee.website_published & (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"/>
|
||||
<div class="mt8">
|
||||
<strong t-field="employee.name"></strong>
|
||||
|
@ -30,7 +30,7 @@ class WebsiteHrRecruitment(http.Controller):
|
||||
# List jobs available to current UID
|
||||
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'):
|
||||
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
|
||||
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)
|
||||
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", {
|
||||
'job': job,
|
||||
'main_object': job,
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
<record id="hr.job_marketing" model="hr.job">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
<field name="website_description" type="html">
|
||||
<section class="mt16 mb16 oe_dark">
|
||||
<div class="container">
|
||||
@ -135,6 +136,7 @@
|
||||
|
||||
<record id="hr.job_developer" model="hr.job">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
<field name="website_description" type="html">
|
||||
<section class="mt16 mb16 oe_dark">
|
||||
<div class="container">
|
||||
@ -268,6 +270,7 @@
|
||||
|
||||
<record id="hr.job_consultant" model="hr.job">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
<field name="website_description" type="html">
|
||||
<section class="mt16 mb16 oe_dark">
|
||||
<div class="container">
|
||||
|
@ -29,6 +29,7 @@ class RecruitmentSource(models.Model):
|
||||
class Applicant(models.Model):
|
||||
|
||||
_inherit = 'hr.applicant'
|
||||
|
||||
website_id = fields.Many2one('website', string="Website")
|
||||
|
||||
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")
|
||||
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_ids = fields.Many2many('website', 'website_hr_job_pub_rel',
|
||||
'website_id', 'job_id',
|
||||
default=_default_website,
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which Job is published.')
|
||||
help='List of websites in which Job '
|
||||
'will published.')
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
|
@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flectra import models, fields, api, _
|
||||
from flectra import models, fields
|
||||
|
||||
|
||||
class LinkTracker(models.Model):
|
||||
|
||||
_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!')
|
||||
|
@ -12,24 +12,17 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_link_tracker_filter" model="ir.ui.view">
|
||||
<field name="name">view.link.tracker.filter</field>
|
||||
<!-- Search -->
|
||||
<record id="view_link_tracker_filter_website" model="ir.ui.view">
|
||||
<field name="name">Links</field>
|
||||
<field name="model">link.tracker</field>
|
||||
<field name="inherit_id" ref="link_tracker.view_link_tracker_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Link Tracker">
|
||||
<separator/>
|
||||
<xpath expr="//field[@name='title']" position="after">
|
||||
<filter name="website_id" string="Website"
|
||||
context="{'group_by':'website_id'}"/>
|
||||
</search>
|
||||
</xpath>
|
||||
</field>
|
||||
</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>
|
||||
|
@ -84,7 +84,6 @@
|
||||
<label class="col-sm-3 control-label text-left hidden">
|
||||
Website
|
||||
</label>
|
||||
|
||||
<div class="col-sm-9">
|
||||
<input type="hidden" id="website_id" class="form-control" t-att-value="website.id"/>
|
||||
</div>
|
||||
|
@ -43,7 +43,7 @@ class WebsiteMembership(http.Controller):
|
||||
# base domain for groupby / searches
|
||||
base_line_domain = [
|
||||
("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)
|
||||
]
|
||||
if membership_id and membership_id != 'free':
|
||||
@ -64,7 +64,7 @@ class WebsiteMembership(http.Controller):
|
||||
if 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)
|
||||
|
||||
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:
|
||||
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:
|
||||
search_domain += ['|', ('name', 'ilike', post_name), ('website_description', 'ilike', post_name)]
|
||||
if country_id:
|
||||
@ -168,7 +168,7 @@ class WebsiteMembership(http.Controller):
|
||||
_, partner_id = unslug(partner_id)
|
||||
if 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['main_object'] = values['partner'] = partner
|
||||
return request.render("website_membership.partner", values)
|
||||
|
@ -13,6 +13,9 @@ class WebsitePartnerPage(http.Controller):
|
||||
_, partner_id = unslug(partner_id)
|
||||
if 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')
|
||||
if partner_sudo.exists() and (partner_sudo.website_published or is_website_publisher):
|
||||
values = {
|
||||
|
@ -3,56 +3,45 @@
|
||||
|
||||
<record id="base.partner_root" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="base.partner_demo" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_12" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_12" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_1" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_12" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_3" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_3" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_18" model="res.partner">
|
||||
<field name="website_published">True</field>
|
||||
<field name="website_ids" eval="[(4,ref('website.default_website'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_10" model="res.partner">
|
||||
|
@ -8,13 +8,18 @@ class WebsiteResPartner(models.Model):
|
||||
_name = 'res.partner'
|
||||
_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_short_description = fields.Text('Website Partner Short Description')
|
||||
website_ids = fields.Many2many('website', 'website_partner_pub_rel',
|
||||
'website_id', 'partner_id',
|
||||
string='Websites', copy=False,
|
||||
default=_default_website,
|
||||
help='List of websites in which '
|
||||
'Partner is published.')
|
||||
'Partner will published.')
|
||||
|
||||
@api.multi
|
||||
def _compute_website_url(self):
|
||||
|
@ -5,6 +5,6 @@ from flectra import fields, models
|
||||
class PaymentAcquirer(models.Model):
|
||||
_inherit = "payment.acquirer"
|
||||
|
||||
website_id = fields.Many2many('website', 'website_payment_rel',
|
||||
'website_id', 'payment_id',
|
||||
string='Website')
|
||||
website_id = fields.Many2one('website', string='Website', copy=False,
|
||||
help='Define website in which Payment '
|
||||
'Gateway will published.')
|
||||
|
@ -25,7 +25,7 @@
|
||||
<field name="inherit_id" ref="payment.acquirer_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='provider']" position='after'>
|
||||
<field name="website_id" widget="many2many_tags"/>
|
||||
<field name="website_id"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='acquirer_left']" position="after">
|
||||
<group nama="acquirer_right">
|
||||
|
@ -191,7 +191,7 @@ class WebsiteSale(http.Controller):
|
||||
if attrib:
|
||||
domain += [('attribute_line_ids.value_ids', 'in', ids)]
|
||||
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:
|
||||
domain += [('tag_ids', 'in', tag_values)]
|
||||
@ -245,10 +245,8 @@ class WebsiteSale(http.Controller):
|
||||
post["search"] = search
|
||||
if category:
|
||||
category = request.env['product.public.category'].browse(int(category))
|
||||
website = []
|
||||
for web in category.website_ids:
|
||||
website.append(web.id)
|
||||
if request.website.id not in website:
|
||||
if not category.website_ids or \
|
||||
request.website.id not in category.website_ids.ids:
|
||||
return request.render('website.404')
|
||||
url = "/shop/category/%s" % slug(category)
|
||||
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)
|
||||
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,
|
||||
active_id=product.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)
|
||||
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):
|
||||
request.session['website_sale_current_pl'] = 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(
|
||||
[('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
|
||||
@ -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['tokens'] = request.env['payment.token'].search(
|
||||
[('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']:
|
||||
acq.form = acq.with_context(submit_class='btn btn-primary', submit_txt=_('Pay Now')).sudo().render(
|
||||
|
@ -29,6 +29,11 @@
|
||||
<field name="salesteam_id" ref="sales_team.salesteam_website_sales"/>
|
||||
</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>
|
||||
<record id="sale.model_sale_order" model="ir.model">
|
||||
|
@ -630,75 +630,99 @@ Weight: 31 grams</field>
|
||||
|
||||
<record id="product.product_product_1_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_2_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('services')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_5b_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Speakers')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_6_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Screen')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_7_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Headset')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_9_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_10_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_12_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Keyboard_Mouse')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_13_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_16_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_17_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_20_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_22_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_24_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_25_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_product_27_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('laptops')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<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="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_order_01_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Software')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_delivery_01_product_template" model="product.template">
|
||||
<field name="public_categ_ids" eval="[(6,0,[ref('Components')])]"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
<record id="product.product_attribute_value_3" model="product.attribute.value">
|
||||
<field name="html_color">#FFFFFF</field>
|
||||
@ -709,7 +733,8 @@ Weight: 31 grams</field>
|
||||
|
||||
<record model="product.pricelist" id="product.list0">
|
||||
<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="currency_id" ref="base.USD"/>
|
||||
</record>
|
||||
@ -722,7 +747,8 @@ Weight: 31 grams</field>
|
||||
|
||||
<record id="list_christmas" model="product.pricelist">
|
||||
<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="sequence">20</field>
|
||||
</record>
|
||||
@ -735,7 +761,8 @@ Weight: 31 grams</field>
|
||||
|
||||
<record id="list_benelux" model="product.pricelist">
|
||||
<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="sequence">2</field>
|
||||
</record>
|
||||
@ -750,7 +777,8 @@ Weight: 31 grams</field>
|
||||
|
||||
<record id="list_europe" model="product.pricelist">
|
||||
<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="sequence">3</field>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
|
@ -10,10 +10,11 @@ from flectra.tools import float_is_zero
|
||||
|
||||
class ProductTags(models.Model):
|
||||
_name = 'product.tags'
|
||||
_description = 'Product Tags'
|
||||
_order = 'sequence'
|
||||
|
||||
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)
|
||||
|
||||
_sql_constraints = [('name_uniq', 'unique (name)',
|
||||
@ -26,7 +27,7 @@ class ProductBrand(models.Model):
|
||||
_order = 'sequence'
|
||||
|
||||
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)
|
||||
brand_image = fields.Binary(string='Brand Image')
|
||||
|
||||
@ -36,7 +37,7 @@ class ProductBrand(models.Model):
|
||||
|
||||
class ProductRibbon(models.Model):
|
||||
_name = 'product.ribbon'
|
||||
_description = 'Product Brand'
|
||||
_description = 'Product Ribbon'
|
||||
_order = 'name'
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class ProductStyle(models.Model):
|
||||
_name = "product.style"
|
||||
class ProductViewLimit(models.Model):
|
||||
_name = 'product.view.limit'
|
||||
_order = 'sequence'
|
||||
|
||||
name = fields.Char(string='Style Name', required=True)
|
||||
html_class = fields.Char(string='HTML Classes')
|
||||
sequence = fields.Integer(help="Gives the sequence order when "
|
||||
"displaying a list of rules.")
|
||||
name = fields.Integer(string='Limit', required=True)
|
||||
|
||||
|
||||
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)
|
||||
_sql_constraints = [('name', 'unique(name)', 'This must be unique!')]
|
||||
|
||||
|
||||
class ProductPricelist(models.Model):
|
||||
_inherit = "product.pricelist"
|
||||
|
||||
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")
|
||||
|
||||
def clear_cache(self):
|
||||
@ -95,24 +97,16 @@ class ProductPricelist(models.Model):
|
||||
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):
|
||||
_name = "product.public.category"
|
||||
_inherit = ["website.seo.metadata"]
|
||||
_description = "Website Product Category"
|
||||
_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)
|
||||
parent_id = fields.Many2one('product.public.category', string='Parent Category', index=True)
|
||||
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.")
|
||||
website_ids = fields.Many2many('website', 'website_prod_public_categ_rel',
|
||||
'website_id', 'category_id',
|
||||
default=_default_website,
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which '
|
||||
'category is published.')
|
||||
'category will published.')
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
tools.image_resize_images(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:
|
||||
res.parent_id.write({
|
||||
'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):
|
||||
tools.image_resize_images(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:
|
||||
self.parent_id.write({
|
||||
'website_ids': [(4, website_id.id) for website_id in self.website_ids]
|
||||
@ -190,6 +187,10 @@ class ProductTemplate(models.Model):
|
||||
_name = 'product.template'
|
||||
_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)
|
||||
alternative_product_ids = fields.Many2many('product.template', 'product_alternative_rel', 'src_id', 'dest_id',
|
||||
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_id', 'product_id',
|
||||
string='Websites', copy=False,
|
||||
default=_default_website,
|
||||
help='List of websites in which '
|
||||
'Product is published.')
|
||||
ribbon_id = fields.Many2one('product.ribbon', string='Product Ribbon')
|
||||
brand_id = fields.Many2one('product.brand', string="Product's Brand")
|
||||
tag_ids = fields.Many2many('product.tags', string='Product Tags')
|
||||
'Product will published.')
|
||||
ribbon_id = fields.Many2one('product.ribbon', string="Product Ribbon")
|
||||
brand_id = fields.Many2one('product.brand', string="Product Brand")
|
||||
tag_ids = fields.Many2many('product.tags', string="Product Tags")
|
||||
|
||||
def _website_price(self):
|
||||
# First filter out the ones that have no variant:
|
||||
@ -267,11 +269,6 @@ class ProductTemplate(models.Model):
|
||||
class Product(models.Model):
|
||||
_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_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')
|
||||
|
@ -17,14 +17,12 @@ class Website(models.Model):
|
||||
currency_id = fields.Many2one('res.currency', related='pricelist_id.currency_id', string='Default Currency')
|
||||
salesperson_id = fields.Many2one('res.users', string='Salesperson')
|
||||
salesteam_id = fields.Many2one('crm.team', string='Sales Channel')
|
||||
pricelist_ids = fields.One2many('website.product.pricelist', compute="_compute_pricelist_ids",
|
||||
string='Price list available for this Ecommerce/Website')
|
||||
pricelist_ids = fields.One2many('product.pricelist', compute="_compute_pricelist_ids",
|
||||
string='Price list available for this Ecommerce/Website')
|
||||
|
||||
@api.one
|
||||
def _compute_pricelist_ids(self):
|
||||
for website in self:
|
||||
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)])
|
||||
self.pricelist_ids = self.env["product.pricelist"].search([("website_ids", "in", self.id)])
|
||||
|
||||
@api.multi
|
||||
def _compute_pricelist_id(self):
|
||||
@ -34,8 +32,8 @@ class Website(models.Model):
|
||||
website.pricelist_id = website.get_current_pricelist()
|
||||
|
||||
# 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')
|
||||
def _get_pl_partner_order(self, country_code, show_visible, website_pl, current_pl, all_pls, partner_pl=False, order_pl=False):
|
||||
@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_pl, partner_pl=False, order_pl=False):
|
||||
""" 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 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:
|
||||
for cgroup in self.env['res.country.group'].search([('country_ids.code', '=', country_code)]):
|
||||
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
|
||||
|
||||
partner = self.env.user.partner_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 partner.property_product_pricelist.website_id:
|
||||
if partner.property_product_pricelist.website_ids:
|
||||
pricelists |= partner.property_product_pricelist
|
||||
|
||||
if not pricelists: # no pricelist for this country, or no GeoIP
|
||||
for all_pl in all_pls:
|
||||
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))
|
||||
pricelists |= all_pl.filtered(lambda pl: not show_visible or pl.selectable or pl.id in (current_pl, order_pl))
|
||||
else:
|
||||
for all_pl in all_pls:
|
||||
pricelists |= all_pl.pricelist_id.filtered(lambda pl: not show_visible and pl.sudo().code)
|
||||
pricelists |= all_pl.filtered(lambda pl: not show_visible and pl.sudo().code)
|
||||
|
||||
# This method is cached, must not return records! See also #8795
|
||||
return pricelists.ids
|
||||
|
@ -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_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_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_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_brand,access_product_brand,model_product_brand,,1,0,0,0
|
||||
access_product_style,access_product_style,model_product_style,,1,0,0,0
|
||||
|
|
@ -19,33 +19,25 @@ class TestWebsitePriceList(TransactionCase):
|
||||
self.website = self.env['website'].browse(1)
|
||||
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')
|
||||
for pl in website_pls:
|
||||
self.env['website.product.pricelist'].create({
|
||||
'pricelist_id': self.env.ref('website_sale.' + pl).id,
|
||||
'website_id': self.website.id,
|
||||
'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.env.ref('website_sale.' + pl).website_ids = [(6, 0, [self.website.id])]
|
||||
self.env.ref('product.list0').website_ids = [(6, 0, [self.website.id])]
|
||||
self.env.ref('website_sale.list_benelux').selectable = True
|
||||
self.website.pricelist_id = self.ref('product.list0')
|
||||
|
||||
ca_group = self.env['res.country.group'].create({
|
||||
'name': 'Canada',
|
||||
'country_ids': [(6, 0, [self.ref('base.ca')])]
|
||||
})
|
||||
ppl = self.env['product.pricelist'].create({
|
||||
self.env['product.pricelist'].create({
|
||||
'name': 'Canada',
|
||||
'selectable': True,
|
||||
'website_ids': [(6, 0, [self.website.id])],
|
||||
'country_group_ids': [(6, 0, [ca_group.id])],
|
||||
'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.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
@ -126,7 +118,7 @@ class TestWebsitePriceList(TransactionCase):
|
||||
country_list = {
|
||||
False: ['USD', 'EUR', 'Benelux', 'Canada'],
|
||||
'BE': ['EUR', 'Benelux'],
|
||||
'IT': ['EUR'],
|
||||
'IT': ['Benelux', 'USD', 'Canada'],
|
||||
'CA': ['EUR', 'Canada'],
|
||||
'US': ['USD', 'EUR', 'Benelux', 'Canada']
|
||||
}
|
||||
|
@ -75,8 +75,8 @@
|
||||
<field name="ribbon_id"/>
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<field name="brand_id" options="{'no_create': True}"/>
|
||||
<field name="website_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
<field name="website_ids"/>
|
||||
</group>
|
||||
<button name="toggle_active" position="before">
|
||||
<button class="oe_stat_button" name="website_publish_button"
|
||||
@ -197,12 +197,20 @@
|
||||
<field name="model">product.pricelist</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name='currency_id' position='after'>
|
||||
<field name="website_id" string='Allow to use on '>
|
||||
<tree editable='bottom' string="Website Store">
|
||||
<field name="website_id"/>
|
||||
<field name="selectable"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="selectable"/>
|
||||
<field name="website_ids" string='Allow to use on '
|
||||
widget="many2many_tags"/>
|
||||
</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>
|
||||
</record>
|
||||
@ -338,7 +346,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Product Brand Action -->
|
||||
<record id="product_by_brand_action" model="ir.actions.act_window">
|
||||
<field name="name">Brands</field>
|
||||
|
@ -131,11 +131,6 @@
|
||||
action="base.action_partner_customer_form"
|
||||
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"/> -->
|
||||
|
||||
<!-- Catalog sub-menus -->
|
||||
@ -156,11 +151,15 @@
|
||||
|
||||
<!-- Product Brands Menu -->
|
||||
<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 -->
|
||||
<menuitem action="product_tags_action" id="menu_product_tags" name="Tags"
|
||||
parent="website_sale.menu_catalog"/>
|
||||
<menuitem action="product_tags_action" id="menu_product_tags"
|
||||
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 -->
|
||||
<menuitem id="menu_ecommerce_payment_acquirers"
|
||||
|
@ -212,7 +212,7 @@
|
||||
<t t-foreach="products" t-as="product">
|
||||
<div id="grid_list"
|
||||
class="col-md-4 oe_product oe_grid oe_product_cart oe-height-4"
|
||||
t-attf-data-publish="#{product.website_published & (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>
|
||||
</div>
|
||||
@ -481,7 +481,7 @@
|
||||
<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">
|
||||
<div class="oe_product oe_list oe_product_cart"
|
||||
t-attf-data-publish="#{product.website_published & (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-set="show_publish" t-value="True" />
|
||||
</t>
|
||||
|
@ -2,5 +2,6 @@
|
||||
<flectra>
|
||||
<record id="delivery.free_delivery_carrier" model="delivery.carrier">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_ids" eval="[(4, ref('website.default_website'))]"/>
|
||||
</record>
|
||||
</flectra>
|
||||
|
@ -8,7 +8,15 @@ class DeliveryCarrier(models.Model):
|
||||
_name = 'delivery.carrier'
|
||||
_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_published = fields.Boolean(default=False)
|
||||
website_ids = fields.Many2many('website', 'website_del_carrier_pub_rel', 'website_id', 'del_carrier_id', string='Websites', copy=False,
|
||||
help='List of websites in which Product is published.')
|
||||
website_ids = fields.Many2many('website', 'website_del_carrier_pub_rel',
|
||||
'website_id', 'del_carrier_id',
|
||||
default=_default_website,
|
||||
string='Websites', copy=False,
|
||||
help='List of websites in which Delivery '
|
||||
'Carrier will published.')
|
||||
|
@ -73,8 +73,8 @@ class SaleOrder(models.Model):
|
||||
|
||||
def _get_delivery_methods(self):
|
||||
address = self.partner_shipping_id
|
||||
domain = 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)
|
||||
website = self.env['website'].get_current_website()
|
||||
return self.env['delivery.carrier'].sudo().search([('website_published', '=', True), ('website_ids', 'in', website.id)]).available_carriers(address)
|
||||
|
||||
@api.multi
|
||||
def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0, **kwargs):
|
||||
|
@ -59,7 +59,7 @@ class WebsiteSlides(http.Controller):
|
||||
"""
|
||||
domain = []
|
||||
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')
|
||||
if not channels:
|
||||
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):
|
||||
user = request.env.user
|
||||
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_args = {}
|
||||
|
||||
|
@ -32,6 +32,10 @@ class Channel(models.Model):
|
||||
'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)
|
||||
active = fields.Boolean(default=True)
|
||||
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',
|
||||
'slide_ids.total_views', "slide_ids.date_published")
|
||||
def _compute_promoted_slide_id(self):
|
||||
domain = self.env['website'].get_current_website()
|
||||
website = self.env['website'].get_current_website()
|
||||
for record in self:
|
||||
if record.promote_strategy == 'none':
|
||||
record.promoted_slide_id = False
|
||||
@ -59,7 +63,7 @@ class Channel(models.Model):
|
||||
record.promoted_slide_id = record.custom_slide_id
|
||||
elif record.promote_strategy:
|
||||
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])
|
||||
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')
|
||||
def _count_presentations(self):
|
||||
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(
|
||||
[('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'],
|
||||
lazy=False)
|
||||
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_full = fields.Boolean('Full Access', compute='_compute_access')
|
||||
can_upload = fields.Boolean('Can Upload', compute='_compute_access')
|
||||
|
||||
website_ids = fields.Many2many('website', 'website_slide_channel_pub_rel',
|
||||
'website_id', 'slide_channel_id',
|
||||
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):
|
||||
if operator not in ('=', '!=', '<>'):
|
||||
@ -209,7 +214,7 @@ class Category(models.Model):
|
||||
result = dict.fromkeys(self.ids, dict())
|
||||
domain = self.env['website'].get_current_website()
|
||||
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'],
|
||||
lazy=False)
|
||||
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')
|
||||
]
|
||||
|
||||
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
|
||||
name = fields.Char('Title', required=True, translate=True)
|
||||
active = fields.Boolean(default=True)
|
||||
@ -296,9 +305,12 @@ class Slide(models.Model):
|
||||
image = fields.Binary('Image', 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)
|
||||
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,
|
||||
help='List of websites in which Slide is published.')
|
||||
default=_default_website,
|
||||
help='List of websites in which Slide '
|
||||
'will published.')
|
||||
|
||||
@api.depends('image')
|
||||
def _get_image(self):
|
||||
@ -475,16 +487,16 @@ class Slide(models.Model):
|
||||
return groups
|
||||
|
||||
def get_related_slides(self, limit=20):
|
||||
domain = 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)]
|
||||
website = self.env['website'].get_current_website()
|
||||
domain = [('website_published', '=', True), ('website_ids', 'in', website.id), ('channel_id.visibility', '!=', 'private'), ('id', '!=', self.id)]
|
||||
if self.category_id:
|
||||
domain += [('category_id', '=', self.category_id.id)]
|
||||
for record in self.search(domain, limit=limit):
|
||||
yield record
|
||||
|
||||
def get_most_viewed_slides(self, limit=20):
|
||||
domain = 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'):
|
||||
website = self.env['website'].get_current_website()
|
||||
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
|
||||
|
||||
def _post_publication(self):
|
||||
|
@ -39,7 +39,7 @@
|
||||
<div class="row">
|
||||
<t t-foreach="channels" t-as="channel">
|
||||
<div t-if="channel_index % 3 == 0" class="clearfix"/>
|
||||
<div class="col-sm-4 mb32" t-attf-data-publish="#{channel.website_published & (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>
|
||||
<a t-attf-href="/slides/#{slug(channel)}">
|
||||
|
Loading…
Reference in New Issue
Block a user