gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:03:59 25 4
gpt4 key购买 nike

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

我试图将核心 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com