如何在 php 中使用 xmlrpc 在 odoo 中创建日记条目和项目?
how to create journal entries and items in odoo using xmlrpc in php?
这是我用来创建日记条目的代码。
//Journal entry creation
function createJournalEntries($jId, $partnerId, $name, $amount, $ref, $periodId, $check, $date)
{
$dAccId = 8;
$cAccId = 6;
$name = 'tea';
$debit = 20;
$credit = 20;
$amtCur = 0.00;
$taxAcc = 15;
$taxAmt = 2;
$jlines = array (
new xmlrpcval(
array(
"name" => new xmlrpcval($name, "string"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"account_id" => new xmlrpcval($dAccId, "int"),
"debit" => new xmlrpcval(20.00, "float"),
"credit" => new xmlrpcval(0.00, "float")
)
),
new xmlrpcval(
array (
"name" => new xmlrpcval($name, "string"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"account_id" => new xmlrpcval($dAccId, "int"),
"debit" => new xmlrpcval(0.00, "float"),
"credit" => new xmlrpcval(20.00, "float")
)
)
);
$val = array (
"journal_id" => new xmlrpcval($jId, "int"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"name" => new xmlrpcval($name, "string"),
"amount" => new xmlrpcval($amount, "float"),
"ref" => new xmlrpcval($ref, "string"),
"peroid_id" => new xmlrpcval($periodId, "int"),
"date" => new xmlrpcval($date, "string"),
"to_check" => new xmlrpcval($check, "boolean"),
"line_id" => new xmlrpcval($jlines, "array"),
);
$module = 'account.move';
$method = 'create';
$valu= $this->create($module, $method, $val);
return $valu;
}
这是要创建的主要函数。
//function for create
public function create($module, $method, array $values = array()) {
$this->client->setSSLVerifyPeer(0);
if (strpos($this->userId, 'LOGIN FAIL:') === false) {
try {
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($this->dbname, "string"));
$msg->addParam(new xmlrpcval($this->userId, "int"));
$msg->addParam(new xmlrpcval($this->password, "string"));
$msg->addParam(new xmlrpcval($module, "string"));
$msg->addParam(new xmlrpcval($method, "string"));
$msg->addParam(new xmlrpcval($values, "struct"));
$response = $this->client->send($msg);
if (!empty($response->faultString())) {
return "FAIL: in create:".$response->faultString();
//return $userId;
}
return $response->value()->scalarval();
} catch (Exception $e) {
throw new Exception("Create Exception:". $e);
}
}else{
return $this->userId;
}
}
这里我无法通过日记条目获取日记条目。
xmlrpc 返回类似对象错误的错误
日记条目和项目创建
/**Journal entry creation**/
function createJournalEntries($jId, $partnerId, $name, $amount, $ref, $periodId, $check, $date)
{
$module = 'account.move';
$method = 'create';
$val = array (
'journal_id' => new xmlrpcval($jId, 'int'),
'partner_id' => new xmlrpcval($partnerId, 'int'),
'name' => new xmlrpcval($name, 'string'),
'amount' => new xmlrpcval($amount, 'float'),
'ref' => new xmlrpcval($ref, 'string'),
'peroid_id' => new xmlrpcval($periodId, 'int'),
'date' => new xmlrpcval($date, 'string'),
'to_check' => new xmlrpcval($check, 'boolean'),
);
$valu= $this->create($module, $method, $val);
/**Journal itmes creation**/
$module = 'account.move.line';
$method = 'create';
$name = 'TOMOTO';
$line1 = array (
'name' => new xmlrpcval($name, 'string'),
'account_id' => new xmlrpcval(25, 'int'),
'ref' => new xmlrpcval($ref, 'string'),
'debit' => new xmlrpcval(10.50, 'double'),
'credit' => new xmlrpcval(0.00, 'double'),
'move_id' => new xmlrpcval($valu, 'int'),
'date_created' => new xmlrpcval($date, 'string'),
'date' => new xmlrpcval($date, 'string')
);
$this->create($module, $method, $line1);
$line2 = array (
'name' => new xmlrpcval($name, 'string'),
'account_id' => new xmlrpcval(8, 'int'),
'ref' => new xmlrpcval($ref, 'string'),
'debit' => new xmlrpcval(0.00, 'double'),
'credit' => new xmlrpcval(10.50, 'double'),
'move_id' => new xmlrpcval($valu, 'int'),
'date_created' => new xmlrpcval($date, 'string'),
'date' => new xmlrpcval($date, 'string')
);
$this->create($module, $method, $line2);
return $valu;
}
这是我用来创建日记条目的代码。
//Journal entry creation
function createJournalEntries($jId, $partnerId, $name, $amount, $ref, $periodId, $check, $date)
{
$dAccId = 8;
$cAccId = 6;
$name = 'tea';
$debit = 20;
$credit = 20;
$amtCur = 0.00;
$taxAcc = 15;
$taxAmt = 2;
$jlines = array (
new xmlrpcval(
array(
"name" => new xmlrpcval($name, "string"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"account_id" => new xmlrpcval($dAccId, "int"),
"debit" => new xmlrpcval(20.00, "float"),
"credit" => new xmlrpcval(0.00, "float")
)
),
new xmlrpcval(
array (
"name" => new xmlrpcval($name, "string"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"account_id" => new xmlrpcval($dAccId, "int"),
"debit" => new xmlrpcval(0.00, "float"),
"credit" => new xmlrpcval(20.00, "float")
)
)
);
$val = array (
"journal_id" => new xmlrpcval($jId, "int"),
"partner_id" => new xmlrpcval($partnerId, "int"),
"name" => new xmlrpcval($name, "string"),
"amount" => new xmlrpcval($amount, "float"),
"ref" => new xmlrpcval($ref, "string"),
"peroid_id" => new xmlrpcval($periodId, "int"),
"date" => new xmlrpcval($date, "string"),
"to_check" => new xmlrpcval($check, "boolean"),
"line_id" => new xmlrpcval($jlines, "array"),
);
$module = 'account.move';
$method = 'create';
$valu= $this->create($module, $method, $val);
return $valu;
}
这是要创建的主要函数。
//function for create
public function create($module, $method, array $values = array()) {
$this->client->setSSLVerifyPeer(0);
if (strpos($this->userId, 'LOGIN FAIL:') === false) {
try {
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($this->dbname, "string"));
$msg->addParam(new xmlrpcval($this->userId, "int"));
$msg->addParam(new xmlrpcval($this->password, "string"));
$msg->addParam(new xmlrpcval($module, "string"));
$msg->addParam(new xmlrpcval($method, "string"));
$msg->addParam(new xmlrpcval($values, "struct"));
$response = $this->client->send($msg);
if (!empty($response->faultString())) {
return "FAIL: in create:".$response->faultString();
//return $userId;
}
return $response->value()->scalarval();
} catch (Exception $e) {
throw new Exception("Create Exception:". $e);
}
}else{
return $this->userId;
}
}
这里我无法通过日记条目获取日记条目。
xmlrpc 返回类似对象错误的错误
日记条目和项目创建
/**Journal entry creation**/
function createJournalEntries($jId, $partnerId, $name, $amount, $ref, $periodId, $check, $date)
{
$module = 'account.move';
$method = 'create';
$val = array (
'journal_id' => new xmlrpcval($jId, 'int'),
'partner_id' => new xmlrpcval($partnerId, 'int'),
'name' => new xmlrpcval($name, 'string'),
'amount' => new xmlrpcval($amount, 'float'),
'ref' => new xmlrpcval($ref, 'string'),
'peroid_id' => new xmlrpcval($periodId, 'int'),
'date' => new xmlrpcval($date, 'string'),
'to_check' => new xmlrpcval($check, 'boolean'),
);
$valu= $this->create($module, $method, $val);
/**Journal itmes creation**/
$module = 'account.move.line';
$method = 'create';
$name = 'TOMOTO';
$line1 = array (
'name' => new xmlrpcval($name, 'string'),
'account_id' => new xmlrpcval(25, 'int'),
'ref' => new xmlrpcval($ref, 'string'),
'debit' => new xmlrpcval(10.50, 'double'),
'credit' => new xmlrpcval(0.00, 'double'),
'move_id' => new xmlrpcval($valu, 'int'),
'date_created' => new xmlrpcval($date, 'string'),
'date' => new xmlrpcval($date, 'string')
);
$this->create($module, $method, $line1);
$line2 = array (
'name' => new xmlrpcval($name, 'string'),
'account_id' => new xmlrpcval(8, 'int'),
'ref' => new xmlrpcval($ref, 'string'),
'debit' => new xmlrpcval(0.00, 'double'),
'credit' => new xmlrpcval(10.50, 'double'),
'move_id' => new xmlrpcval($valu, 'int'),
'date_created' => new xmlrpcval($date, 'string'),
'date' => new xmlrpcval($date, 'string')
);
$this->create($module, $method, $line2);
return $valu;
}