You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo9安装product_print_zpl_barcode模块打印条码报AttributeError求助

Fix AttributeError: 'product.pricelist' object has no attribute 'get_product_pricelist' in Odoo 9

Hey there, let's get that barcode printing module working again! The error you're hitting is a straightforward method name mismatch—Odoo 9's product.pricelist model doesn't have a get_product_pricelist() method, but it does have the correct built-in method to fetch product prices from a pricelist.

Root Cause

In your _compute_price method, you're calling a non-existent method wiz.pricelist_id.get_product_pricelist(). The correct method name for Odoo 9 is get_product_price(), and it expects specific parameters that align with the version's API. Additionally, the final return wiz.price line in the method is unnecessary (and incorrect for multi-record operations) since @api.depends methods automatically update field values without needing a return.

Fixed Code for _compute_price

Replace your existing _compute_price method with this corrected version:

@api.depends('pricelist_id', 'quantity', 'product_id')
def _compute_price(self):
    # for regular barcodes
    for wiz in self:
        if wiz.pricelist_id and wiz.product_id:
            # Use Odoo 9's standard pricelist price retrieval method
            price_uom = wiz.pricelist_id.get_product_price(
                wiz.product_id, 1.0, partner_id=False, uom_id=wiz.uom_id.id
            )
            wiz.price_uom = price_uom
            wiz.price = price_uom * wiz.quantity

Key Changes Explained

  • Method Name Fix: Swapped get_product_pricelist() with get_product_price()—this is the official method in Odoo 9 for getting a product's price from a pricelist.
  • Parameter Alignment: Added uom_id=wiz.uom_id.id to ensure the price is calculated using the product's default unit of measure, which matches your module's logic.
  • Removed Unnecessary Return: The return wiz.price line was removed because @api.depends methods don't need to return values; they directly update the field values of each record in self.

Quick Additional Check

Double-check that your Odoo 9 instance has the core product module installed (which it should be, since you're working with product variants) and that the pricelist you're using has valid price rules configured for your products.

内容的提问来源于stack exchange,提问作者Dhouha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:22:28