Odoo Help


Purchase Order, add Quantity to tree view

on 7/12/13, 2:02 AM 2,428 views

Hi there,

I am trying to add a new column into the tree view, but this is a existing element, rather than a new element. Inside the Purchase order-->order lines, there is element product_qty. I need to add this element into the purchase order tree view.

As purchase.order.line is called by purchase.order, I tried to inherit the class, and related a new column to the product_qty in my inherited purchase.order class. But it did not work.

I am attaching the related codes here, your kind help is much appreciated!

from openerp.osv import fields, osv

class purchase_order(osv.osv):




    <record model="ir.ui.view" id="m_purchase_quotation_tree_view">
        <field name="name">Purchase Quotation Inherited List View</field>
        <field name="model">purchase.order</field> 
        <field name="inherit_id" ref="purchase.purchase_order_tree" /> 
            <field name="arch" type="xml">

                    <field name="date_order" position="after">
                        <field name="tree_quantity" />


Error msg:

Server Traceback (most recent call last): File "C:\erpDev\workspace\openerp-7.0\openerp\addons\web\session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "C:\erpDev\workspace\openerp-7.0\openerp\netsvc.py", line 292, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "C:\erpDev\workspace\openerp-7.0\openerp\service\web_services.py", line 626, in dispatch res = fn(db, uid, params) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\osv.py", line 131, in wrapper return f(self, dbname, args, *kwargs) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\orm.py", line 3604, in read result = self._read_flat(cr, user, select, fields, context, load) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\orm.py", line 3724, in _read_flat res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\fields.py", line 1131, in get result = self._fnct(obj, cr, uid, ids, name, self._arg, context) File "C:\erpDev\workspace\openerp-7.0\openerp\osv\fields.py", line 1197, in _fnct_read value = value[field] or False File "C:\erpDev\workspace\openerp-7.0\openerp\osv\orm.py", line 425, in __getitem__ if result_line[field_name]: KeyError: 'product_uom'


Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 7/12/13, 2:12 AM

A purchase order is one or many purchase order lines, each with a quantity.

If there is more than one purchase order line, which quantity do you want in the treeview?

I think you need a new field that calculates what you want, since quantity isn't related to purchase order, but to purchase order line.

hi ray, thank you very much for pointing out my mistake! because in my case i have one type of products in each of purchase order, product quantity makes sense. I think I will need a new filed to calculate the total quantity then. Again, thx a lot for the help!

on 7/12/13, 3:32 AM

Hi Ray, as I'm pretty new to Openerp and python..i was reading the codes and tried to figure out how to calculate the quantity. I tried to refer to the amount_untaxed/amount_taxed, but it seems that these fields involve with complex functions with accounting etc. I am wondering whether you could advise the approach that how I can sort out the total quantity in the order_lines, then present it in the Order_Line page on Purchase Order form...thx a lot!

on 7/12/13, 7:05 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 7/12/13, 2:02 AM
Seen: 2428 times
Last updated: 3/16/15, 8:10 AM