qweb 相关问题

QWeb是OpenERP / Odoo Web客户端使用的模板引擎。它是一种基于XML的模板语言,类似于Genshi,Thymeleaf或Facelets

Odoo QWEB:仅显示具有任意长度的元素

我有一个注释字段,我想在 Odoo 报告中显示它,但前提是它有任意长度。 我尝试了这个但没有成功: 我想在 Odoo 报告中显示一个注释字段,但前提是它具有任意长度。 我尝试过但没有成功: <t t-if="len(o.note) > 0" <div t-field="o.note" style="border:1px solid black;"></div> </t> 出现错误。这样做的正确方法是什么? 提前谢谢。使用 Odoo 16.0 尝试这个方法;如果该字段不包含任何值,Odoo 将声明它 False,因此您实际上不需要检查长度。 <t t-if="o.note" <div t-field="o.note" style="border:1px solid black;"></div> </t>

回答 1 投票 0

第二页与第一页odoo报告的页边距不同

大家好,我创建了一个自定义的外部布局,其中没有公司的徽标或信息,我在报告中使用了 A4 纸张格式,顶部边距为 40 毫米,底部边距为 30 毫米,但是当我...

回答 1 投票 0

在 Odoo 16 QWeb 模板中,<link>标签的内容添加在标签之后,而不是在

我在 Odoo 16 QWeb 模板中看到一些奇怪的行为。给定以下模板: 测试 这个

回答 1 投票 0

在 Odoo17 中使用 Qweb 循环浏览群组列表

