161 lines
5.8 KiB
Python
161 lines
5.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
import os
|
|
from odoo import models, fields, api
|
|
from odoo.http import request
|
|
from odoo.addons.http_routing.models.ir_http import _guess_mimetype
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class websiteMenu(models.Model):
|
|
_inherit = "website.menu"
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
res = super().create(vals_list)
|
|
return res
|
|
|
|
|
|
class IrHttp(models.AbstractModel):
|
|
_inherit = 'ir.http'
|
|
|
|
@classmethod
|
|
def _serve_page(cls):
|
|
req_page = request.httprequest.path
|
|
_, ext = os.path.splitext(req_page)
|
|
|
|
def _search_page(comparator='='):
|
|
page_domain = [('url', comparator, req_page)] + request.website.website_domain()
|
|
return request.env['website.page'].sudo().search(page_domain, order='website_id asc', limit=1)
|
|
|
|
# specific page first
|
|
page = _search_page()
|
|
|
|
if req_page != "/":
|
|
response = request.render(page.view_id.id, {
|
|
'main_object': page,
|
|
}, mimetype=_guess_mimetype(ext))
|
|
return response
|
|
|
|
res_id = request.env['ir.model.data'].sudo()._xmlid_to_res_id('tx_cms_upgrade.data_tx_home_description')
|
|
home_id = request.env["tx.home.description"].sudo().browse([res_id])
|
|
response = request.render("tx_cms_upgrade.txhomepage", {
|
|
"bannerIds": home_id.banner_ids,
|
|
"twoLevelTitle": home_id.two_level_title,
|
|
"twoLevelDescription": home_id.two_level_description,
|
|
"twoSubMenuIds": home_id.sub_menu_ids,
|
|
"threeMenuIds": home_id.three_menu_ids,
|
|
"partnerIds": home_id.partner_ids,
|
|
"fourDataTitle": home_id.four_data_title,
|
|
"fourDataIds": home_id.four_data_ids,
|
|
}, mimetype=_guess_mimetype(ext))
|
|
return response
|
|
|
|
|
|
class HomeDescription(models.Model):
|
|
_name = "tx.home.description"
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_description = "首页描述"
|
|
|
|
name = fields.Char(tracking=True)
|
|
banner_ids = fields.One2many("tx.home.banner", "home_id", string="Banner")
|
|
|
|
# 二层
|
|
two_level_title = fields.Char(string="标题", tracking=True)
|
|
two_level_description = fields.Char(string="描述", tracking=True)
|
|
sub_menu_ids = fields.One2many("tx.home.two.sub.menu", "home_id", string="二层卡片")
|
|
|
|
# 三层
|
|
three_menu_ids = fields.One2many("tx.home.three.sub.menu", "home_id", string="三层卡片")
|
|
|
|
# 四层
|
|
four_data_title = fields.Char("四层标题", tracking=True)
|
|
four_data_ids = fields.One2many("tx.home.four.data", "home_id", string="四层信息")
|
|
|
|
partner_ids = fields.One2many("tx.home.partner", "home_id", string="合作伙伴")
|
|
|
|
remarks = fields.Text(string="备注")
|
|
|
|
|
|
class HomeBanner(models.Model):
|
|
_name = "tx.home.banner"
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_description = "首页Banner"
|
|
|
|
home_id = fields.Many2one("tx.home.description", string="首页描述")
|
|
img = fields.Image(string="图片", tracking=True)
|
|
banner_one_title = fields.Char(string="一级标题", tracking=True)
|
|
banner_two_title = fields.Char(string="二级标题", tracking=True)
|
|
banner_three_title = fields.Char(string="三级标题", tracking=True)
|
|
banner_btn_name = fields.Char(string="按钮名称", tracking=True)
|
|
banner_btn_url = fields.Char(string="连接地址", tracking=True)
|
|
|
|
|
|
class HomeTwoSubMenu(models.Model):
|
|
_name = "tx.home.two.sub.menu"
|
|
_description = "首页二层设置"
|
|
|
|
home_id = fields.Many2one("tx.home.description", string="首页描述")
|
|
img = fields.Image(string="图片", tracking=True)
|
|
title = fields.Char(string="标题", tracking=True)
|
|
description = fields.Char(string="描述", tracking=True)
|
|
btn_name = fields.Char(string="按钮名称", tracking=True)
|
|
btn_url = fields.Char(string="连接地址", tracking=True)
|
|
|
|
|
|
class HomeThreeSubMenu(models.Model):
|
|
_name = "tx.home.three.sub.menu"
|
|
_description = "首页三层设置"
|
|
|
|
home_id = fields.Many2one("tx.home.description", string="首页描述")
|
|
title = fields.Char(string="顶级菜单")
|
|
line_ids = fields.One2many("tx.home.three.sub.menu.line", "three_menu_id", string="二级菜单", tracking=True)
|
|
|
|
|
|
class txHomeThreeSubMenuLine(models.Model):
|
|
_name = "tx.home.three.sub.menu.line"
|
|
_description = "三层菜单明细"
|
|
|
|
three_menu_id = fields.Many2one("tx.home.three.sub.menu", string="")
|
|
name = fields.Char(string="名称")
|
|
description = fields.Char(string="描述")
|
|
img = fields.Image(string="图片", tracking=True)
|
|
|
|
|
|
class HomeFiveSubMenu(models.Model):
|
|
_name = "tx.home.partner"
|
|
_description = "首页合作伙伴"
|
|
|
|
home_id = fields.Many2one("tx.home.description", string="首页描述")
|
|
name = fields.Char(string="名称", tracking=True)
|
|
img = fields.Image(string="图片", tracking=True)
|
|
|
|
|
|
class HomeFourData(models.Model):
|
|
_name = "tx.home.four.data"
|
|
_description = "四层信息"
|
|
|
|
home_id = fields.Many2one("tx.home.description", string="首页描述")
|
|
img = fields.Image(string="图片", tracking=True)
|
|
tag_name = fields.Char(string="标签", tracking=True)
|
|
title = fields.Char(string="标题", tracking=True)
|
|
content = fields.Html(string="内容", tracking=True)
|
|
data_btn_name = fields.Char(string="按钮名称", tracking=True)
|
|
data_btn_url = fields.Char(string="连接地址", tracking=True)
|
|
line_id = fields.One2many("tx.home.four.data.line", "data_id", string="明细")
|
|
|
|
|
|
class HomeFourDataLine(models.Model):
|
|
_name = "tx.home.four.data.line"
|
|
_description = "四层信息明细"
|
|
|
|
data_id = fields.Many2one("tx.home.four.data", string="信息")
|
|
amount = fields.Float(string="数额", tracking=True)
|
|
amount_explain = fields.Char(string="数额说明", tracking=True)
|
|
remarks = fields.Char(string="备注", tracking=True)
|
|
explain = fields.Char(string="说明", tracking=True)
|
|
|
|
|
|
|