Odoo Help

4

Attribute "_auto" in v7

By
saad
on 3/21/13, 4:30 AM 4,366 views

In which case we use the attribute _auto = False in our classes ?
It seems that its use has changed in v7.

I would say that in 99.99% of the cases you won't need it.

Daniel Reis
on 3/21/13, 6:15 AM
8

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4565
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 3/21/13, 4:48 AM

Hello,

_auto is a Predefined field that determines whether a corresponding PostgreSQL table must be generated automatically from the object. Setting _auto to False can be useful in case of OpenERP objects generated from PostgreSQL views. See the “Document” for more details.

Thanks,

Serpent Consulting Services.

1
Shelton
On 3/21/13, 4:40 AM

Please check Object Attributes

1

Gopakumar N G

--Gopakumar N G--
1218
| 5 3 7
Cochin, India
--Gopakumar N G--

Project Lead at Bizweaver Technologies Pvt. Ltd.

Gopakumar N G
On 9/3/13, 5:02 AM

The parameter _auto=False to the OpenERP object is used, so no table corresponding to the _columns dictionary is created automatically. For getting values add a method init(self, cr) that creates a PostgreSQL View matching the fields declared in _columns. And also all fields in the _columns dictionary must have a flag readonly=True.

For example:

class report_crm_case_user(osv.osv):


 _name = "report.crm.case.user"
   _description = "Cases by user and section"
   _auto = False
    _columns = {
   'name': fields.date('Month', readonly=True),
   'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
   'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
   'amount_revenue': fields.float('Est.Revenue', readonly=True),
      'amount_costs': fields.float('Est.Cost', readonly=True),
   'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
   'nbr': fields.integer('# of Cases', readonly=True),
      'probability': fields.float('Avg. Probability', readonly=True),
   'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
   'delay_close': fields.integer('Delay to close', readonly=True),
   }
    _order = 'name desc, user_id, section_id'

   def init(self, cr):
   cr.execute("""
        create or replace view report_crm_case_user as (
            select
                min(c.id) as id,
                substring(c.create_date for 7)||'-01' as name,
                c.state,
                c.user_id,
                c.section_id,
                count(*) as nbr,
                sum(planned_revenue) as amount_revenue,
                sum(planned_cost) as amount_costs,
                sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
                avg(probability)::decimal(16,2) as probability,
                to_char(avg(date_closed-c.create_date), 'DD"d" `HH24:MI:SS') as delay_close
            from
                crm_case c
            group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
   )""")
   report_crm_case_user()

You can find the applications of _auto=False in the Sales Analysis report in Reporting tab of OpenERP and the code in report folder in sales module.

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

0 follower(s)

Stats

Asked: 3/21/13, 4:30 AM
Seen: 4366 times
Last updated: 3/16/15, 8:10 AM