This question has been flagged
3 Replies
4132 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.

Avatar
Discard
Author

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

Best Answer

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. 

Avatar
Discard
Author Best Answer

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.

Avatar
Discard
Best Answer

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.

 

Avatar
Discard