Odoo Help


self.pool.get from other object and browse the value

on 2/17/14, 4:18 AM 5,887 views

In the Sale Order Line table, I want to add columns Quantity on Hand from the Inventory tab in Product view afer the columns Product. To achieve this, I try to create a custom module with self.pool.get and browse method. The problem right now is it shows the error of invalid XML for view architecture. Please help me.

Here is my code


from openerp.osv import fields, osv
from openerp import netsvc, tools, pooler
import openerp.addons.decimal_precision as dp

class qty_available_add(osv.osv):

    _inherit = "sale.order"

    _columns = {
        'qty_available': fields.float('Qty Disponible',digits_compute= dp.get_precision('Product UoS')),

    def get_qty(self, cr, uid, id, product, context=None):
        wg_qty_avail = self.pool.get('product.product').browse(cr,uid,product,context=None).qty_available
        result['qty_available'] = wg_qty_avail



<?xml version="1.0" encoding="utf-8"?>
    <record model="ir.ui.view" id="qty_available">
        <field name="name">sale.order.form</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form" />
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/form/group/group/field[@name='product_id']" position="after">
                <field name="qty_available" />

Thank you very much

On 2/18/14, 6:06 PM

I also think your py file is incorrect. You would need to create a fields.function field in stead of the fields.float.

Regards, André Schenkels

Krupesh Laiya
On 2/18/14, 6:24 AM

Your xpath is wrong update it like as given below:

<record id="view_sale_textline_tree" model="ir.ui.view">
    <field name="name">sale.order.form</field>
    <field name="model">sale.order</field>
    <field name="type">form</field>
    <field name="priority" eval="8"/>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='product_id']" position="after">
            <field name="CUSTOM FIELD NAME" />
        <xpath expr="//tree/field[@name='product_id']" position="after">
            <field name="CUSTOM FIELD NAME"/>

Note: and inherit sale.order.line instead of sale.order

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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: 2/17/14, 4:18 AM
Seen: 5887 times
Last updated: 3/16/15, 8:10 AM