以下の方法ではcomplete_operation
アクティブIDを印刷するのに使用しましたが、None
と表示されます。現在のIDはmrp.production
です。 mrp.operations
は、mrp.production
のone2manyフィールドです。odoo 9でone2manyのactive_idを取得する方法は?
class mrpProduction(models.Model):
_inherit = "mrp.production"
end_date = fields.Datetime('Scheduled End Date')
operations = fields.One2many('mrp.operations','operation_id', 'Operations')
class mrpOperations(models.Model):
_name = "mrp.operations"
name = fields.Many2one("custom.operations", "Operation Name")
status = fields.Selection([('Completed','Completed'),('Pending','Pending')],'Status')
operation_id = fields.Integer()
@api.multi
def complete_operation(self):
print self.id
active_id=self.env.context.get('active_id')
print active_id,'--'
'operation_id'は' mrp.production'の 'Many2one 'でなければなりません。そして、 'complete_operation()'とは何ですか?プロダクションと操作の間にはたくさんの関係があるので、 'self.operation_id.id'(' Many2one'に変更したと仮定して)を出力/返すことができます。 – CZoellner
@Mani Active Idあなたはウィザードオブジェクトを使用している場合にのみ表示されます –