我正在尝试在 Odoo17 的 Qweb 报告上按类别显示产品列表。我在 python 类中创建了我的列表。处理完成后,这个 python 列表如下所示: { '办公家具...

回答 1 投票 0

如何在 Odoo 社区(Saas)中创建另一个发票模板

我正在尝试在 Odoo 17 社区 (SaaS) 中创建一个带有自定义标题的新发票模板。 所以我首先做的是创建一个报告,它现在显示在我的发票中。 这是我的报告

回答 1 投票 0

Odoo 17错误:@spreadsheet/hooks:以下模块被其他模块需要但尚未定义

我有 Odoo 17 本地安装。我安装了一些模块,然后不知何故,当单击仪表板应用程序时,此错误开始直接显示在浏览器中: 需要以下模块...

回答 1 投票 0

如何在 Odoo 14 中扩展模板 xml:space="preserve"

我试图继承website_slides中的slide.slide.quiz.validation来更改电子学习中测验页面按钮的标签。升级我的自定义模块和

回答 1 投票 0

如何在页面加载时显示模式?

我有一个带有模式窗口的页面。我可以使用按钮和正确的 data-bs- 属性来显示和隐藏此模式。 现在,我想要的是在页面加载时显示模式。这似乎是唯一正确的...

回答 1 投票 0

Odoo 16 - QWeb 模板 - 在页面加载时显示模式

我有一个带有模式窗口的页面。 我可以使用按钮和正确的 data-bs- 属性来显示和隐藏此模式,这有效。 现在,我想要的是在页面加载时显示模式。看来...

回答 1 投票 0

Odoo V16 - 显示/隐藏网站注册表单上的动态输入

在网站注册表单上添加两个字段后, - 第一个是复选框“我是一家公司” - 第二个是输入字符 SIRET NUMBER 我正在尝试(目标是):隐藏第二个......

回答 1 投票 0

如何在odoo qweb中将float转换为int?

我需要有关 odoo 的帮助。 我想在 Odoo14 qweb 中将 float 转换为 int。 ...

回答 1 投票 0

在qweb报告Odoo中获取文档附件列表

我正在使用 qweb 报告生成一个文档,该文档应该使用 Odoo 的文档模块关联附件。但我不知道如何显示与 do 关联的附件列表...

回答 1 投票 0

使用javascript读取odoo16记录信息

我是 odoo 和 web 的新手,我有这个问题 我有一个模板,提供了一个下拉列表,其中包含可供选择的倡议,我需要查看有关所选倡议的一些信息...

回答 1 投票 0

Odoo 13:如何基于Qweb和颜色转换在看板视图中显示选择字段?

这是我第一次使用 Qweb for Odoo XML。我猜由于缺乏经验,我的代码无法按预期工作。预先非常感谢您。 我有一个选择字段: 优先级=fie...

回答 1 投票 0

如何在网站上的模式组件中显示我的自定义模型字段?

我对如何从后端模型检索数据并将其显示在我的网站上感到有点困惑。例如,我正在使用网站模型提供的拖放组件。我怎样才能

回答 1 投票 0

如何更改 Odoo 网站滑块中的背景图像

我一直在尝试替换通过 localhost:8069/slides 访问的 Odoo 网站滑块中的图像。但它仍然不会显示。我错过了一些进口吗? 我继承了 website_slides。

回答 1 投票 0

Odoo v14 _render_qweb_pdf(渲染编译 AST 时出错)

我正在尝试创建一个 cron,当产品数量几乎为 0 时发送库存警报 我正在尝试创建一个 cron,当产品数量几乎为 0 时发送库存警报 <record id="ir_cron_mort_crm" model="ir.cron"> <field name="name">Product Quantity Alert</field> <field name="model_id" ref="model_stock_quant"/> <field name="state">code</field> <field name="code">model.send_alert_email()</field> <field name="user_id" ref="base.user_admin"/> <field name="interval_number">1</field> <field name="interval_type">days</field> <field name="numbercall">-1</field> <field name="priority">0</field> <field name="active" eval="True"/> </record> 我正在使用此代码 from odoo import models, fields, api import base64 class StockQuant(models.Model): _inherit = 'stock.quant' alert_qty = fields.Float(string='Alert Quantity', store=True) def send_alert_email(self): # Retrieve the PDF report template print("innnnnn") report_template_id = self.env.ref('y_slnee_test.report_stock_alert')._render_qweb_pdf(self.id) print('report---',report_template_id) # Encode the PDF data in base64 format data_record = base64.b64encode(report_template_id[0]) print('data-----',data_record) # Attachment data ir_values = { 'name': "Report", 'type': 'binary', 'datas': data_record, 'store_fname': 'data_record', 'mimetype': 'application/x-pdf', } data_id = self.env['ir.attachment'].sudo().create(ir_values) print('created data ?----', data_id) template = self.env.ref('y_slnee_test.report_stock_reorder_report_template_id') print('email template------', template) # Associate the created attachment with the email template template.attachment_ids = [(6, 0, [data_id.id])] print('attached file---',template.attachment_ids) email_values = {'email_to': '[email protected]', 'email_from': '[email protected]'} template.sudo().send_mail(1, email_values=email_values, force_send=True) # Remove the attachment from the email template template.attachment_ids = [(3, data_id.id)] return True class StaticProducts(models.AbstractModel): _name = "report.y_slnee_test.report_stock_reorder_report_template" @api.model def _get_report_values(self, docids, data=None): report_data = [] product_ids = self.env['stock.quant'].search([]) for rec in product_ids: if rec.alert_qty: alert_qty = rec.available_quantity - rec.alert_qty if alert_qty < 0: values = {'product': rec.product_id.name or '', 'location': rec.location_id.name or '', 'available': rec.available_quantity or '', 'alert': alert_qty or ''} print(values) report_data.append(values) print(report_data) return { 'docs': report_data, } 当我手动运行 cron 且报告中没有任何内容(只有表标题)时,它正在运行 但当我有价值观时 {'product': 'BROTHER Toner-Kit (TN-2410)', 'location': 'Vendors', 'available': -58.0, 'alert': -68.0} {'product': 'Tintenpatrone schwarz (K-EPS-C13T34714010XL)', 'location': 'Vendors', 'available': -35.0, 'alert': -45.0} 我收到此错误: ValueError: <class 'odoo.addons.base.models.qweb.QWebException'>: "Error to render compiling AST" while evaluating 'model.send_alert_email()' 我确定问题出在这一行: report_template_id = self.env.ref('y_slnee_test.report_stock_alert')._render_qweb_pdf(self.id) 你能帮我吗? XML: <template id="report_stock_reorder_report_template"> <t t-call="web.html_container"> <t t-call="web.basic_layout"> <div class="page"> <div> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> <table class="table table-sm o_main_table"> <thead> <tr> <t t-set="colspan" t-value="4"/> <th class="text-right">Article</th> <th class="text-right">Emplacement</th> <th class="text-right">Qty Alert</th> <th class="text-right">Qty Disponible</th> <th class="text-right">(Qty Disponible - Qty d’Alert)</th> </tr> </thead> <tbody> <t t-if="docs" t-foreach="docs" t-as="l"> <tr> <td> <span t-if ="l.product" t-esc="l.product"/> </td> <td> <span t-if ="l.location" t-esc="l.location"/> </td> <td> <span t-if ="l.available" t-esc="l.available"/> </td> <td> <span t-if ="l.alert" t-esc="l.alert"/> </td> </tr> </t> </tbody> </table> </div> </div> </t> </t> </template> <!-- Definition of the report --> <record id="report_stock_alert" model="ir.actions.report"> <field name="name">Stock Alert Quantity</field> <field name="model">stock.quant</field> <field name="report_type">qweb-pdf</field> <field name="report_name">y_slnee_test.report_stock_reorder_report_template</field> <field name="report_file">y_slnee_test.report_stock_reorder_report_template</field> </record> 我尝试打印每一步来调试代码,我确定问题出在这一行: report_template_id = self.env.ref('y_slnee_test.report_stock_alert')._render_qweb_pdf(self.id) 我不知道如何解决 预览模块的链接,很简单 https://drive.google.com/file/d/1cXJ4DEIox-1LlhKgoDTkmh8xxmm-XQyM/view?usp=sharing

回答 1 投票 0

QWeb docker 镜像

有人能够构建包含机器人框架和 QWeb 安装的 docker 镜像吗?我能够构建图像,但用它运行测试没有成功。它说“资源文件‘Qweb’”

回答 1 投票 0

Odoo V15,500:移动到新服务器后出现内部服务器错误 |用户错误:附件与现有文件发生冲突

首先,感谢您的帮助,我是 Odoo 网站的初学者。 由于我已将 proxmox 网站 Odoo V15 移至新的 Proxmox(同一网站),该网站向我显示 500:内部服务器错误。之前

回答 1 投票 0

QWeb中传递给子模板的变量的范围是什么?

我正在使用 Odoo 13,但这是一个 QWeb 问题: 我在 QWeb 中得到了以下模板: ... 我正在使用 Odoo 13,但这是一个 QWeb 问题: 我在QWeb中得到如下模板: <template id="my_subtemplate"> <t t-set="foo" t-value="foo + 1"/> <p>Inside subtemplate: <t t-esc="foo"/></p> </template> 在其他模板中,我调用了两次,这样: <t t-set="foo" t-value="1"/> <t t-call="my_module.my_subtemplate"/> <t t-call="my_module.my_subtemplate"/> <p>Inside main template: <t t-esc="foo"/></p> 所以当我调用主模板时,我期望得到这个结果: Inside subtemplate: 2 Inside subtemplate: 3 Inside main template: 3 但是,我得到这个: Inside subtemplate: 2 Inside subtemplate: 2 Inside main template: 1 不能在子模板中修改变量吗?关于如何完成如此简单的任务有什么想法吗? 第一个问题:似乎在子模板中是不可能的。引自 13.0 文档: 或者,调用指令主体中设置的内容将是 在调用子模板之前评估,并且 can alter a local 上下文: 我将“本地上下文”解释为您内部foo的范围保留在子模板中,就像拥有外部foo的副本。 第二题:难。你可以使用循环,比如: <t t-set="foo" t-value="1"/> <t t-for="your_iterable" t-as="item"> <t t-set="foo" t-value="foo + 1"/> <t t-call="my_module.my_subtemplate"/> <p>Inside main template: <t t-esc="foo"/></p> <!-- subtemplate without t-set!!! --> 可以工作,因为现在foo一直保持在同一个范围内。

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.