【问题标题】:How to add a field in a purchase order line and perform an action in OpenERP如何在采购订单行中添加字段并在 OpenERP 中执行操作
【发布时间】:2019-04-12 14:57:05
【问题描述】:

我在采购订单行中添加了两个字段。它可以正常工作并保存,但是当我确认订单时,它会引发类似

的错误
AttributeError: "Field 'product_tunch' does not exist in object 'browse_record(purchase.order, 23)'"

此处字段添加成功,但为什么我在确认采购订单时出现错误,下面是我的字段

_columns={
    'product_tunch':fields.float('Tunch', digits_compute=  dp.get_precision('price_subtotal')),
    'product_kt':fields.selection([('14kt','14 KT'), ('18kt','18 KT'), ('20kt','20 KT')
                                   , ('22kt','22 KT'), ('24kt','24 KT')], 'Type', 
                                   size=32,),

我的功能是

def _amount_line(self, cr, uid, ids, prop, arg, context=None):
    res = {}
    cur_obj=self.pool.get('res.currency')
    tax_obj = self.pool.get('account.tax')
    for line in self.browse(cr, uid, ids, context=context):
        taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id, line.product_pc, line.order_id.partner_id)
        cur = line.order_id.pricelist_id.currency_id
        res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
        res[line.id]=(line.price_unit *line.product_qty*(line.product_tunch/100)) 
    return res

我的视图文件是

<record id="view_purchase_inherit_form"  model="ir.ui.view">
        <field name="name">purchase.inherit.form</field>
        <field name="model">purchase.order.line</field>
        <field name="inherit_id" ref="purcahse.view_order_form"/>
        <field name="arch" type="xml">
            <data>
                <xpath expr="//field[@name='taxes']" position="before">
                    <field name="product_tunch"/>
                    <field name="product_kt"/>
                </xpath>
            </data> 
        </field>
    </record> 

【问题讨论】:

  • 您在哪个对象中放置了“_amount_line”函数。 purchase_order 还是 purchase_order_line?

标签: python openerp


【解决方案1】:

在views文件第4行检查购买的拼写

【讨论】:

    【解决方案2】:
    1. 重启服务器并更新模块查看效果
    2. 如果没有,请通过 pgAdmin 检查 sql 表并在 purchase_order 中检查是否有 'product_tunch' 列
    3. 您是否在列上方的 .py _inherit = 'purchase.order' 中写入?您是否在 init.py 中添加了文件?

    我没有更多的想法

    【讨论】:

    • 我更新了模块并删除了该订单,但我在 account_invoice_line 中看不到 product_tunch 的值,我还在 account_invoice_line 中添加了该字段
    • 感谢您的回答,请为我的问题做点什么您好先生,我这样做了,但现在我想在发票报告中显示 product_tunch 但我无法在发票报告中显示此字段怎么能我这样做请帮忙
    【解决方案3】:

    您可以尝试使用以下语法启动服务器一次:

     openerp-server -c path/to/your/conf.file -d your_database -u module_to_update
    

    【讨论】:

      猜你喜欢
      • 2019-06-16
      • 1970-01-01
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      相关资源
      最近更新 更多