Я хочу сделать мобильное приложение для запросов на отпуск в системе Odoo ERP.Я использовал реагировать родной, чтобы сделать приложение.проблема в том, что я пытался получить ввод от пользователя, а затем передать его в API Odoo для отправки в систему, но не могу найти хороший способ сделать это
Odoo api - 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>
);
}
}