-1

这是我的模型

OColumn state_order = new OColumn("state_order", OSelection.class)
.addSelection("draft","New")
.addSelection("paid","Paid")
.addSelection("cancel","Cancelled")
.addSelection("done","Posted")
.addSelection("invoiced","Invoiced")

在我的片段中,我需要读取 state_order 值这是我的代码

 public void onViewBind(View view, Cursor cursor, ODataRow row) {
  OControls.setText(view, R.id.state, row.getString("state_order"));
   }

但他向我展示了错误的价值,我能做什么!

4

1 回答 1

0

该字段state_order必须以相同的名称存在于服务器中。
即使它有效,您也会得到draft而不是Draft Quotation,并且要获取值(而不是键),您将需要添加一个本地计算列:

@Odoo.Functional(method = "stateTitle", store=true, depends = {"state"})
OColumn state_title = new OColumn("State title", OVarchar.class)
       .setLocalColumn();

public String stateTitle (OValues values){
    HashMap<String,String> hm = new HashMap();
            hm.put ("draft", "Draft Quotation");
            hm.put ("sent", "Quotation Sent");
            hm.put ("cancel", "Cancelled");
            hm.put ("waiting_date", "Waiting Schedule");
            hm.put ("progress", "Sales Order");
            hm.put ("manual", "Sale to Invoice");
            hm.put ("shipping_except", "Shipping Exception");
            hm.put ("invoice_except", "Invoice Exception");
            hm.put ("done", "Done");

    return  hm.get(values.getString("state"));
}
于 2018-04-15T09:17:10.917 回答