SOAP set_relation set_relationship doesn't work for AOS_Contracts<>Documents & Accounts<>Documents - Internal server error 500

While trying to set link between Account or AOS_Contract and Document using set_relationship, I’ve got an internal server error (500).

Error in Apache log: [Wed Mar 23 10:02:33.112821 2016] [:error] [pid 16953] [client] PHP Fatal error: Call to a member function add() on a non-object in /var/www/crmdev/soap/SoapSugarUsers.php on line 1418

I’ve tried to work out this situation and discovered that it might be a SuiteCRM bug (mismatched names of relations)
After that I’ve added a tiny block of code to SoapSugarUsers.php, just before line 1416 ( if (!empty($key)) { ):

if (($module1 == ‘AOS_Contracts’ || $module1 == ‘Accounts’) && $module2 == ‘Documents’)
{ $key = ‘documents’; $mod->load_relationship($key); $mod->$key->add($module2_id); return $error->get_soap_array(); }

And it fixed a problem.

I hope it should be done in next SuiteCRM releases.

Thank you for your attention.