【问题标题】:Using "if" to change "state" on openerp在 openerp 上使用“if”改变“状态”
【发布时间】:2013-06-03 19:17:18
【问题描述】:

我需要使用其付款方式更改发票的状态。

    def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):
    result = {}
    invoice_obj = self.pool.get('account.move.line')
    for rec in self.browse(cr, uid, ids, context):
        result[rec.id] = (0, 0)
        invoice_id = invoice_obj.search(cr, uid, [(
            'move_id', '=', rec.move_id.id)], context=context)
        if invoice_id:
            inv = invoice_obj.browse(cr, uid, invoice_id[0], context)
            if inv.payment_type:
                result[rec.id] = (inv.payment_type.id, self.pool.get(
                    'payment.type').browse(cr, uid, inv.payment_type.id, context).name)
        else:
            result[rec.id] = (0, 0)
    return result
    if result != '1':
        return self.write(cr, uid, ids, {'state_cheque': 'usado'})
    else:
        return self.write(cr, uid, ids, {'state_cheque': 'caixa'})

我需要在发票结算期间创建“支票”时获取付款类型,因此我可以将其设置为 Caixa(如果是支票)或 Usado(如果不是)。我不知道所有的名字是否正确,因为我是从这里的一个人那里复制的,他说会的(如果我让它通过,我会感到羞耻)。

支票,就像任何付款都保存在日记帐中一样,支票保存在带有其名称(ChequeJournal)的特定日记帐中,如果我可以使用它来创建默认状态,那就更好了。

我尝试过的每一种方法都失败了。最近我发现付款类型保存为 int 而不是 char 或 string,但更改它仍然没有结果。

我无法使用 self.write ,因为我正在编辑 account_move_line.py,OpenERP 找不到我要添加状态的内容。因此,我需要获取发票 ID 才能更改该状态。新的问题出现了?

【问题讨论】:

    标签: python openerp erp


    【解决方案1】:

    一旦调用了return 语句,函数就会立即退出,因此您的最后4 行不会被执行。 (或者可能是格式错误?)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多