Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
4779 Prikazi

Hi,

I try to override the model crm.lead.report

But my field doesn't appear in the database

This is my python code


from openerp.osv import orm, fields

class account_invoice_report(orm.Model):
    _inherit = 'crm.lead.report'
   

    _columns = {
        'other_turnover': fields.float('Other turnover'),
    }

 

Anyone have an idea?

Avatar
Opusti
Best Answer

crm_lead_report is a VIEW defines a view of a query.  If you want to shows 'other_turnover' in the crm_lead_report view then add the column in sql query in the python file and define in xml file.

Refer:  Default  CRM, Sale, Purchase, Account Module Report File.

Postgresql View Document:-  http://www.postgresql.org/docs/9.2/static/sql-createview.html

Openerp:-  http://sajjadhossain.com/2013/06/30/openerp-7-creating-report-using-sql-query/

Avatar
Opusti
Avtor Best Answer

It's possible to add the column in python code. I tried this but it's not ok

    def init(self, cr):
        tools.drop_view_if_exists(cr, 'crm_lead_report')
        cr.execute("""
            CREATE OR REPLACE VIEW crm_lead_report AS (
                SELECT

                    c.other_turnover,

                FROM
                    crm_lead c
                WHERE c.active = 'true'
            )""")

Avatar
Opusti

In custom module copy and paste the original CRM report query and add your extra field c.other_turnover.

Related Posts Odgovori Prikazi Aktivnost
1
nov. 24
1781
0
avg. 24
1716
2
avg. 24
245
0
avg. 24
12
4
mar. 24
3660