首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法适应“account.analytic.account”类型

无法适应“account.analytic.account”类型
EN

Stack Overflow用户
提问于 2015-07-16 09:12:59
回答 1查看 2.6K关注 0票数 3

我正在把一个account.analytic.account字段从销售订单转到发票。目的是在确认销售订单时通过现场。

代码语言:javascript
复制
def _prepare_invoice(self, cr, uid, order, lines, context=None):
    """Prepare the dict of values to create the new invoice for a
       sales order. This method may be overridden to implement custom
       invoice generation (making sure to call super() to establish
       a clean extension chain).

       :param browse_record order: sale.order record to invoice
       :param list(int) line: list of invoice line IDs that must be
                              attached to the invoice
       :return: dict of value to create() the invoice
    """
    if context is None:
        context = {}
    journal_ids = self.pool.get('account.journal').search(cr, uid,
        [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
        limit=1)
    if not journal_ids:
        raise osv.except_osv(_('Error!'),
            _('Please define sales journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
    invoice_vals = {
        'name': order.client_order_ref or '',
        'origin': order.name,
        'type': 'out_invoice',
        'reference': order.client_order_ref or order.name,
        'account_id': order.partner_invoice_id.property_account_receivable.id,
        'partner_id': order.partner_invoice_id.id,
        'journal_id': journal_ids[0],
        'invoice_line': [(6, 0, lines)],
        'currency_id': order.pricelist_id.currency_id.id,
        'comment': order.note,
        'payment_term': order.payment_term and order.payment_term.id or False,
        'fiscal_position': order.fiscal_position.id or order.partner_invoice_id.property_account_position.id,
        'date_invoice': context.get('date_invoice', False),
        'company_id': order.company_id.id,
        'user_id': order.user_id and order.user_id.id or False,
        'section_id' : order.section_id.id,
        'order_field':order.order
    }

    # Care for deprecated _inv_get() hook - FIXME: to be removed after 6.1
    invoice_vals.update(self._inv_get(cr, uid, order, context=context))
    return invoice_vals

我正在重写sale.py中的方法'order_field‘是我在account.invoice中的字段,model.and顺序在sale.order中是相同的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-16 09:32:35

当您得到无法适应类型'x‘错误时,通常使用的是一个对象x,而不是它的ID (这实际上是必需的)。

因此,如果在order_field中出现此错误,则应该编写'order_field': order.order.id

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31450046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档