fix #I7J61Y [app_website_blog_editor]让博文分类的显示按sequence排序

This commit is contained in:
Chill
2023-07-07 18:47:02 +08:00
parent 5c82965036
commit ae44f2023c
25 changed files with 439 additions and 1 deletions

View File

@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# from . import main from . import main

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
import re
import werkzeug
from odoo import http, fields, tools
from odoo.addons.http_routing.models.ir_http import slug, unslug
from odoo.addons.website.controllers.main import QueryURL
from odoo.http import request
from odoo.addons.website_blog.controllers.main import WebsiteBlog
class WebsiteBlog(WebsiteBlog):
@http.route([
'/blog',
'/blog/page/<int:page>',
'/blog/tag/<string:tag>',
'/blog/tag/<string:tag>/page/<int:page>',
'''/blog/<model("blog.blog"):blog>''',
'''/blog/<model("blog.blog"):blog>/page/<int:page>''',
'''/blog/<model("blog.blog"):blog>/tag/<string:tag>''',
'''/blog/<model("blog.blog"):blog>/tag/<string:tag>/page/<int:page>''',
], type='http', auth="public", website=True, sitemap=True)
def blog(self, blog=None, tag=None, page=1, search=None, **opt):
Blog = request.env['blog.blog']
# TODO adapt in master. This is a fix for templates wrongly using the
# 'blog_url' QueryURL which is defined below. Indeed, in the case where
# we are rendering a blog page where no specific blog is selected we
# define(d) that as `QueryURL('/blog', ['tag'], ...)` but then some
# parts of the template used it like this: `blog_url(blog=XXX)` thus
# generating an URL like "/blog?blog=blog.blog(2,)". Adding "blog" to
# the list of params would not be right as would create "/blog/blog/2"
# which is still wrong as we want "/blog/2". And of course the "/blog"
# prefix in the QueryURL definition is needed in case we only specify a
# tag via `blog_url(tab=X)` (we expect /blog/tag/X). Patching QueryURL
# or making blog_url a custom function instead of a QueryURL instance
# could be a solution but it was judged not stable enough. We'll do that
# in master. Here we only support "/blog?blog=blog.blog(2,)" URLs.
if isinstance(blog, str):
blog = Blog.browse(int(re.search(r'\d+', blog)[0]))
if not blog.exists():
raise werkzeug.exceptions.NotFound()
blogs = tools.lazy(lambda: Blog.search(request.website.website_domain(), order="sequence asc, name asc"))
if not blog and len(blogs) == 1:
url = QueryURL('/blog/%s' % slug(blogs[0]), search=search, **opt)()
return request.redirect(url, code=302)
date_begin, date_end, state = opt.get('date_begin'), opt.get('date_end'), opt.get('state')
if tag and request.httprequest.method == 'GET':
# redirect get tag-1,tag-2 -> get tag-1
tags = tag.split(',')
if len(tags) > 1:
url = QueryURL('' if blog else '/blog', ['blog', 'tag'], blog=blog, tag=tags[0], date_begin=date_begin, date_end=date_end, search=search)()
return request.redirect(url, code=302)
values = self._prepare_blog_values(blogs=blogs, blog=blog, date_begin=date_begin, date_end=date_end, tags=tag, state=state, page=page, search=search)
# in case of a redirection need by `_prepare_blog_values` we follow it
if isinstance(values, werkzeug.wrappers.Response):
return values
if blog:
values['main_object'] = blog
values['blog_url'] = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end, search=search)
else:
values['blog_url'] = QueryURL('/blog', ['tag'], date_begin=date_begin, date_end=date_end, search=search)
return request.render("website_blog.blog_post_short", values)

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="group_01" model="product.attribute.value.group">
<field name="name">CHN</field>
<field name="ref">CN</field>
</record>
<record id="group_02" model="product.attribute.value.group">
<field name="name">Eur</field>
<field name="ref">EU</field>
</record>
<record id="group_03" model="product.attribute.value.group">
<field name="name">US</field>
<field name="ref">US</field>
</record>
</data>
</odoo>

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import api, models, fields, _ from odoo import api, models, fields, _
from odoo.tools.safe_eval import safe_eval
class BlogBlog(models.Model): class BlogBlog(models.Model):
@@ -9,3 +10,9 @@ class BlogBlog(models.Model):
# 排序 # 排序
sequence = fields.Integer(string='Sequence', default=20, index=True, help="Determine the display order") sequence = fields.Integer(string='Sequence', default=20, index=True, help="Determine the display order")
def action_view_blog_post(self):
self.ensure_one()
action = self.env.ref('website_blog.action_blog_post').read()[0]
action['domain'] = [('blog_id', '=', self.id)]
return action

