Closed aymen6 closed 6 years ago
ODataRow resPartner = row.getM2ORecord("person_id").browse()
hello , where can i put this ?
ODataRow resPartner = row.getM2ORecord("person_id").browse()
i rellay want to show the name of person not his id
this is method in fragement
public void onViewBind(View view, Cursor cursor, ODataRow row) { OControls.setText(view, R.id.name, row.getString("name")); OControls.setText(view, R.id.email, row.getString("message")); ODataRow resPartner = row.getM2ORecord("person_id").browse(); OControls.setText(view, R.id.company_name,resPartner);
this is the class sanction who haves informations about person
public class Sanction extends OModel { public static final String TAG = Sanction.class.getSimpleName(); public static final String AUTHORITY = "com.odoo.Person"; OColumn message = new OColumn("message", OText.class).setRequired();; OColumn name= new OColumn("name", OVarchar.class).setSize(100); OColumn student_id= new OColumn("student_id", ResPartner.class, OColumn.RelationType.ManyToOne); OColumn class_id= new OColumn("class_id", Classes.class, OColumn.RelationType.ManyToOne); OColumn type_id= new OColumn("type_id", typee.class, OColumn.RelationType.ManyToOne);
// @Odoo.Functional(store = true, depends = {"student_id"},
method = "storeCompanyName") // OColumn student_id = new OColumn("s", OVarchar.class).setSize(100) // .setLocalColumn();
public Sanction(Context context, OUser user) {
super(context,"proschool.sanction", user);
// setHasMailChatter(true);
}
/*public String storeCompanyName(OValues value) {
try {
if (!value.getString("student_id").equals("false")) {
List<Object> student_id = (ArrayList<Object>)
value.get("student_id"); return student_id.get(1) + ""; } } catch (Exception e) { e.printStackTrace(); } return ""; }*/ @Override public Uri uri() { return buildURI(AUTHORITY); }
}
i try to show the name but i can't can you help me plz and thank you if you need any more code i will put
On 14 March 2018 at 15:52, Afe Dare notifications@github.com wrote:
ODataRow resPartner = row.getM2ORecord("person_id").browse()
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Odoo-mobile/framework/issues/366#issuecomment-373049479, or mute the thread https://github.com/notifications/unsubscribe-auth/AXszPfmcb8ASMF1mdllBJak1t783VOamks5teS68gaJpZM4Smwy_ .
public void onViewBind(View view, Cursor cursor, ODataRow row) { ODataRow resPartnerRow = row.getM2ORecord("person_id").browse(); OControls.setText(view, R.id.name, resPartnerRow.getString("name")); }
doesn't work java.lang.Integer cannot be cast to com.odoo.core.orm.OM2ORecord
On 15 March 2018 at 10:22, Aymen Zairi zairiaymen6@gmail.com wrote:
On 15 March 2018 at 10:14, Afe Dare notifications@github.com wrote:
public void onViewBind(View view, Cursor cursor, ODataRow row) { ODataRow resPartnerRow = row.getM2ORecord("person_id").browse(); OControls.setText(view, R.id.name, resPartnerRow.getString("name")); }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Odoo-mobile/framework/issues/366#issuecomment-373309516, or mute the thread https://github.com/notifications/unsubscribe-auth/AXszPcjziGfXvmXroK5ngmaTUBEc5A7Lks5tejEEgaJpZM4Smwy_ .
person_id
is a json array
On 15 March 2018 at 10:29, Aymen Zairi zairiaymen6@gmail.com wrote:
doesn't work java.lang.Integer cannot be cast to com.odoo.core.orm.OM2ORecord
On 15 March 2018 at 10:22, Aymen Zairi zairiaymen6@gmail.com wrote:
On 15 March 2018 at 10:14, Afe Dare notifications@github.com wrote:
public void onViewBind(View view, Cursor cursor, ODataRow row) { ODataRow resPartnerRow = row.getM2ORecord("person_id").browse(); OControls.setText(view, R.id.name, resPartnerRow.getString("name")); }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Odoo-mobile/framework/issues/366#issuecomment-373309516, or mute the thread https://github.com/notifications/unsubscribe-auth/AXszPcjziGfXvmXroK5ngmaTUBEc5A7Lks5tejEEgaJpZM4Smwy_ .
person_id can't be a json array, its an integer --> OColumn person_id = new OColumn("name", ResPartner.class, OColumn.RelationType.ManyToOne);
Its not required
this is my fragment
@Override public void onViewBind(View view, Cursor cursor, ODataRow row) { OControls.setText(view, R.id.name, row.getString("name")); OControls.setText(view, R.id.email, row.getString("message")); (ligne 131) ODataRow resPartnerRow = row.getM2ORecord("student_id").browse(); OControls.setText(view, R.id.company_name, resPartnerRow.getString("Name"));
}
and this is the class
public class Sanction extends OModel { public static final String TAG = Sanction.class.getSimpleName(); public static final String AUTHORITY = "com.odoo.Etudiant"; OColumn message = new OColumn("message", OText.class).setRequired();; OColumn name= new OColumn("name", OVarchar.class).setSize(100); OColumn class_id= new OColumn("class_id", Classes.class, OColumn.RelationType.ManyToOne); OColumn type_id= new OColumn("type_id", typee.class, OColumn.RelationType.ManyToOne); OColumn student_id = new OColumn("Name", ResPartner.class, OColumn.RelationType.ManyToOne);
he shows me
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.ClassCastException: java.lang.Integer cannot be cast to com.odoo.core.orm.OM2ORecord at com.odoo.core.orm.ODataRow.getM2ORecord(ODataRow.java:69) at com.odoo.Etudiant.Student.onViewBind(PersonFragement.java:131)
what can i do
On 15 March 2018 at 10:34, Afe Dare notifications@github.com wrote:
person_id can't be a json array, its an integer --> OColumn person_id = new OColumn("name", ResPartner.class, OColumn.RelationType.ManyToOne);
Its not required
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Odoo-mobile/framework/issues/366#issuecomment-373314996, or mute the thread https://github.com/notifications/unsubscribe-auth/AXszPZtC4UQcpuLLiNiuBh7KvtRPabxUks5tejWZgaJpZM4Smwy_ .
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.ClassCastException: java.lang.Integer cannot be cast to com.odoo.core.orm.OM2ORecord at com.odoo.core.orm.ODataRow.getM2ORecord(ODataRow.java:69) at com.odoo.Etudiant.Student.onViewBind(PersonFragement.java:131)
error in log
On 15 March 2018 at 12:56, Aymen Zairi zairiaymen6@gmail.com wrote:
this is my fragment
@Override public void onViewBind(View view, Cursor cursor, ODataRow row) { OControls.setText(view, R.id.name, row.getString("name")); OControls.setText(view, R.id.email, row.getString("message")); (ligne 131) ODataRow resPartnerRow = row.getM2ORecord("student_id").browse(); OControls.setText(view, R.id.company_name, resPartnerRow.getString("Name"));
}
and this is the class
public class Sanction extends OModel { public static final String TAG = Sanction.class.getSimpleName(); public static final String AUTHORITY = "com.odoo.Etudiant"; OColumn message = new OColumn("message", OText.class).setRequired();; OColumn name= new OColumn("name", OVarchar.class).setSize(100); OColumn class_id= new OColumn("class_id", Classes.class, OColumn.RelationType.ManyToOne); OColumn type_id= new OColumn("type_id", typee.class, OColumn.RelationType.ManyToOne); OColumn student_id = new OColumn("Name", ResPartner.class, OColumn.RelationType.ManyToOne);
he shows me
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.ClassCastException: java.lang.Integer cannot be cast to com.odoo.core.orm.OM2ORecord at com.odoo.core.orm.ODataRow.getM2ORecord(ODataRow.java:69) at com.odoo.Etudiant.Student.onViewBind(PersonFragement.java:131)
what can i do
On 15 March 2018 at 10:34, Afe Dare notifications@github.com wrote:
person_id can't be a json array, its an integer --> OColumn person_id = new OColumn("name", ResPartner.class, OColumn.RelationType.ManyToOne);
Its not required
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Odoo-mobile/framework/issues/366#issuecomment-373314996, or mute the thread https://github.com/notifications/unsubscribe-auth/AXszPZtC4UQcpuLLiNiuBh7KvtRPabxUks5tejWZgaJpZM4Smwy_ .
i need to show the person name actually i show the id of person
public void onViewBind(View view, Cursor cursor, ODataRow row) { OControls.setText(view, R.id.name, row.getString("person_id")); } there are a relation manyToOne between class (sanction) and (ResPartner)
in this class(sanction) i put this code OColumn person_id = new OColumn("name", ResPartner.class, OColumn.RelationType.ManyToOne); he shows me the id of person but i need to show his name what can i do ?
"person_id": [ 81, " JackZ" ],