Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Qweb report( key error). Odoo v11

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
qwebreportpurchase_orderserpentodooV11
3 Respuestas
9284 Vistas
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
Descartar
Sehrish

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

Avatar
Kabeer KB
Mejor respuesta

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
Descartar
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
Mejor respuesta

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
Descartar
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.

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How customize default report_purchaseorder.xml qweb report in odoo v8.0
qweb report purchase_order odooV8
Avatar
0
mar 15
4620
odoo 16 report target new page scss
qweb report
Avatar
Avatar
1
abr 25
2382
Missing external identifier on new external layout template Resuelto
qweb report
Avatar
Avatar
2
mar 25
3125
Translate month name in t-esc Qweb report Resuelto
qweb report
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov 24
8411
QWeb Report Shows Different When Edit And Print Review Resuelto
qweb report
Avatar
Avatar
1
mar 24
3151
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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