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

Qweb report( key error). Odoo v11

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
qwebreportpurchase_orderserpentodooV11
3 Respostas
9294 Visualizações
Avatar
Abdullah

I want to see notes field of the purchase order in the report too. I have added the field by inheritance once and also by changing the purchase module code but i am getting an error with report . All other fields are working and fetching data. It is basically a purchase comparison report. Please help and tell me what i am doing wrong and what should i do.

here is my code for notes field


<t t-foreach="data" t-as="question">
<tr class="row2">
<td class="table_td">
<span t-esc="i" />
</td>
<td style="border:solid #d1cfcf 1px;padding:5px;line-height: 13px;">
<span t-esc="question['product_name']" />
</td>
<td class="table_td">
<span t-esc="question['uom']" />
</td>
<td class="table_td">
<span t-esc="question['qty']" />
</td>
<t t-foreach="data" t-as="question">
<t t-foreach="question['amt']" t-as="amount">
<td class="table_td">
<span t-esc="amount['price']" />
</td>
<td class="table_td">
<span t-esc="amount['total_amount']" />
</td>
<td class="table_td">
<span t-esc="amount['notes']" />
</td>

</t>
everything is working except notes. The error i am getting is
error 

'notes'
Traceback (most recent call last):
  File "C:\odoo\odoo\odoo\addons\base\ir\ir_qweb\qweb.py", line 343, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_1059_1060
  File "<template>", line 2, in body_call_content_1059
  File "<template>", line 74, in foreach_1058
  File "<template>", line 88, in foreach_1057
  File "<template>", line 89, in foreach_1056
KeyError: 'notes'

Error to render compiling AST
KeyError: 'notes'
Template: 1059
Path: /templates/t/t/div/div/div/div[4]/table/thead/tr[2]/t[3]/tr/t/t[1]/td[3]/span
Node: <span t-esc="amount['notes']"/>
0
Avatar
Cancelar
Sehrish

Hope this will helps, https://goo.gl/8HgnCF

Avatar
Kabeer KB
Melhor resposta

The error message saying, there is no key argument 'notes' in the dictinory 'amount'. Make sure you added the key 'notes' in the dictionary in python funciton. 

Note: Please post complete source code including python code. 

Hope this will help you.

0
Avatar
Cancelar
Abdullah
Autor

Thanks for replying. Can you please give me an example of how to add notes in the dictionary?

Kabeer KB

Please post complete code of the report both xml and python.

Abdullah
Autor

its an addon which i am changing named as "Purchase comparison chart".

main.py includes

from odoo import http

from odoo.http import request

class ValidateBid(http.Controller):

@http.route(['/purchase_comparison_chart/purchase_comparison/<model("purchase.requisition"):purchase_requisition_id>'], type='http', auth='public', website=True)

def purchase_comparison(self, purchase_requisition_id, **post):

supplier_ids = []; product_ids=[]; values = []; amt = []; number = []; supplier_id = []

counts = 1

for record in request.env['purchase.order'].sudo().search([('requisition_id', '=', purchase_requisition_id.id)]):

# Append supplier

supplier_ids.append({'supplier_id':record.partner_id.id, 'sname':record.partner_id.name})

supplier_id.append(record.partner_id.id)

number.append(counts)

# Append Products and quantity

counts +=1

for line in record.order_line:

if values:

if line.product_id.id not in product_ids:

product_ids.append(line.product_id.id)

values.append({'product_id':line.product_id.id, 'product_name':line.product_id.name, 'price':line.price_unit, 'uom':line.product_id.uom_po_id.name, 'qty':line.product_qty, 'name':line.name})

else:

product_ids.append(line.product_id.id)

values.append({'product_id':line.product_id.id,'product_name':line.product_id.name, 'price':line.price_unit, 'uom':line.product_id.uom_po_id.name,'qty':line.product_qty, 'name':line.name})

count = 0; supplier_amount_total = []; no_of_col = 2 ; even_number = [] ; odd_number = []

# Append amount based on the products and supplier

for separate_values in values:

