问题描述
您好,我正在研究 odoo 11 会计,并且正在尝试在多公司中开发合并试算表,这是我的 sql 代码,显示了我所有帐户的试算表
query_inject_account = """
INSERT INTO
l10n_ro_report_trial_balance_account
(
report_id,create_uid,create_date,account_id,code,name,debit_opening,credit_opening,debit_initial,credit_initial,debit,credit,debit_total,credit_total,debit_balance,credit_balance)
SELECT
%s AS report_id,%s AS create_uid,NOW() AS create_date,accounts.*,CASE WHEN accounts.debit_total > accounts.credit_total
THEN accounts.debit_total - accounts.credit_total
ELSE 0
END AS debit_balance,CASE WHEN accounts.credit_total > accounts.debit_total
THEN accounts.credit_total - accounts.debit_total
ELSE 0
END AS credit_balance,SUM(accounts.debit_total) as total1,SUM(accounts.credit_total) as total2
FROM
(
SELECT
acc.id,acc.code,acc.name,coalesce(sum(open.debit),0) AS debit_opening,coalesce(sum(open.credit),0) AS credit_opening,coalesce(sum(init.debit),0) AS debit_initial,coalesce(sum(init.credit),0) AS credit_initial,coalesce(sum(current.debit),0) AS debit,coalesce(sum(current.credit),0) AS credit,0) + coalesce(sum(init.debit),0) +
coalesce(sum(current.debit),0) AS debit_total,0) + coalesce(sum(init.credit),0) +
coalesce(sum(current.credit),0) AS credit_total
FROM
account_account acc
LEFT OUTER JOIN account_move_line AS open
ON open.account_id = acc.id AND open.date < %s
LEFT OUTER JOIN account_move_line AS init
ON init.account_id = acc.id AND init.date >= %s AND init.date < %s
LEFT OUTER JOIN account_move_line AS current
ON current.account_id = acc.id AND current.date >= %s
AND current.date <= %s
LEFT JOIN account_move AS move
ON open.move_id = move.id AND move.state in (%s)
LEFT JOIN account_move AS init_move
ON init.move_id = init_move.id AND init_move.state in (%s)
LEFT JOIN account_move AS current_move
ON current.move_id = current_move.id AND current_move.state in (%s)
WHERE acc.id in %s
GROUP BY acc.id,accounts.*
ORDER BY acc.id) as accounts"""
这个代码让我总结借方,账户贷方,我想总结每个结果的总和 我遇到了这个错误,谁能帮助我,请
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)