Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Qweb report( key error). Odoo v11

Odoberať

Get notified when there's activity on this post

This question has been flagged
qwebreportpurchase_orderserpentodooV11
3 Replies
9276 Zobrazenia
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
Zrušiť
Sehrish

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

Avatar
Kabeer KB
Best Answer

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
Zrušiť
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
Best Answer

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
Zrušiť
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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
How customize default report_purchaseorder.xml qweb report in odoo v8.0
qweb report purchase_order odooV8
Avatar
0
mar 15
4616
odoo 16 report target new page scss
qweb report
Avatar
Avatar
1
apr 25
2381
Missing external identifier on new external layout template Solved
qweb report
Avatar
Avatar
2
mar 25
3112
Translate month name in t-esc Qweb report Solved
qweb report
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov 24
8411
QWeb Report Shows Different When Edit And Print Review Solved
qweb report
Avatar
Avatar
1
mar 24
3148
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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