obuchmann / odoo-jsonrpc

PHP Odoo Json-RPC connector, prepared for laravel integration
MIT License
34 stars 11 forks source link

Feature Request: addition of searchCount method (or count) #5

Closed xewl closed 2 years ago

xewl commented 2 years ago

Obuchmann\OdooJsonRpc\Odoo seems to be missing a way to get the count of a search result.

While Odoo->search uses Odoo\Endpoint->search, there's currently no alternative to reach Odoo\Endpoint->count from the Odoo provider.

obuchmann commented 2 years ago

Count is currently only implemented via the ->model('res.user') interface. As seen in the test cases:


    public function testCount()
    {
        $amount = $this->odoo
            ->model('res.partner')
            ->count();
        $this->assertEquals('integer', gettype($amount));
    }

    public function testCountWhere()
    {
        $amount = $this->odoo
            ->model('res.partner')
            ->count();

        $customerAmount = $this->odoo
            ->model('res.partner')
            ->where('is_company', '=', true)
            ->count();

        $this->assertLessThan($amount, $customerAmount);
    }
xewl commented 2 years ago

I will add the test for it asap, as I will be continuing on using this library in the following 2 weeks.

In one of my 2 use cases; I'm currently not using the model() (RequestBuilder) interface, as I'm building the Domain I needed for it myself. That's where I hit this use case.

Keep you posted :)

xewl commented 2 years ago

fyi, I reckon I've been postponing this, but I'll continue on this asap :)