| 1 | package OpenERP::XMLRPC::Client; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: XMLRPC Client tweaked for OpenERP interaction. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | our $VERSION = '0.25'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use failures qw/openerp::fault/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use RPC::XML qw/RPC_STRING/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | has 'username' => ( is => 'ro', isa => 'Str', default => 'admin'); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | has 'password' => ( is => 'ro', isa => 'Str', default => 'admin'); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | has 'dbname' => ( is => 'ro', isa => 'Str', default => 'terp'); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | has 'host' => ( is => 'ro', isa => 'Str', default => '127.0.0.1'); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | has 'port' => ( is => 'ro', isa => 'Int', default => 8069); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | has 'proto' => ( is => 'ro', isa => 'Str', default => 'http'); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | has use_failures => (is => 'ro', isa => 'Bool', default => 0); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | has '_report_report_uri' => ( is => 'ro', isa => 'Str', default => 'xmlrpc/report' ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | has '_object_execute_uri' => ( is => 'ro', isa => 'Str', default => 'xmlrpc/object' ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | has '_object_execute_kw_uri' => ( is => 'ro', isa => 'Str', default => 'xmlrpc/object' ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | has '_object_exec_workflow_uri' => ( is => 'ro', isa => 'Str', default => 'xmlrpc/object' ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | has 'openerp_uid' => ( is => 'rw', isa => 'Int' ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | has 'base_rpc_uri' => ( is => 'rw', isa => 'Str', default => 'xmlrpc/common'); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | with 'MooseX::Role::XMLRPC::Client' => | |||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | name => 'openerp', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | login_info => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub _build_openerp_userid { shift->username } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_openerp_userid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub _build_openerp_passwd { shift->password } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_openerp_passwd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub _build_openerp_uri | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_openerp_uri: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | return $self->proto . '://' . $self->host . ':' . $self->port . '/' . $self->base_rpc_uri; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub openerp_login | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openerp_login: called CC=5 SCAR=32.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | # call 'login' method to get the uid.. | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | my $res = $self->openerp_rpc->send_request('login', RPC_STRING($self->dbname), $self->username, \$self->password ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( ! defined $res || ! ref $res ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $res and ref $res
MC/DC0%0/2
defined $res and ref $res
defined $res
ref $res
Truth table0%0/3
A and B
A= defined $resB= ref $res
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | die "Failed to log into OpenERP XML RPC service"; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | die "Incorrect username or password" if $$res == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # set the uid we have just had returned from logging in.. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->openerp_uid( ${ $res } ); | |||||||||||||||||||||||||||||||||||||||||
| 60 | # NOTE: OpenERP seems to be filling in faultCode not faultString these days | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # (6.1.1) so we need to check for that and display it instead. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if($self->use_failures) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->openerp_rpc->fault_handler(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | failure::openerp::fault->throw({ | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | msg => $_[0]->{faultCode} ? $_[0]->{faultCode}->value : $_[0]->string, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | payload => { original_exception => $_[0]} | ||||||||||||||||||||||||||||||||||||||||||
| 68 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | else | ||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->openerp_rpc->fault_handler(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | confess $_[0]->{faultCode} ? $_[0]->{faultCode}->value : $_[0]->string | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | sub openerp_logout | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openerp_logout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 82 | # do nothing on logout...nothing is required.. | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | sub BUILD | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | $RPC::XML::ENCODING = 'utf-8'; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | $self->openerp_login; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub change_uri | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_uri: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $base_uri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $exsting_base_uri = $self->base_rpc_uri; | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return $exsting_base_uri if $base_uri eq $exsting_base_uri; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->base_rpc_uri( $base_uri ); # change the base path. | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $self->openerp_rpc->uri( $self->_build_openerp_uri ); # rebuild and set the new uri. | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return $exsting_base_uri; # return the old uri. | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | sub object_execute | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_execute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $method = shift; # eg. 'search' | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $relation = shift; # eg. 'res.partner' | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my @args = @_; # All other args we just pass on. | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | # change the uri to base uri we are going to query.. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->change_uri( $self->_object_execute_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->simple_request | |||||||||||||||||||||||||||||||||||||||||
| 121 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 'execute', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | RPC_STRING($self->dbname), | ||||||||||||||||||||||||||||||||||||||||||
| 124 | $self->openerp_uid, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | \$self->password, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | $relation, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | $method, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | @args | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | sub object_execute_kw | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_execute_kw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $method = shift; # eg. 'search' | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $relation = shift; # eg. 'res.partner' | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my @args = @_; # All other args we just pass on. | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | # change the uri to base uri we are going to query.. | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->change_uri( $self->_object_execute_kw_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->simple_request | |||||||||||||||||||||||||||||||||||||||||
| 145 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 'execute_kw', | ||||||||||||||||||||||||||||||||||||||||||
| 147 | RPC_STRING($self->dbname), | ||||||||||||||||||||||||||||||||||||||||||
| 148 | $self->openerp_uid, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | \$self->password, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | $relation, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | $method, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | @args, | ||||||||||||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | sub object_exec_workflow | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_exec_workflow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $method = shift; # eg. 'search' | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $relation = shift; # eg. 'res.partner' | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my @args = @_; # All other args we just pass on. | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | # change the uri to base uri we are going to query.. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->change_uri( $self->_object_exec_workflow_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->simple_request | |||||||||||||||||||||||||||||||||||||||||
| 169 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 'exec_workflow', | ||||||||||||||||||||||||||||||||||||||||||
| 171 | RPC_STRING($self->dbname), | ||||||||||||||||||||||||||||||||||||||||||
| 172 | $self->openerp_uid, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | \$self->password, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | $relation, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | $method, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | @args | ||||||||||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | sub report_report | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report_report: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $report_id = shift; # eg. 'purchase.quotation' | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $object_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $parameters = shift; # eg. model, id and report_type | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | # change the uri to base uri we are going to query.. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->change_uri( $self->_report_report_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $self->simple_request | |||||||||||||||||||||||||||||||||||||||||
| 193 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 'report', | ||||||||||||||||||||||||||||||||||||||||||
| 195 | RPC_STRING($self->dbname), | ||||||||||||||||||||||||||||||||||||||||||
| 196 | $self->openerp_uid, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | \$self->password, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | $report_id, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | [$object_id], | ||||||||||||||||||||||||||||||||||||||||||
| 200 | $parameters, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | sub report_report_get | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report_report_get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $report_id = shift; # eg. 123 | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # change the uri to base uri we are going to query.. | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->change_uri( $self->_report_report_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $object = $self->simple_request | |||||||||||||||||||||||||||||||||||||||||
| 215 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 'report_get', | ||||||||||||||||||||||||||||||||||||||||||
| 217 | RPC_STRING($self->dbname), | ||||||||||||||||||||||||||||||||||||||||||
| 218 | $self->openerp_uid, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | \$self->password, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | $report_id, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if($object->{state}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $data = $object->{result}; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return decode_base64($data); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | sub simple_request | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
simple_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # I haven't forced dbname to be passed as string in here because it's possible other consumers of this class have | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # used it in other ways where the dbname wasn't necessarily the second argument. Therefore I've done it in | ||||||||||||||||||||||||||||||||||||||||||
| 238 | # each of its callers I know about. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | local *RPC::XML::boolean::value = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 242 | # this fudges the false so it's not 0 | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # which means if it was used to indicate null is probably going to work better. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | # the downside is that we presumably lose some precision when it comes to bools | ||||||||||||||||||||||||||||||||||||||||||
| 245 | # and nulls. | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return undef unless ${$self}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | return $self->openerp_rpc->simple_request(@_); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | sub create | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | return shift->_three_arg_execute('create', @_); | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | sub read | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($self, $object, $ids, $context, $fields) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $ids = [ $ids ] unless ( ref $ids eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ($context) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return $self->object_execute('read', $object, $ids, $fields, $context); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return $self->object_execute('read', $object, $ids); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | sub search | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my ($self, $object, $args, $context, $offset, $limit, $order) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ($context) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return $self->object_execute('search', $object, $args, $offset // 0, $limit, $order, $context); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$offset // 0
MC/DC0%0/1
$offset // 0
$offset
Truth table0%0/2
A
A= $offset
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return $self->object_execute('search', $object, $args); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | sub field_info | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return shift->_three_arg_execute('fields_view_get', @_); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | sub model_fields | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
model_fields: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return shift->_three_arg_execute('fields_get', @_); | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | sub update | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return shift->_array_execute('write', @_); | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | sub get_defaults | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_defaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return shift->_array_execute('default_get', @_); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | sub delete | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return shift->_array_execute('unlink', @_); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | sub copy | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return shift->_three_arg_execute('copy', @_); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub _three_arg_execute | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_three_arg_execute: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $verb = shift; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return $self->object_execute($verb, $object, $args, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | sub _array_execute | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_array_execute: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $verb = shift; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $ids = shift; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | # ensure we pass an array of IDs to the RPC.. | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $ids = [ $ids ] unless ( ref $ids eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return $self->object_execute($verb, $object, $ids, $args, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | sub search_detail | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_detail: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my ($self, $object, $args, $context, $offset, $limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | # search and get ids.. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $ids = $self->search( $object, $args, $context, $offset, $limit ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return unless ( defined $ids && ref $ids eq 'ARRAY' && scalar @$ids >= 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $ids and ref $ids eq "ARRAY" and scalar @$ids >= 1
defined $ids and ref $ids eq "ARRAY"
MC/DC0%0/3
defined $ids and ref $ids eq "ARRAY" and scalar @$ids >= 1
defined $ids
ref $ids eq "ARRAY"
scalar @$ids >= 1
Truth table0%0/4
A and B and C
A= defined $idsB= ref $ids eq "ARRAY"C= scalar @$ids >= 1
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | # read data from all the ids.. | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # FIXME: I'm fairly sure context is in the wrong place. | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | return $self->read( $object, $ids, $context ); | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | sub read_single | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_single: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $res = shift->read( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | return unless ( defined $res && ref $res eq 'ARRAY' && scalar @$res >= 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $res and ref $res eq "ARRAY" and scalar @$res >= 1
defined $res and ref $res eq "ARRAY"
MC/DC0%0/3
defined $res and ref $res eq "ARRAY" and scalar @$res >= 1
defined $res
ref $res eq "ARRAY"
scalar @$res >= 1
Truth table0%0/4
A and B and C
A= defined $resB= ref $res eq "ARRAY"C= scalar @$res >= 1
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return $res->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | __END__ | ||||||||||||||||||||||||||||||||||||||||||