Hi all,
I'm trying to modify product.template from within a module. Specifically I am looking to make the Internal Reference (default_code) field sortable. I've managed to build up a module that modifies an esiting form, but I can't seem to manage to get the changes to product.template to work.
My __init__.py looks like this:
# -*- coding: utf-8 -*- from . import addIntRef
# -*- coding: utf-8 -*- from openerp.osv import fields, osv class product_template2(osv.osv): _name = 'product.template' _inherit = 'product.template' _columns = { 'default_code': fields.related('product_variant_ids', 'default_code', type='char', string='Internal Reference'), } product_template2()
My __openerp__.py looks like this:
# -*- coding: utf-8 -*- { 'name': "Add Internal Reference", 'summary': """Add Internal Reference field to standard forms.""", 'description': """ Adds the default internal reference field to forms so it is visible. This is used for internal part numbers so access to this is important. """, 'author': "Peck Tech Consulting Ltd.", 'website': "http://www.pecktech.ca", 'category': 'Tool', 'version': '0.1', 'depends': ['product'], 'data': ['addIntRef.xml'], 'demo': [], }
<?xml version="1.0"?> <openerp> <data> <record id="product.product_template_tree_view2" model="ir.ui.view"> <field name="name">product.template.product.tree2</field> <field name="model">product.template</field> <field name="inherit_id" ref="product.product_template_tree_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='name']" position="before"> <field name="default_code"/> </xpath> </field> </record> </data> </openerp>
I've tried marking this field as sortable from the web interface, it does not allow me to save those changes. Plus that would be non-upgrade freindly... I think I am close, but just need some help getting over this last hump.
Oh and if it makes a difference I have Odoo 8 running on a Ubuntu server and I am accessing it from my local Windows 10 box with Chrome browser. I just updated Odoo this AM so should be on latest and greatest...
Any help / hints here would be much appreciated! Thanks!!!
Thanks for the feedback Groover. What I am trying to achieve here is to have the product.template.product.tree view sortable on Internal Reference (default_code) field that I've added. As it is now, I can click on the Name, Internal Category, Product Type and Status and have the records sorted on those. But the newly added field in the tree view is not sortable. I though it was to do with the product.template default_code value not being set to searchable, but looking at some of those other fields it looks like those are not either... So this leads me to believe that I need to change an attribute on that field that I've added to make that work. I still don't know why my product.template changes are not working, but that's secondary now... By the way I did try your suggestion but that did not work. Thinking it has more to do with my implementation though... Time for some more digging! If I look at the product.template (which is ithe source for this view, I find that those fields