View File

@@ -11,6 +11,20 @@
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="app_view_blog_blog_form" model="ir.ui.view">
<field name="name">app.blog.blog.form</field>
<field name="model">blog.blog</field>
<field name="inherit_id" ref="website_blog.view_blog_blog_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet//group" position="before">
<div class="oe_button_box" name="button_box">
<button name="action_view_blog_post" type="object" class="oe_stat_button">
<field name="blog_post_count" widget="statinfo"/>
</button>
</div>
</xpath>
</field>
</record>
</odoo> </odoo>

View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
from . import models
from . import controllers
from .hooks import pre_init_hook
from .hooks import post_init_hook
from .hooks import uninstall_hook

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
# Created on 2022-09-01
# author: 欧度智能https://www.odooai.cn
# email: 300883@qq.com
# resource of odooai
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Odoo12在线用户手册长期更新
# https://www.sunpop.cn/documentation/user/12.0/zh_CN/index.html
# Odoo12在线开发者手册长期更新
# https://www.sunpop.cn/documentation/12.0/index.html
# Odoo10在线中文用户手册长期更新
# https://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.sunpop.cn/odoo10_developer_document_offline/
##############################################################################
# Copyright (C) 2009-TODAY sunpop.cn Ltd. https://www.sunpop.cn
# Author: Ivan Deng300883@qq.com
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
# See <http://www.gnu.org/licenses/>.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
##############################################################################
{
'name': "Website Blogs Search Enhance",
'version': '16.23.07.07',
'author': 'odooai.cn',
'category': 'Base',
'website': 'https://www.odooai.cn',
'license': 'LGPL-3',
'sequence': 2,
'price': 0.00,
'currency': 'EUR',
'images': ['static/description/banner.png'],
'depends': [
'website_blog',
],
'summary': '''
Odoo App of sunpop.cn
''',
'description': '''
Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition
1.
2.
11. Multi-language Support. Multi-Company Support.
12. Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition.
13. Full Open Source.
==========
1.
2.
11. 多语言支持,多公司支持
12. Odoo 16,15,14,13,12, 企业版社区版在线SaaS.sh版等全版本支持
13. 代码完全开源
''',
'data': [
'views/blog_post_views.xml',
# 'report/.xml',
],
'demo': [],
# 'pre_init_hook': 'pre_init_hook',
# 'post_init_hook': 'post_init_hook',
# 'uninstall_hook': 'uninstall_hook',
'installable': True,
'application': True,
'auto_install': False,
}

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
# from . import main

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Created on 2018-10-12
# author: 欧度智能https://www.odooai.cn
# email: 300883@qq.com
# resource of odooai
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
# Odoo在线中文用户手册长期更新
# https://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.sunpop.cn/odoo10_developer_document_offline/
# description:
from odoo import api, SUPERUSER_ID, _
def pre_init_hook(cr):
pass
# cr.execute("")
def post_init_hook(cr, registry):
pass
# cr.execute("")
def uninstall_hook(cr, registry):
pass
# cr.execute("")

View File

