【问题标题】:There is some error in my inheritance function我的继承函数有一些错误
【发布时间】:2019-07-02 10:23:56
【问题描述】:

我在 odoo 中的继承有错误

odoo.tools.convert.ParseError: "验证约束字段生产日期不存在时出错

我已经附上了 XML 代码和 python 文件

我也尝试过更改文件名并将模型保存在单独的文件中

XML 文件

<odoo>
  <data>
    <record id="stock_form_inherite_view" model="ir.ui.view">
      <field name="name">stock.date.inherit.view</field>
      <field name="model">stock.picking</field>
      <field name="inherit_id" ref="stock.view_picking_form" />
      <field name="arch" type="xml">
        <xpath expr="//field[@name='move_line_ids']/tree/field[@name='product_id']" position="after">
          <field name='production_date' readonly="1"/>
          <field name='expiry_date' readonly="1"/>
        </xpath>
      </field>
    </record>
  </data>
</odoo>

Python 文件

from odoo import models, fields

class StockPicking(models.Model):
"""Added the new field quantity which is related field to   stock_move."""
_inherit = 'stock.picking'

product_qty = fields.Float(string="Quantity", related="move_lines.product_uom_qty")



class stockpickingline(models.Model):
"""Added For the Production Date and Expiry Date"""
_inherit='account.invoice.line'
lot_number = fields.Many2one('stock.production.lot', string='Lot Number')
production_date = fields.Date('Production date',  related='lot_number.production_date')
expiry_date = fields.Datetime('Expiry date', related='lot_number.life_date')

【问题讨论】:

  • odoo.tools.convert.ParseError:“验证约束时出错字段production_date不存在

标签: python xml inheritance odoo-11


【解决方案1】:

您在 py 的 account.invoice.line 中添加 production_date 字段,并在 stock_picking 的 move_line_ids 中调用它。通常 stock.picking 中的 move_line_ids 与 stock_move 模型有关。请检查 move_line_ids 关系。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-08
    • 1970-01-01
    • 2021-05-26
    • 2014-01-10
    • 1970-01-01
    • 1970-01-01
    • 2020-10-02
    • 2016-11-01
    相关资源
    最近更新 更多