Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4742 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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

Related Posts Odpovědi Zobrazení Aktivita
1
lis 24
1690
0
srp 24
1677
2
srp 24
245
0
srp 24
12
4
bře 24
3532