Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

When i try to print a custom report i get a AttributeError: object has no attribute '_ids'

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
error
1 Responder
9359 Visualizações
Avatar
Erhuvwu Akpobaro

I have a custom report , with a print button(red) , however when i click the print button i get this error :

           File "/opt/odoo/community/addons/camden-market/cm_sales_receipt/cm_sales_receipt.py", line 89, in print_receipt assert len(self) == 1, 'This option should only be used for a single id at a time.' File "/opt/odoo/odoo/openerp/models.py", line 5332, in __len__ return len(self._ids) AttributeError: 'cm.sales.receipt' object has no attribute '_ids'

Also i have another normal print button which when i click print my report but it is just an empty file.

 

 

My class :

class cm_sales_receipt(osv.osv):
    _name = "cm.sales.receipt"
    _description = "Camden Market Sales Receipt"
    _auto = False
    _columns = {
        'paymentref':fields.char('PaymentRef'),
        'date':fields.date('Date'),
        'receipt_number':fields.char('Receipt Number'),
        'customer':fields.char('Customer',size=128),
        'unit':fields.char('Unit',size=128),
        'company':fields.char('Name',size=128,required=True),
        'invoicing_company':fields.char('Invoicing Company', size=128,required=True),
        'street':fields.char('Street',size=128,required=True),
        'street2':fields.char('Street2',size=128,required=True),
        'zip':fields.char('Zip',size=10,required=True),
        'state':fields.char('State',size=128,required=True),
        'city':fields.char('City',size=128,required=True),
        'email':fields.char('Email',size=128),
        'fax':fields.integer('Fax'),
        'phone':fields.integer('State'),
        'paid_amount':fields.float('Paid_Amount'),

    }

