2

助けてください..どうしたの

 def _amount_all(self, cr, uid, ids, name, args, context=None):
    res = {}
    for invoice in self.browse(cr, uid, ids, context=context):
        res[invoice.id] = {
            'amount_untaxed': 0.0,
            'amount_tax': 0.0,
            'amount_total': 0.0
        }
        for line in invoice.invoice_line:

            res[invoice.id]['amount_untaxed'] += line.price_subtotal
        for line in invoice.tax_line:
            res[invoice.id]['amount_tax'] += line.amount 
        res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
        cr.execute('select payment from sale_order where name = %s',(invoice.origin,))
        ads = cr.fetchone()
        pay = ads and ads[0] or None
        if pay == 'deposit':
            if invoice.partner_id.avail < 0:
                raise osv.except_osv(_('Invalid action !'), _('Deposit must be recharged')
                    if invoice.amount_total != res[invoice.id]['amount_total']:
                        temp = invoice.partner_id.depot - res[invoice.id]['amount_total']
                        cr.execute('update res_partner set depot=%s where id = %s', (temp, invoice.partner_id.id,))
    return res

彼がデポジットを使用して支払い、ゼロ未満の場合は利用可能である場合、そうでない場合はデポジットの削減が行われるという条件を確認しました。これは正しいと思いますが、実行するとこのように表示されます

invoice.amount_total != res[invoice.id]['amount_total']: SyntaxError : 無効な構文

4

1 に答える 1

2

行の後に2タブ(8スペース)を指定したのはなぜですか?raise osv.except_osv() コードは次のようになります

def _amount_all(self, cr, uid, ids, name, args, context=None):
    res = {}
    for invoice in self.browse(cr, uid, ids, context=context):
        res[invoice.id] = {
            'amount_untaxed': 0.0,
            'amount_tax': 0.0,
            'amount_total': 0.0
        }
        for line in invoice.invoice_line:

            res[invoice.id]['amount_untaxed'] += line.price_subtotal
        for line in invoice.tax_line:
            res[invoice.id]['amount_tax'] += line.amount 
        res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
        cr.execute('select payment from sale_order where name = %s',(invoice.origin,))
        ads = cr.fetchone()
        pay = ads and ads[0] or None
        if pay == 'deposit':
            if invoice.partner_id.avail < 0:
                raise osv.except_osv(_('Invalid action !'), _('Deposit must be recharged')
            if invoice.amount_total != res[invoice.id]['amount_total']:
                temp = invoice.partner_id.depot - res[invoice.id]['amount_total']
                cr.execute('update res_partner set depot=%s where id = %s', (temp, invoice.partner_id.id,))
    return res
于 2012-08-25T08:12:26.763 に答える