如何在openerp中多次继承一个类?
我需要把采购订单这个类分成两种类型。一种是只能用于销售的产品的采购订单,另一种是只能用于购买的产品的采购订单。
我尝试把核心的 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 个回答
1
为了把那些表格添加到你的数据库里,你需要重启你的服务器和模块(就像Lukasz Puchala说的那样)。你的代码应该会创建新的表格。
不过我不太明白你最开始的需求,为什么不直接用sale.order来处理可以被出售的产品,而用purchase.order来处理可以被购买的产品呢?
顺便说一下:
你不需要创建一个叫做purchase.order.line.saleok的东西(因为它根本不会被用到),因为你的purchase.order.saleok会保持它最初的_fields定义,它会创建标准的purchase.order.line,而不是你想要的purchase.order.line.saleok(除非你修改了order_line这个字段,让它关联到purchase.order.line.saleok)。