Here below is the code used  to print the report (note function is indented so part of above class :

 def print_receipt(self, cr, uid, ids, context=None):
        """
        This function prints the Property Rental Sales receipt
        """
        assert len(self) == 1, 'This option should only be used for a single id at a time.'
        #self.sent = True
        return self.pool['report'].get_action(cr, uid, ids, 'cm_sales_receipt.report_salesreceipt', context=context)

 

extract from view which has print button (note: print button displays correctly in module:

 <!-- Property Rental Sales Receipt Form View -->
        <record model="ir.ui.view" id="view_cm_sales_receipt_form">
            <field name="name">cm.sales.receipt.form</field>
            <field name="model">cm.sales.receipt</field>
            <field name="arch" type="xml">
                <form string=" Sales Receipt" version="8.0">
                <header>
                    <button name="print_receipt" string="Print Receipt" type="object" class="oe_highlight" groups="base.group_user"/>
                </header>
                                <sheet>
                                <group>
                                        <group>
                                               <field name="invoicing_company"/>
                           <field name="customer"/>
                                               <field name="paymentref"/>
                           <field name="receipt_number"/>
                           <field name="company"/>
                                               <field name="paid_amount"/>
                                    </group>
                                        </group>
                                        </sheet>
                </form>
            </field>
        </record>

 

 

here is the report xml file :

<openerp>
    <data>
        <report
            string="Sales Rental Receipt"
            id="action_cm_report_sales_receipt"
            model="cm.sales.receipt"
            report_type="qweb-pdf"
            name="cm_sales_receipt.report_cm_salesreceipt"
            file="cm_sales_receipt.report_cm_salesreceipt"
            attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('RCPT'+(object.number or '').replace('/','')+'.pdf')"
        />
    </data>
</openerp

 

 

  • module installs correctly
  • ((custom)print button displays correctly but once clicked i recieve an  error
  • when i click the normal print button once clicked it prints  an empty report.

1) it seems the _ids cannot be found in this case , is there an indication of where in the code is '_ids' is not being passed through .

 

 

0
Avatar
Cancelar
Avatar
Emipro Technologies Pvt. Ltd.
Melhor resposta

Hi,

you have used _auto = False means odoo will not create table of this model.

So, you do not get the id of this model because model is not available.

There may be the possibilities that you have create SQL VIEW into init() method with same name as model. In your case VIEW name is "cm_sales_receipt". Then you have to change at the line  assert len(ids) == 1  instead of assert len(self) == 1 .

I hope you will resolve your issue.

0
Avatar
Cancelar
Erhuvwu Akpobaro
Autor

Thank you the problem is solved , the print button prints a document now , although now its just a white plain document but i guess that is down to the way im calling the data.

Erhuvwu Akpobaro
Autor

I get a error when i try to call the views in my xml : error log: InternalError: current transaction is aborted, commands ignored until end of transaction block model: class cm_sales_receipt(osv.osv): _name = "cm.sales.receipt" _description = "Camden Market Sales Receipt" _auto = False _columns = { 'paymentref':fields.char('PaymentRef'), 'date':fields.date('Date'), 'receipt_number':fields.char('Receipt Number'), 'customer':fields.char('Customer',size=128), 'unit':fields.char('Unit',size=128), 'company':fields.char('Name',size=128,required=True), 'invoicing_company':fields.char('Invoicing Company', size=128,required=True), 'street':fields.char('Street',size=128,required=True), 'street2':fields.char('Street2',size=128,required=True), 'zip':fields.char('Zip',size=10,required=True), 'state':fields.char('State',size=128,required=True), 'city':fields.char('City',size=128,required=True), 'email':fields.char('Email',size=128), 'fax':fields.char('Fax'), 'phone':fields.char('Phone'), 'paid_amount':fields.float('Paid_Amount'), } _order = 'date desc, paid_amount desc' def init(self, cr): tools.sql.drop_view_if_exists(cr, 'cm_sales_receipt') cr.execute(""" create or replace view cm_sales_receipt as ( select min(c.id) as id, a.name as customer, c.number as receipt_number, c.reference as PaymentRef, (select e.name from res_company e where c.company_id = e.id) as company, (select f.name from res_company f where a.invcompany_id = f.id) as invoicing_company, (select s.street from res_partner s where s.id = (select w.partner_id from res_company w where id = a.invcompany_id)) as street, (select s.street2 from res_partner s where s.id = (select w.partner_id from res_company w where id = a.invcompany_id)) as street2, (select s.zip from res_partner s where s.id = (select w.partner_id from res_company w where id = a.invcompany_id)) as zip, (select t.name from res_country_state t where t.id = (select s.state_id from res_partner s where s.id = (select w.partner_id from res_company w where id = a.invcompany_id))) as state, (select s.city from res_partner s where s.id = (select w.partner_id from res_company w where id = a.invcompany_id)) as city, (select s.email from res_partner s where a.invcompany_id = s.id) as email, (select s.fax from res_partner s where a.invcompany_id = s.id) as fax, (select s.phone from res_partner s where a.invcompany_id = s.id) as phone, c.amount as paid_amount, c.date as date from account_analytic_account a, account_voucher c where a.partner_id = c.partner_id group by c.id, a.name, c.number, c.reference, c.amount, c.company_id, a.invcompany_id, c.date ) """) def print_receipt(self, cr, uid, ids, context=None): """ This function prints the Property Rental Sales receipt """ assert len(ids) == 1, 'This option should only be used for a single id at a time.' #self.sent = True context = dict(context or {}, active_ids=ids) return self.pool['report'].get_action(cr, uid, ids, 'cm_sales_receipt.report_salesreceipt', context=context) report view:

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
?"Your country might be blocked by our hosting provider" error when I create new website
error
Avatar
0
nov. 25
592
Payment Page Return Error with Razorpay on Mobile Devices
error
Avatar
0
set. 25
1258
Error after installing "purchase" app in Odoo version 18
error
Avatar
Avatar
1
dez. 24
7017
error schema for TourStep Error
error
Avatar
0
nov. 24
2643
Can't modify manifest version of custom module [Odoo.sh]
error
Avatar
Avatar
Avatar
2
jul. 24
5377
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now