【问题标题】:How do I solve psycopg2.ProgrammingError: column reference "account_analytic_id" is ambiguous in odoo如何解决 psycopg2.ProgrammingError:列引用“account_analytic_id”在 odoo 中不明确
【发布时间】:2023-03-07 03:41:01
【问题描述】:

我正在尝试将模块从 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"

【问题讨论】:

  • 您标记 Odoo 版本 8 和版本 12 有什么原因吗?
  • 是的,让我认为这两个版本都有经验的开发人员有更多的受众

标签: python odoo odoo-8 odoo-12


【解决方案1】:

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

可以看到here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-09
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    • 2018-05-23
    • 2021-03-29
    • 1970-01-01
    相关资源
    最近更新 更多