我创建了一个新模块,以使用Odoo Mobile框架显示,创建,编辑和删除(project.task)模型上的记录
public class ProjectTask extends OModel {
public static final String TAG = ProjectTask.class.getSimpleName();
public static final String AUTHORITY = "com.odoo.addons.projects.project_tasks";
OColumn name = new OColumn("Name", OVarchar.class).setSize(100);
OColumn project_id = new OColumn("Project", ProjectProject.class, OColumn.RelationType.ManyToOne);
OColumn description = new OColumn("Description", OText.class);
public ProjectTask(Context context, OUser user) {
super(context, "project.task", user);
setHasMailChatter(true);
}
@Override
public Uri uri() {
return buildURI(AUTHORITY);
}
}
和另一种用于在ManyToOne字段(project_id)中查看项目的模型
public class ProjectProject extends OModel {
public static final String TAG = ProjectProject.class.getSimpleName();
OColumn name = new OColumn("Name", OVarchar.class).setSize(100);
public ProjectProject(Context context, OUser user) {
super(context, "project.project", user);
}
}
并且当我在布局中定义了可编辑字段(project_id)时,我确保添加了app:widgetType =“ SearchableLive”
为了使用选择小部件来选择项目
<odoo.controls.OField
android:id="@+id/edit_project_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:controlLabel="Project"
app:fieldName="project_id"
app:fieldTextAppearance="?android:textAppearanceMedium"
app:widgetType="SearchableLive"></odoo.controls.OField>
但是该字段仅作为所选投影的整数ID出现,如此屏幕快照所示!
Screen shot from Mobile Form View
我该如何修复此代码,以便项目名称出现在表单中,当我单击此可编辑字段时,它会进入搜索视图并以与res.partner中的country_id相同的方式选择所需的项目,如以下屏幕截图?
Screen shot from Customers Mobile Form View
当我单击“国家/地区”时,会显示此搜索视图?