您好,登錄后才能下訂單哦!
class:
import time from openerp.osv import osv from openerp.report import report_sxw class stock_picking_out(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(stock_picking_out, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, 'get_partner_product': self._get_partner_product, }) # todo 獲取客戶產品編碼: def _get_partner_product(self, partner, product_id): sql = """SELECT cp.partner_default_code FROM customer_product cp LEFT JOIN res_partner rp ON rp.id = cp.partner_id WHERE cp.product_id = %s AND cp.partner_id = %s""" self.cr.execute(sql, (product_id, partner)) sql_data = self.cr.fetchall() if len(sql_data) > 0: for obj in sql_data: partner_default_code = obj[0] return partner_default_code return '' class report_stockpickingout(osv.AbstractModel): _name = 'report.report_stock.report_stockpickingout' _inherit = 'report.abstract_report' _template = 'report_stock.report_stockpickingout' _wrapped_report_class = stock_picking_out
Report_view:
<td class="text-left">
<span t-esc="get_partner_product(doc.partner_id.id,l.product_id.id)"/>
</td>
當我在打印的時候,報出的問題:
QWebException: "'NoneType' object is not callable" while evaluating 'get_partner_product(doc.partner_id.id,l.product_id.id)'
Answer:
在"_name"時,路徑的錯誤,必須要添加上"report"的引用:
class report_stockpickingout(osv.AbstractModel): _name = 'report.report_stock.report_stockpickingout'
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。