python - 如何在openerp中多次继承一个类?

标签 python odoo openerp-7

我需要将采购订单类继承为两种类型。一种是针对产品只能出售的采购订单,另一种是针对产品只能购买的采购订单。

我试图将核心 purchase.order 对象继承到两个新的自定义对象中。但是它不起作用。

我的代码是

from osv import fields, osv

class purchase_order_saleok(osv.osv):

  _inherit = 'purchase.order'
  _name = 'purchase.order.saleok'

  STATE_SELECTION = [
    ('draft', 'Draft PO'),
    ('pending', 'Pending'),
    ('sent', 'RFQ Sent'),
    ('confirmed', 'Waiting Approval'),
    ('approved', 'Confirmed'),
    ('except_picking', 'Shipping Exception'),
    ('except_invoice', 'Invoice Exception'),
    ('done', 'Ordered'),
    ('cancel', 'Cancelled')]

  _columns =  {
    'state': fields.selection(
       STATE_SELECTION, 
       'Status', 
       readonly=True, 
       help="The status of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' status. Then the order has to be confirmed by the user, the status switch to 'Confirmed'. Then the supplier must confirm the order to change the status to 'Approved'. When the purchase order is paid and received, the status becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the status becomes in exception.",
       select=True
    )
  }

  purchase_order_saleok()

  class purchase_order_line_saleok(osv.osv):
    _inherit = 'purchase.order.line'
    _name = 'purchase.order.line.saleok'

  purchase_order_line_saleok()

谁能帮帮我?

最佳答案

为了将这些表添加到数据库中,您必须重新启动服务器和模块(正如 Lukasz Puchala 所说)。您的代码应创建新表。

但我不明白你的第一个需求,你为什么不使用 sale.order 用于可以sold 的产品,和 purchase.order 可以购买的产品?

仅供引用:

您不需要创建 purchase.order.line.saleok(因为它永远不会被使用),因为您的 purchase.order.saleok 将保留其第一个 _fields 定义,它将创建标准的 purchase.order.line 而不是你 purchase.order.line.saleok (除非你覆盖字段 order_line, one2many,与purchase.order.line.saleok)。

关于python - 如何在openerp中多次继承一个类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23235669/

相关文章:

python - 使用创建按钮直接打开 "one2many form view"(odoo)

python - 使用 Excel 工作表中的数据在 Python 中绘制图表

python - 如何有效地将数据框中的条目映射到字典

python - 3 级字典 python 不明显

python - openERP中变量赋值错误

openerp - python和odoo中的self.pool.get()是什么?

python - 具有前同级的多个值

postgresql - Odoo 10 - 取消的选股无法删除,为什么?

python - 员工标签验证错误的 odoo 分配请求?

python - Odoo 13 如何安装自定义模块