Odoo Help

1

(SOLVED) Can I search on a new field added to an inherited class in OpenERP 6.1?

By
Luis M. Ontalba
on 7/15/14, 12:32 PM 1,372 views

I have created a new class inheriting from acount.move:

from osv import fields, osv

class account_ordering(osv.osv):

_inherit = "account.move"

_name = "account.move"

_columns = {

'fiscalyear_id': fields.related('period_id','fiscalyear_id',type='many2one',relation='account.fiscalyear',string='Fiscal year', store=True, readonly=True)

}

account_ordering()

And I have added a new field and a new search field inheriting from a tree view:

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="view_account_ordering1_tree" model="ir.ui.view">

<field name="name">view.account.ordering1.tree</field>

<field name="model">account.move</field>

<field name="type">tree</field>

<field name="inherit_id" ref="account.view_account_move_filter"/>

<field name="arch" type="xml">

<field name="period_id" position="before">

<field name="fiscalyear_id"/>

</field>

</field>

</record>

<record id="view_account_ordering2_tree" model="ir.ui.view">

<field name="name">view.account.ordering2.tree</field>

<field name="model">account.move</field>

<field name="type">tree</field>

<field name="inherit_id" ref="account.view_move_tree"/>

<field name="arch" type="xml">

<field name="name" position="after">

<field name="fiscalyear_id"/>

</field>

</field>

</record>

</data>

</openerp>

My problem is the added search field is not working. What is wrong?

Thank you in advanced.

I have added  the "fiscalyear_id" field to account.move model, I have added this field to the account move tree view, and I have added a new search field in the search area in this view. All this changes work apparently well, the new field "fiscalyear_id" is in the account move tree view and there is a new search field by fiscalyear_id. The problem is when I try to search account moves selecting a fiscal year in the new field, it doesn´t find any account move. If I add a new search field on a original field of account.move model, it works correctly, but it doesn´t work on an added field like "fiscalyear_id". The code is what I posted first, the python class inheriting from account.move and de xml file inheriting from the account move tree view

Luis M. Ontalba
on 7/19/14, 5:04 AM
1
Mantavya Gajjar (mga)
On 7/15/14, 12:48 PM

When you inherit _inherit = "account.move" you no need to define _name = "account.move". You have to inherit search view of account.move and add field fiscalyear_id to do search on it. 

0
Luis M. Ontalba
On 7/22/14, 4:56 AM

It is SOLVED.

I have removed store=True in the "fiscalyear_id" field and now it is possible to search account move by fiscal year.

Thank you.

0

Hello Luis,

If possible, provide your module, So I can test and let you know the reason.

Remove everything from that module, just keep this problem related code. Upload that module somewhere like dropbox and give me link, So that I can try and solve your problem.

 

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.

Register

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

2 follower(s)

Stats

Asked: 7/15/14, 12:32 PM
Seen: 1372 times
Last updated: 3/16/15, 8:10 AM