| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
OpenERP::OOM::Schema |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSYS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 METHODS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 class |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Provides the OpenERP::OOM::Class class object requested. This will |
|
14
|
|
|
|
|
|
|
load the class into memory. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $accounts = $schema->class('Accounts'); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 timeout |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Set the timeout - passes through to the $self->client->openerp_rpc->timeout() method underneath. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 PROPERTIES |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 openerp_connect |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This should be populated with a hash of the OpenERP connection details. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
<openerp_connect> |
|
29
|
|
|
|
|
|
|
username admin |
|
30
|
|
|
|
|
|
|
password admin |
|
31
|
|
|
|
|
|
|
dbname company-database |
|
32
|
|
|
|
|
|
|
host openerp-server |
|
33
|
|
|
|
|
|
|
</openerp_connect> |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 link_provider |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Out of the box the links to the external database are generated each time the |
|
38
|
|
|
|
|
|
|
link is followed. It's generally a good idea to provide your own provider that |
|
39
|
|
|
|
|
|
|
provides a cached connection for the link. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
NOTE: this could do with more detail to explain it better. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 link_config |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This is the configuration for the externals links. Typcially it is setup with |
|
46
|
|
|
|
|
|
|
the connection information if the default link provider is used. If another link |
|
47
|
|
|
|
|
|
|
provider is provided this won't be necessary. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 client |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The XMLRPC client that talks to OpenERP. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 link |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Provides a link to another part of the database. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$schema->link('DBIC') |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 provide_link |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
A default implementation of a link provider that loads up an OpenERP::OOM::Link::$class |
|
62
|
|
|
|
|
|
|
on the fly. This is slow so you normally don't want to use this. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright (C) 2011 OpusVL |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use 5.010; |
|
73
|
1
|
|
|
1
|
|
990
|
use Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
74
|
1
|
|
|
1
|
|
5
|
use OpenERP::XMLRPC::Client; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
75
|
1
|
|
|
1
|
|
5872
|
|
|
|
1
|
|
|
|
|
966676
|
|
|
|
1
|
|
|
|
|
496
|
|
|
76
|
|
|
|
|
|
|
with 'OpenERP::OOM::DynamicUtils'; |
|
77
|
|
|
|
|
|
|
with 'OpenERP::OOM::Link::Provider'; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has 'openerp_connect' => ( |
|
80
|
|
|
|
|
|
|
isa => 'HashRef', |
|
81
|
|
|
|
|
|
|
is => 'ro', |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
has 'link_config' => ( |
|
85
|
|
|
|
|
|
|
isa => 'HashRef', |
|
86
|
|
|
|
|
|
|
is => 'ro', |
|
87
|
|
|
|
|
|
|
); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has link_provider => ( |
|
90
|
|
|
|
|
|
|
isa => 'OpenERP::OOM::Link::Provider', |
|
91
|
|
|
|
|
|
|
is => 'ro', |
|
92
|
|
|
|
|
|
|
lazy_build => 1, |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has 'client' => ( |
|
96
|
|
|
|
|
|
|
isa => 'OpenERP::XMLRPC::Client', |
|
97
|
|
|
|
|
|
|
is => 'ro', |
|
98
|
|
|
|
|
|
|
lazy => 1, |
|
99
|
|
|
|
|
|
|
builder => '_build_client', |
|
100
|
|
|
|
|
|
|
); |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
has lang => ( |
|
103
|
|
|
|
|
|
|
isa => 'Str', |
|
104
|
|
|
|
|
|
|
is => 'ro', |
|
105
|
|
|
|
|
|
|
default => 'en_GB', |
|
106
|
|
|
|
|
|
|
); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
|
109
|
|
|
|
|
|
|
# we are also a link provider |
|
110
|
|
|
|
|
|
|
# so use that if one isn't provided. |
|
111
|
|
|
|
|
|
|
my $self = shift; |
|
112
|
|
|
|
|
|
|
return $self; |
|
113
|
0
|
|
|
0
|
|
|
} |
|
114
|
0
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $self = shift; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
die 'Your config file has not been loaded or wired up correctly.' unless $self->openerp_connect; |
|
120
|
0
|
|
|
0
|
|
|
return OpenERP::XMLRPC::Client->new(%{$self->openerp_connect}); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
0
|
0
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
has _class_cache => (is => 'ro', isa => 'HashRef', default => sub { {} } ); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my ($self, $class) = @_; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
if(exists $self->_class_cache->{$class}) |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
0
|
|
|
0
|
1
|
|
return $self->_class_cache->{$class}; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
0
|
0
|
|
|
|
|
my $package = $self->meta->name . "::Class::$class"; |
|
135
|
|
|
|
|
|
|
my $object_package = $self->meta->name . "::Object::$class"; |
|
136
|
0
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$self->ensure_class_loaded($package); |
|
138
|
0
|
|
|
|
|
|
$self->ensure_class_loaded($object_package); |
|
139
|
0
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$self->_class_cache->{$class} = $package->new( |
|
141
|
0
|
|
|
|
|
|
schema => $self, |
|
142
|
0
|
|
|
|
|
|
); |
|
143
|
|
|
|
|
|
|
return $self->_class_cache->{$class}; |
|
144
|
0
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
{ |
|
150
|
|
|
|
|
|
|
my ($self, $class) = @_; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return $self->link_provider->provide_link($class); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
0
|
1
|
|
my ($self, $class) = @_; |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
my $package = ($class =~ /^\+/) ? $class : "OpenERP::OOM::Link::$class"; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$self->ensure_class_loaded($package); |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
0
|
1
|
|
return $package->new( |
|
162
|
|
|
|
|
|
|
schema => $self, |
|
163
|
0
|
0
|
|
|
|
|
config => $self->link_config->{$class}, |
|
164
|
|
|
|
|
|
|
); |
|
165
|
0
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
my $self = shift; |
|
168
|
|
|
|
|
|
|
return $self->client->openerp_rpc->timeout(@_); |
|
169
|
0
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |