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):
_name='purchase.order'
_inherit='purchase.order'
#_inherits={'purchase.order.line':'product_qty','purchase.order.line':'product_uom'}
_inherits={'purchase.order.line':'product_qty'}
_columns={
'tree_quantity':fields.related('product_qty',string='Quantity',relation='purchase.order.line'),
}
purchase_order()
<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">
<data>
<field name="date_order" position="after">
<field name="tree_quantity" />
</field>
</data>
</field>
</record>
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'