Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Qweb report( key error). Odoo v11

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
qwebreportpurchase_orderserpentodooV11
3 Réponses
9290 Vues
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
Ignorer
Sehrish

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

Avatar
Kabeer KB
Meilleure réponse

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
Ignorer
Abdullah
Auteur

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
Auteur

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
Auteur

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
Meilleure réponse

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
Ignorer
Abdullah
Auteur

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.

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How customize default report_purchaseorder.xml qweb report in odoo v8.0
qweb report purchase_order odooV8
Avatar
0
mars 15
4621
odoo 16 report target new page scss
qweb report
Avatar
Avatar
1
avr. 25
2383
Missing external identifier on new external layout template Résolu
qweb report
Avatar
Avatar
2
mars 25
3129
Translate month name in t-esc Qweb report Résolu
qweb report
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov. 24
8413
QWeb Report Shows Different When Edit And Print Review Résolu
qweb report
Avatar
Avatar
1
mars 24
3152
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

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