在首页odoo中显示一个字段

问题描述

我已经在odoo中创建了一个模块,其模型名为“产品”,字符串字段为“ formelab”,我想在产品表的价格下方显示此“ formelab”字段。

This is the product page which I called PROD

That's the shop page

我想在PROD表上的“ $ 1.00”下显示“ ABCCCC”

这是views文件夹中的product_template.xml

``

    <?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="formelab_ref_id_form" model="ir.ui.view">
        <field name="name">access.product.view.form</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_only_form_view"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='type']" position="after">
                <field name="formelab_ref"/>
            </xpath>
        </field>
    </record>
</odoo>

and that's the product.py in the models folder

# -*- coding: utf-8 -*-
from odoo import api,fields,models


class product(models.Model):
    _inherit = 'product.template'
    formelab_ref = fields.Char("Formelab")

``

解决方法

您需要更改products_item模板。

以下代码在formelab_ref跨度之后添加priceCurrency值:

<template inherit_id="website_sale.products_item" id="daz">
    <xpath expr="//span[@itemprop='priceCurrency']" position="after">
        <span t-field="product.formelab_ref"/>
    </xpath>
</template>