for suppliers in supplier_ids:

for record in request.env['purchase.order'].sudo().search([('requisition_id', '=', purchase_requisition_id.id),('partner_id', '=',suppliers['supplier_id'])]):

for po_line in request.env['purchase.order.line'].search([('order_id', '=', record.id),('product_id', '=',separate_values['product_id'])]):

amt.append({'total_amount':(po_line.product_qty * po_line.price_unit), 'price':po_line.price_unit, 'name': po_line.name})

values[count]['amt'] = amt

count +=1

amt = []

# Generate number to create rows and columns

total_supplier = len(number)

if total_supplier >= 2:

increase_by_supplier = total_supplier * no_of_col

else:

increase_by_supplier = no_of_col

if total_supplier > 1:

total_no = range(1, increase_by_supplier + 1)

supplier_amount_total_1 = list(range(1, increase_by_supplier + 1))

else:

total_no = range(1, increase_by_supplier)

supplier_amount_total_1 = list(range(1, increase_by_supplier))

for c_number in total_no:

if c_number%2 ==0:

even_number.append(c_number)

else:

odd_number.append(c_number)

for record in request.env['purchase.order'].sudo().search([('requisition_id', '=', purchase_requisition_id.id)]):

supplier_amount_total.append(record.amount_total)

# Update the amount in even number position

tcount = 1

for i in even_number:

supplier_amount_total_1[i-1] = supplier_amount_total[tcount-1]

tcount +=1

# Update the supplier id in odd number position

scount = 1

for odd_no in odd_number:

for total in total_no:

if total == odd_no:

supplier_amount_total_1[odd_no-1] = supplier_id[scount-1]

scount +=1

return request.render('purchase_comparison_chart.purchase_comparison', {'data':values, 'supplier':supplier_ids,'purchase_requisition_id':purchase_requisition_id,

'number':number, 'to_no':total_no, 'column_no':even_number, 'supplier_amount_total':supplier_amount_total,

'supplier_amount_total_1':supplier_amount_total_1, 'odd_number':odd_number})

---------------------

python file includes

class PurchaseOrder(models.Model):

_inherit = 'purchase.order.line'

notes = fields.Char(string='Notes')

@api.model

def create(self,vals):

if vals.get('requisition_id'):

purchase_ids = self.env['purchase.order'].search([('requisition_id','=',vals.get('requisition_id'))])

for po_id in purchase_ids:

if vals.get('partner_id') == po_id.partner_id.id:

raise UserError(_('RFQ is available for this purchase agreement for the same vendor'))

return super(PurchaseOrder, self).create(vals)

@api.multi

def write(self, vals):

if vals.get('partner_id') or vals.get('requisition_id'):

purchase_ids = self.env['purchase.order'].search([('requisition_id', '=', vals.get('requisition_id'))])

for po_id in purchase_ids:

if vals.get('partner_id') == po_id.partner_id.id:

raise UserError(_('RFQ is available for this purchase agreement for the same vendor'))

return super(PurchaseOrder, self).write(vals)

class PurchaseRequisition(models.Model):

_inherit = 'purchase.requisition'

print_url = fields.Char("Print link", compute="_compute_url")

def _compute_url(self):

""" Computes a public URL for the purchase comparison """

base_url = '/' if self.env.context.get('relative_url') else self.env['ir.config_parameter'].get_param('web.base.url')

for record in self:

record.print_url = urljoin(base_url, "purchase_comparison_chart/purchase_comparison/%s" % (slugify(record)))

@api.multi

def show_terms_condition(self, value1, value2):

if value1 and value2:

va = str(value1).strip()

terms_condition = self.env['purchase.order'].search([('requisition_id', '=',self.id), ('partner_id', '=', int(va))])

if terms_condition:

return terms_condition.notes

else:

return None

@api.multi

def purchase_comparison(self):

""" Open the website page with the purchase comparison form """

self.ensure_one()

if self.order_count == 0:

raise UserError(_('No RFQ available for the Purchase agreement. Please add some RFQ to compare'))

