summaryrefslogtreecommitdiff
path: root/FS/FS/svc_Common.pm
diff options
context:
space:
mode:
authorivan <ivan>2010-05-21 00:09:40 +0000
committerivan <ivan>2010-05-21 00:09:40 +0000
commit276c1e6f4efb7ba5568bee9189298bc1a757d34d (patch)
tree9639bb992d85aae630ce8a7b42a5466d9ddbafcf /FS/FS/svc_Common.pm
parentf1cd7f98b487e74aa60b6c41d3377cc60f7ac25a (diff)
agent virt inventory, RT#7010
Diffstat (limited to 'FS/FS/svc_Common.pm')
-rw-r--r--FS/FS/svc_Common.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index fd2745d..71290f4 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -735,10 +735,17 @@ sub set_auto_inventory {
$hash{'item'} = $self->getfield($field);
}
+ my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null' => 1,
+ 'table' => 'inventory_item',
+ );
+
my $inventory_item = qsearchs({
'table' => 'inventory_item',
'hashref' => \%hash,
- 'extra_sql' => 'LIMIT 1 FOR UPDATE',
+ 'extra_sql' => "AND $agentnums_sql",
+ 'order_by' => 'ORDER BY ( agentnum IS NULL ) '. #agent inventory first
+ ' LIMIT 1 FOR UPDATE',
});
unless ( $inventory_item ) {