@@ -0,0 +1,21 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * app_website_blog_editor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230320\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-10 17:30+0000\n"
"PO-Revision-Date: 2023-04-10 17:30+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: app_website_blog_editor
#: model_terms:ir.ui.view,arch_db:app_website_blog_editor.app_view_blog_post_form
msgid "Content"
msgstr "博客图文"

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of sunpop.cn. See LICENSE file for full copyright and licensing details.
# Created on 2019-04-20
# author: 欧度智能http://www.sunpop.cn
# email: 300883@qq.com
# resource of odooai
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo12在线用户手册长期更新
# http://www.sunpop.cn/documentation/user/12.0/en/index.html
# Odoo12在线开发者手册长期更新
# http://www.sunpop.cn/documentation/12.0/index.html
# Odoo10在线中文用户手册长期更新
# http://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# http://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# http://www.sunpop.cn/odoo10_developer_document_offline/
# description:

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- model权限 -->
<record id="acc_module" model="ir.model.access">
<field name="name">acc_module_user</field>
<field name="model_id" ref="model_app_order"/>
<field name="group_id" ref="base.group_user"/>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="1"/>
</record>
<!-- 应用权限目录 -->
<record model="ir.module.category" id="app_module_category_1">
<field name="name">App...</field>
<field name="description">Helps you manage your ...</field>
<field name="sequence">8</field>
</record>
<!-- 权限用户 -->
<!-- 普通 -->
<record id="group_app_user" model="res.groups">
<field name="name">App User</field>
<field name="category_id" ref="app_module_category_1"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="comment">The user will be able to ...</field>
</record>
<!-- 管理员,可以配置 -->
<record id="group_app_admin" model="res.groups">
<field name="name">App Admin</field>
<field name="category_id" ref="app_module_category_1"/>
<field name="implied_ids" eval="[(4, ref('group_app_user'))]"/>
<field name="comment">The user will be able to config ...</field>
</record>
<!-- group_erp_manager自动有完整权限 -->
<record id="base.group_erp_manager" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_app_admin'))]"/>
</record>
<!-- Rules -->
<record id="rule_user" model="ir.rule">
<field name="name">Users are allowed to access their own m///</field>
<field name="model_id" ref="model_app_order"/>
<field name="domain_force">['|', ('partner_id', 'in', [user.partner_id.id]), ('user_id.id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
<!--End -->
</data>
</odoo>

View File

@@ -0,0 +1 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -0,0 +1,95 @@
<section class="oe_container">
<div class="oe_row oe_spaced" >
<div class="oe_span12">
<h2 class="oe_slogan"> </h2>
<h3 class="oe_slogan"> </h3>
<div class="oe_row">
<h3>Lastest update: v13.23.03.23</h3>
<div class="oe_span12">
<img class="oe_demo oe_screenshot" style="max-height: 100%;" src="banner.png">
</div>
<div class="oe_span12 oe_spaced">
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
<i class="fa fa-hand-o-right"></i><b> Key features: </b>
<ul class="list-unstyled">
<li>
<i class="fa fa-check-square-o text-primary"></i>
Put key function here.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
1.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
11. Multi-language Support. Multi-Company Support.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
12. Support Odoo 16,15,14,13,12, Enterprise and Community and odoo.sh Edition.
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h1 class="text-danger text-center">So Easy to navigator and search any data.</h1>
<h4 class="oe_slogan"> </h4>
<div class="oe_demo oe_screenshot">
<img src=".jpg"/>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h1 class="text-danger text-center">Multi-language Support..</h1>
<h4 class="oe_slogan"> </h4>
<div class="oe_demo oe_screenshot">
<img src="cnreadme.jpg"/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Technical Help & Support</h2>
</div>
<div class="col-md-12 pad0">
<div class="oe_mt16">
<p><h4>
For any type of technical help & support requests, Feel free to contact us</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:guohuadeng@hotmail.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> guohuadeng@hotmail.com</a>
<p><h4>
Via QQ: 300883 (App user would not get QQ or any other IM support. Only for odoo project customize.)</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:300883@qq.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> 300883@qq.com</a>
</div>
<div class="oe_mt16">
<p><h4>
Visit our website for more support.</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="https://www.odooai.cn" target="_blank"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-web"></i>https://www.odooai.cn</a>
</div>
</div>
</div>
<div class="oe_row oe_spaced text-center">
<h1>More Powerful addons, Make your odoo very easy to use, easy customize:
<a class="btn btn-primary mb16" href="http://www.odoo.com/apps/modules/browse?author=odooai.cn">odooai.cn Odoo Addons</a>
</h1>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="app_view_blog_post_search" model="ir.ui.view">
<field name="name">app.blog.post.search</field>
<field name="model">blog.post</field>
<field name="inherit_id" ref="website_blog.view_blog_post_search"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<searchpanel>
<field name="blog_id"/>
</searchpanel>
</xpath>
</field>
</record>
</odoo>