我如何解决psycopg2.ProgrammingError:列引用“ account_analytic_id”在odoo中不明确

时间:2019-11-14 08:43:25

标签: python odoo odoo-8 odoo-12

我正在尝试将模块从odoo 8迁移到odoo 12,并且在odoo 12环境中尝试安装odoo 8模块时遇到此错误。

psycopg2.ProgrammingError: column reference "account_analytic_id" is ambiguous
LINE 18: ..., sub.product_id, sub.partner_id, sub.country_id, sub.accoun...

这是我怀疑错误来自的代码块

class AccountInvoiceReport(models.Model):
    _inherit = 'account.invoice.report'

    cost_center_id = fields.Many2one(
        'account.cost.center',
        string='Cost Center',
        readonly=True
    )
    account_analytic_id = fields.Many2one(
        'account.analytic.account',
        string='Analytic Account',
        readonly=True
    )

    def _select(self):
        return super(AccountInvoiceReport, self)._select() + \
            ", sub.cost_center_id as cost_center_id, " + \
            "sub.account_analytic_id as account_analytic_id"

    def _sub_select(self):
        return super(AccountInvoiceReport, self)._sub_select() + \
            ", ail.cost_center_id as cost_center_id, " + \
            "ail.account_analytic_id as account_analytic_id"

    def _group_by(self):
        return super(AccountInvoiceReport, self)._group_by() + \
            ", ail.cost_center_id, " + \
            "ail.account_analytic_id"

1 个答案:

答案 0 :(得分:0)

只需使用account_analytic_id删除查询部分,因为它已经在Odoo 12的account.invoice.report中。

可以看到here