Odoo 17 problem with Odoo/Request/Search.php
Hi there @obuchmann
I think there is a compatibility issue with Odoo 17. In Odoo/Request/Search.php you provide the $count parameter, but this parameter does not exist anymore since Odoo 17. See here: https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html#odoo.models.Model.search
This means that I am now getting errors like this returned from Odoo API: BaseModel.search() takes from 2 to 5 positional arguments but 6 were given
A related problem is that the count method in Odoo/Endpoint/ObjectEndpoint.php cannot be used anymore to retrieve the count.
You should add a SearchCount Request subclass similar to this:
class SearchCount extends Request
{
public function __construct(
string $model,
protected Domain $domain
)
{
parent::__construct( $model, 'search_count');
}
public function toArray(): array
{
return [
$this->domain->toArray(),
];
}
}
and then use that instead inside of the count method in Odoo/Endpoint/ObjectEndpoint.php
public function count(string $model, ?Domain $domain = null, int $offset = 0, ?int $limit = null, ?string $order = null, ?Options $options = null): int
{
return $this->execute(new SearchCount(
model: $model,
domain: $domain ?? new Domain()
), $options);
}
I hope you can fix it yourself like this. I could create a PR but I don't have much time and I probably will forget it. In the meantime, I just wanted to give you the chance to fix this.
PS: For Odoo <= 16 compatibility you might want to still allow the $order parameter for Search request, but if $count is not null, then maybe construct it to use search_count instead of search and only return the domain as part of the array params...
Thank you for your input! I added this in v1.8.0