Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

AttributeError: 'browse_record_list' object has no attribute 'type' for a custom module

By
Odoo
on 10/1/14, 6:32 AM 1,899 views

Hi when I click on this button(function ),it raised an error ,need a help

def cash_payment_popup(self, cr, uid, ids, context=None):
        if not ids: return []
  #      num=self.browse(cr,uid,ids,context=context)
        journal_pool = self.browse(cr,uid,ids,context=context)
        #journal = journal_pool[0]['journal_id']
        dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid,'customer_payments', 'customer_payment_wizard_form_view')
       # journal_pool = self.pool.get('account.journal')
     #   journal = journal_pool.browse(cr, uid,num, context=context)
        inv = self.browse(cr, uid, ids[0], context=context)
        if journal_pool.type == 'cash':       ###How to check here its a journal_id value is cash/bank
            return {
                'name':_("Cash Payment Order"),
                'view_mode': 'form',
                'view_id': view_id,
                'view_type': 'form',
                'res_model': 'customer.payment.wizard',
                'type': 'ir.actions.act_window',
                'nodestroy': True,
                'target': 'new',
                'domain': '[]',
                'context': {
                    'default_supplier_name': self.pool.get('res.partner')._find_accounting_partner(inv.partner_id).id,
                    'default_amount': inv.amount_total,
                    'default_date': inv.date,
                 #   'default_currency': self.pool.get('account.invoice')._get_currency(inv.currency_id).id,
                 #   'default_company_name': self.pool.get('res.partner')._find_accounting_partner(inv.company_id).id,
                    'default_cash_payment_order_no':inv.reference,
                    'default_document': inv.document,
                    'default_date_location': inv.date_location,
                    'default_purpose': inv.purpose,
                    'default_enclosure': inv.enclosure,
                    'default_amount_words':inv.amount_in_text,
               #     'default_accounts':inv.ren_period,
                            }
            }
        else:
            raise osv.except_osv(_("Alert !!"),_("You Cannot Withdraw Deposit Before 3 Months"))

1
Narayanamurthy
On 10/1/14, 7:39 AM

from this journal_pool = self.browse(cr,uid,ids,context=context), "journal_pool" is of List [] type,

the error is from u cannot get data from list of browse record if u use . (dot),

 

use "For Loop" for  journal_pool in self.browse(cr,uid,ids,context=context),

You can get journal = journal_pool.journal_id

type=journal_pool.type

def cash_payment_popup(self, cr, uid, ids, context=None):
        if not ids: return []
  #      num=self.browse(cr,uid,ids,context=context)
        for journal_pool in self.browse(cr,uid,ids,context=context):
            #journal = journal_pool[0]['journal_id']
             dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr,

             uid,'customer_payments','customer_payment_wizard_form_view')
          # journal_pool = self.pool.get('account.journal')
     #      journal = journal_pool.browse(cr, uid,num, context=context)
            inv = self.browse(cr, uid, ids[0], context=context)
            if journal_pool.type == 'cash':       ###How to check here its a journal_id value is cash/bank
                 return {
                'name':_("Cash Payment Order"),
                'view_mode': 'form',
                'view_id': view_id,
                'view_type': 'form',
                'res_model': 'customer.payment.wizard',
                'type': 'ir.actions.act_window',
                'nodestroy': True,
                'target': 'new',
                'domain': '[]',
                'context': {
                    'default_supplier_name':self.pool.get('res.partner')._find_accounting_partner(inv.partner_id).id,
                    'default_amount': inv.amount_total,
                    'default_date': inv.date,
                 #   'default_currency': self.pool.get('account.invoice')._get_currency(inv.currency_id).id,
                 #   'default_company_name': 

                  #    self.pool.get('res.partner')._find_accounting_partner(inv.company_id).id,
                    'default_cash_payment_order_no':inv.reference,
                    'default_document': inv.document,
                    'default_date_location': inv.date_location,
                    'default_purpose': inv.purpose,
                    'default_enclosure': inv.enclosure,
                    'default_amount_words':inv.amount_in_text,
               #     'default_accounts':inv.ren_period,
                            }
                    }
            else:
                raise osv.except_osv(_("Alert !!"),_("You Cannot Withdraw Deposit Before 3 Months"))

0
Artur Bertram
On 10/1/14, 7:29 AM

Replace this code

if journal_pool.type == 'cash':       ###How to check here its a journal_id value is cash/bank

with this

if journal.type == 'cash':       ###How to check here its a journal_id value is cash/bank

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/1/14, 6:32 AM
Seen: 1899 times
Last updated: 3/16/15, 8:10 AM