phpdrupalodoo-12

NameError: Method not available report


I made the web service to communicate two applications odoo12 and drupal. when i try to retrieve a report in odoo12 from drupal, i get this error message:

-Drupal:

Le site Web a rencontré une erreur inattendue. Veuillez essayer de nouveau plus tard.</br></br><em class="placeholder">Zend\XmlRpc\Client\Exception\FaultException</em>: Traceback (most recent call last):
  File &quot;C:\odoo-12.0\odoo\addons\base\controllers\rpc.py&quot;, line 63, in xmlrpc_2
    response = self._xmlrpc(service)
  File &quot;C:\odoo-12.0\odoo\addons\base\controllers\rpc.py&quot;, line 43, in _xmlrpc
result = dispatch_rpc(service, method, params)
  File &quot;C:/odoo-12.0\odoo\http.py&quot;, line 121, in dispatch_rpc
    result = dispatch(method, params)
  File &quot;C:/odoo-12.0\odoo\service\model.py&quot;, line 34, in dispatch
    raise NameError(&quot;Method not available %s&quot; % method)
NameError: Method not available report
 in <em class="placeholder">Zend\XmlRpc\Client-&gt;call()</em> (line <em class="placeholder">325</em> of <em class="placeholder">vendor\zendframework\zend-xmlrpc\src\Client.php</em>). <pre class="backtrace">Jsg\Odoo\Odoo-&gt;getReport(&#039;crm_ong.report_recufiscal&#039;, 0, &#039;qweb-pdf&#039;) (Line: 124)

-Odoo:

Traceback (most recent call last):
  File "C:/odoo-12.0\odoo\http.py", line 121, in dispatch_rpc
    result = dispatch(method, params)
  File "C:/odoo-12.0\odoo\service\model.py", line 34, in dispatch
    raise NameError("Method not available %s" % method)
NameError: Method not available report

-code drupal

public function submitForm(array &$form, FormStateInterface $form_state) {
        global $id_don;
        global $client;

        $id_don = (int) $form_state->getValues()['id_don'];


        $model = "crm.alima.don";
        $ids = [$id_don];

        $report_data=$client->getReport('crm_solthis.report_recufiscal', $id_don, 'qweb-pdf');


        header('Content-Type: application/pdf');
        echo $report_data;die();
        header('Content-Type: text/css');
        header("Content-Disposition: attachment; filename=RecuFiscal.pdf");

      }

Solution

  • The report service has been removed from Odoo since version 11.0.
    Relevant commits : c23ef9a, 3425752.

    I just inspected Odoo client used by Drupal and it appears the code doesn't take these changes into account :

    # from function getReport()
    $client = $this->getClient('report');
    $reportId = $client->call('report', $params);
    

    To fix your issue, don't use getReport, I guess it's still possible to grab some data for your model and print kind of a report by tweaking the method from the client.

    I suggest to switch to the object endpoint to get a generic XmlRpcClient on which you might be able to call render().

    For example you can use search() to get a reportId in the first place (no more report service but ir.actions.report model still available), and then try to read/render it like in this example (this is not 'client' code relative to Odoo but you get the idea).