0
我需要在openerp中創建一個選擇字段,它的值應該從一個函數加載,而且這個字段需要與另一個表的多個二元關係。我已經創建了選擇字段和值從函數加載,但許多二元關係不起作用。下面給出的是我的代碼。多對一的關係在fields.selection()中不起作用openerp
def _sel_proj(self, cr, uid, context=None):
cr.execute("""SELECT project.id,account.name FROM project_project project
LEFT JOIN account_analytic_account account ON
account.id = project.analytic_account_id
LEFT JOIN project_user_rel rel ON rel.project_id = project.id
WHERE (account.user_id = %s or rel.uid = %s)
GROUP BY project.id,account.name"""%(uid, uid))
return [(r[0],r[1]) for r in cr.fetchall()]
_name = 'mat.mgmt'
_columns = {'project_id':fields.selection(_sel_proj,string='Project',type="many2one",relation="project.project",select="true",required="true"),}
使用many2one字段並覆蓋def search()函數以實現此目的 – senthilnathang