SELECT l.journal_id, %s
FROM account_move_line AS l
LEFT JOIN account_journal j ON (j.id = l.journal_id)
WHERE l.state <> 'draft'
AND l.journal_id IN (%s)
AND (l.account_id = j.default_credit_account_id OR
l.account_id = j.default_debit_account_id)
我收到错误
column l.state does not exist LINE 17: WHERE l.state <> 'draft'
account_move_line
没有"state"
,但它与account_move
有state
。关系是move_id
那我怎么写得正确呢?我试过了
WHERE l.move_id.state <> 'draft'
但是我收到了一个错误
missing FROM-clause entry for table "move_id"
LINE 17: WHERE l.move_id.state <> 'draft'
^
基本上我需要与move_id
相关的account_move_line state <> 'draft'
请使用以下查询:
SELECT l.journal_id, %s
FROM account_move_line AS l
INNER JOIN account_move am ON l.move_id = am.state_id
LEFT JOIN account_journal j ON (j.id = l.journal_id)
WHERE am.state <> 'draft'
AND l.journal_id IN (%s)
AND (l.account_id = j.default_credit_account_id OR
l.account_id = j.default_debit_account_id)