Javascript react用于odoo的本机应用程序

Javascript react用于odoo的本机应用程序,javascript,reactjs,react-native,mobile,odoo,Javascript,Reactjs,React Native,Mobile,Odoo,我想在Odoo ERP系统中为假期请求制作移动应用程序。我用react native来制作这个应用程序。问题是我试图从用户那里获取输入,然后将其传递给odooapi,以便在系统中提交,但我找不到一个好的方法来完成 ODOOAPI-xmlrpc: var Odoo = require('odoo-xmlrpc'); var odoo = new Odoo({ url: 'http://abdelazizs-macbook-pro.local', port: '8069',

我想在Odoo ERP系统中为假期请求制作移动应用程序。我用react native来制作这个应用程序。问题是我试图从用户那里获取输入,然后将其传递给odooapi,以便在系统中提交,但我找不到一个好的方法来完成

ODOOAPI-xmlrpc:

var Odoo = require('odoo-xmlrpc');

var odoo = new Odoo({
    url: 'http://abdelazizs-macbook-pro.local',
    port: '8069',
    db: 'hr_2-9_test_11',
    username: 'admin',
    password: 'admin'
});

odoo.connect(function (err) {
    if (err) { return console.log(err); }
    console.log('Connected to Odoo server.');    
});

odoo.connect(function (err) {
    if (err) { return console.log(err); }
    console.log('Connected to Odoo server.');
    var inParams = [];
    inParams.push({'name': 'egg'
    ,'holiday_status_id':parseInt(1)
    , 'date_from':'2018-08-14 16:35:38'
    , 'date_to':'2018-08-16 16:35:38'
    , 'employee_id':parseInt(1)})
    var params = [];
    params.push(inParams);
    odoo.execute_kw('hr.holidays', 'create', params, function (err, value) {
        if (err) { return console.log(err); }
        console.log('Result: ', value);
    });
}); 
我们想用用户输入替换这些默认参数

{'name': 'egg'
    ,'holiday_status_id':parseInt(1)
    , 'date_from':'2018-08-14 16:35:38'
    , 'date_to':'2018-08-16 16:35:38'
    , 'employee_id':parseInt(1)}
以下是其中一个应用程序组件,其中包含领料日期:

    import React, { Component } from 'react';
import DatePicker from 'react-native-datepicker';
import {Text, View} from 'react-native';

export default class Component1 extends Component {
    constructor(props){
        super(props)
        this.state = {date:"2019-05-15"}



      }

 render(){
    return(

      <View>
        <Text style={{fontSize:25,}}>From</Text>
       <DatePicker
         style={{width: 300,justifyContent: 'center',
         }}
     date={this.state.date}
     mode="date"
     placeholder="select date"
     format="YYYY-MM-DD"

     confirmBtnText="Confirm"
     cancelBtnText="Cancel"

     customStyles={{
       dateIcon: {
         position: 'absolute',
         right: 0,
         top: 4,
         marginRight: 10


       },
       dateInput: {
         marginLeft: 36
       }
       // ... You can check the source to find the other keys.
     }}
     onDateChange={(date) => {this.setState({date: date})}}
   />

  </View>





    );


 }


}
import React,{Component}来自'React';
从“react native DatePicker”导入日期选择器;
从“react native”导入{Text,View};
导出默认类Component1扩展组件{
建造师(道具){
超级(道具)
this.state={日期:“2019-05-15”}
}
render(){
返回(
从…起
{this.setState({date:date}}}
/>
);
}
}

您必须调用组件,如

class MyComponent extends React.Component{
    state = {
        date: ''
    }
    callToOdoo = () => {
        //your odoo call
    }
    dateHandler = (date) => {
        this.setState({date: date}, () => {
            this.callToOdoo();
        })
    }
    render(){
        return(<View>
              <DatePicker
                  {...}
               onDateChange={{this.dateHandler}}
        />
类MyComponent扩展了React.Component{ 状态={ 日期:'' } callToOdoo=()=>{ //你的奥多电话 } dateHandler=(日期)=>{ this.setState({date:date},()=>{ 这个。callToOdoo(); }) } render(){ 返回(