Odoo Help

Welcome!

This community 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.

0

How to limit the records according to the domain in the reporting?

By
Sage
on 2/26/13, 1:58 AM 1,515 views

Hi Team,

In Openerp report object, such as "crm.lead.report", the generation of the view is from a sql query:

 cr.execute("""
        CREATE OR REPLACE VIEW crm_lead_report AS (
            SELECT
                id,

                to_char(c.date_deadline, 'YYYY') as deadline_year,
                to_char(c.date_deadline, 'MM') as deadline_month,
                to_char(c.date_deadline, 'YYYY-MM-DD') as deadline_day,

                to_char(c.create_date, 'YYYY') as creation_year,
                to_char(c.create_date, 'MM') as creation_month,
                to_char(c.create_date, 'YYYY-MM-DD') as creation_day,

                to_char(c.date_open, 'YYYY-MM-DD') as opening_date,
                to_char(c.date_closed, 'YYYY-mm-dd') as date_closed,

                c.state,
                c.user_id,
                c.probability,
                c.stage_id,
                c.type,
                c.company_id,
                c.priority,
                c.section_id,
                c.channel_id,
                c.type_id,
                c.partner_id,
                c.country_id,
                c.planned_revenue,
                c.planned_revenue*(c.probability/100) as probable_revenue,
                1 as nbr,
                date_trunc('day',c.create_date) as create_date,
                extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as  delay_close,
                abs(extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24)) as  delay_expected,
                extract('epoch' from (c.date_open-c.create_date))/(3600*24) as  delay_open
            FROM
                crm_lead c
            WHERE c.active = 'true'
        )""")

As a result, all the domain restriction cannot take effect here. And every user can view all company's data within the report no matter these companies have any connection. For example, user A is from Company A, but he can see company B,C,Ds' records in the report. Is there any workaround to fix the issue?

Regards Sage

1

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 2/26/13, 4:59 AM

You can use domains also in osv.Memory objects without any restriction.

You can define a new access rule for "crm.lead.report" with domain

['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]

This should limit the access to data related to the users company.

Thanks. It works.

Sage
on 2/26/13, 9:05 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/26/13, 1:58 AM
Seen: 1515 times
Last updated: 3/16/15, 8:10 AM