0

我正在为 Odoo 13 创建一个自定义模块,该模块继承订单行页面上的销售订单。

这是我的模型

# -*- coding: utf-8 -*-

from odoo import models, fields


class application(models.Model):
    _inherit = 'sale.order'

    application = fields.Char()

这是我的 view.xml

<odoo>
    <record id="view_order_form" model="ir.ui.view">
        <field name="name">Application</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="before">
                <field name="application" string="Application"/>
            </xpath>
        </field>
    </record>

    <template id="application_document" inherit_id="sale.sale_order_portal_content">
        <xpath expr="//div[2]/section[1]/table//th[1]" position="before">
            <th class="text-left">Application</th>
        </xpath>
        <xpath expr="//div[2]/section[1]/table//td[1]" position="before">
            <td>
                <span t-field="line.application"/>
            </td>
        </xpath>
    </template>
</odoo>

这是我的清单.py

{
'name': "Application",

'summary': """
    Add a new field in sale order line - Application
    """,

'description': """
    This new field will determine the application of the said products in quotation
""",

'author': "Developer",
'website': "None",

# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Sales',
'version': '13.0.1.0.0',

# any module necessary for this one to work correctly
'depends': ['base', 'sale'],

# always loaded
'data': [
    # 'security/ir.model.access.csv',
    'views/application.xml',
],
# only loaded in demonstration mode
'demo': [
    'demo/demo.xml',
    ],
    'installable': True,
    'application': True,
    'auto_install': False
}

问题是,在我安装了 cust 应用程序后,在“添加部分”和“添加注释”的产品下将不起作用。

4

1 回答 1

0

将您的模型更改为_inherit = 'sale.order.line'。您正在尝试将字段添加到错误的对象中。

谢谢

于 2020-03-11T09:39:56.467 回答