我使用odoo 10,与我要销售的新对象的关系不起作用,我仅使用@ api.onchange('product_id')来检查我的关系的工作方式... 这是我的'paket.perjalanan'对象设计
from odoo import models, fields, api
class Paket(models.Model):
_name = 'paket.perjalanan'
name = fields.Char(string='Reference', readonly=True)
product_id = fields.Many2one('product.product', string='Sale', domain=[('type','=','service')], required=True)
.......
travel_line = fields.One2many('sale.order', 'travel_id', string='Paket Perjalanan')
@api.onchange('product_id')
def testing(self):
print self.travel_line
这是我的“ sale.order”继承对象
from odoo import models, fields, api
class SaleOrderCustom(models.Model):
_inherit = 'sale.order'
invoice_address = fields.Many2one('res.partner', string='Invoice Address', required=True)
delivery_address = fields.Many2one('res.partner', string='Delivery Address', required=True)
travel_id = fields.Many2one('paket.perjalanan', string='Travel Package', domain=[('state', '=', 'confirmed')])
document_line = fields.One2many('sale.document.line', 'document_id', string='Dokumen Line', required=True)
passport_line = fields.One2many('sale.passport.line', 'passport_id', string='Passport Line')
当我运行@ api.onchange('product_id')时,它仅显示sale.order()
,它应该显示为sale.order('some_id')
,任何人都可以给我建议吗?
答案 0 :(得分:0)
添加@api.depends
@api.onchange('product_id')
@api.depends('travel_line')
def testing(self):
print self.travel_line
希望它会对您有所帮助。