return {

'type': 'ir.actions.act_url',

'name': "Purchase Comparison Chart",

'target': 'self',

'url': self.with_context(relative_url=True).print_url

}

@api.multi

def print_xl(self):

purchase_orders = self.env['purchase.order'].search([('requisition_id', '=', self.id)])

for rec in purchase_orders:

for line in rec.order_line:

price_unit = line.price_unit

price_subtotal = line.price_subtotal

style2 = xlwt.easyxf('font: name Times New Roman bold on;align: horiz center;', num_format_str='#,##0')

style0 = xlwt.easyxf('font: name Times New Roman bold on;align: horiz right;', num_format_str='#,##0.00')

style1 = xlwt.easyxf('font: name Times New Roman, bold on,height 250; pattern: pattern solid, fore_colour black;', num_format_str='#,##0.00')

workbook = xlwt.Workbook()

sheet = workbook.add_sheet(self.name)

sheet.write_merge(2, 2, 4, 6, 'PURCHASE COMPARISON', style1)

sheet.write(3, 7,'PRC No', style0)

sheet.write(3, 8, self.name, style0)

sheet.write(4, 7, 'Date',style0)

sheet.write(4, 8, self.ordering_date,style0)

sheet.write_merge(6, 6, 0, 1, 'PRODUCT DETAILS', style1)

sheet.write(8, 3, 'S NO',style1)

sheet.write_merge(8, 8, 4, 5, 'MATERIAL',style1)

sheet.write_merge(8, 8, 6, 7, 'UOM',style1)

sheet.write(8, 8, 'QTY',style1)

n = 9; i = 1

for line in self.line_ids:

sheet.write(n, 3, i, style2)

sheet.write_merge(n, n,4,5, line.product_id.name, style0)

sheet.write_merge(n, n,6,7, line.product_uom_id.name, style0)

sheet.write(n,8, line.product_qty, style0)

n +=1; i += 1

ams_time = datetime.now()

date = ams_time.strftime('%m-%d-%Y %H.%M.%S')

filename = ('Report' + '-' + date + '.xls')

workbook.save(filename)

fp = open(filename, "rb")

file_data = fp.read()

attach_id = self.env['report.wizard'].create({'attachment': base64.encodestring(file_data),

'attach_name': 'Report.xls'})

fp.close()

return {

'type': 'ir.actions.act_window',

'name': ('Report'),

'res_model': 'report.wizard',

'res_id': attach_id.id,

'view_type': 'form',

'view_mode': 'form',

'target': 'new',

}

class PaymentWizard(models.TransientModel):

_name = 'report.wizard'

_description = 'Report Details'

attachment = fields.Binary('Excel Report File', nodrop=True, readonly=True)

attach_name = fields.Char('Attachment Name')

---------------------

now i am trying to take the 'name' field in purchase.order.line to use as notes and i am trying to show it on report and as you said i was trying to add it in dictionary too but no success

Abdullah
Autor

ok now it is working i am getting the notes field in the report just had to do some styling now. Thank you soo much you helped alot

Avatar
Anusha
Melhor resposta

Hi,  

 I dint understand the exact requirement from your code.By default the Notes we add in the purchase order will be automatically come in the purchase order when we print it. Even though in your code make sure that in each records of question['amt']  there is a field 'notes'.

0
Avatar
Cancelar
Abdullah
Autor

its a purchase comparison report for the rfqs against each tender. Its a customer requirement that he wants to add a note for each vendor rfq and he wants to print that too.

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
How customize default report_purchaseorder.xml qweb report in odoo v8.0
qweb report purchase_order odooV8
Avatar
0
mar. 15
4622
odoo 16 report target new page scss
qweb report
Avatar
Avatar
1
abr. 25
2383
Missing external identifier on new external layout template Resolvido
qweb report
Avatar
Avatar
2
mar. 25
3129
Translate month name in t-esc Qweb report Resolvido
qweb report
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov. 24
8413
QWeb Report Shows Different When Edit And Print Review Resolvido
qweb report
Avatar
Avatar
1
mar. 24
3153
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