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

时间:2014-04-23 05:40:33

标签: python openerp 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()

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

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

但是我不明白你的第一个需求,为什么你不能使用 sale.order 来购买产品 > purchase.order 可以购买的产品

仅供参考:

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