How to create a join using a reference field

I want to join move.shipment and

    if 'move.shipment' not in tables:
        shipment = Shipment.__table__()
        tables['move.shipment'] = shipment
        from_item = (from_item
            .join(shipment, condition=move.shipment ==

I receive this error.

psycopg2errorsUndefinedFunction: operator does not exist: character varying = integer
LINE 1: IN “stock_shipment_out” AS “k” ON (“b”“shipment” = “k”“id”
HINT: No operator matches the given name and argument types You might need to add explicit type casts

Also is related with this

def _where(cls, tables, withs):
    Shipment = Pool().get('stock.shipment.out')
    context = Transaction().context
    shipment = Shipment.__table__()
    move = tables['move']
    where = super()._where(tables, withs)
    customer = context.get('customer')
    if customer:
        where &= shipment.customer == customer
    return where

I receive this error

psycopg2errorsUndefinedTable: missing FROM-clause entry for table “k”
LINE 1: “b”“effective_date” <= ‘2023-10-04’::date)) AND (“k”"custo

move.shipment is a tuple with: shipment_model, id

Try something like this:

from_item = (from_item
        .join(shipment, (Concat(Shipment.__name__ + ',', == move.shipment))
1 Like

It works like a charm! Thanks

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.