Odoo Help

2

How to write my own validation on default save button in partners ? [Closed]

By
Sohail
on 5/17/13, 1:32 PM 4,413 views

The Question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
on 05/18/2013 07:40:20

I need to write my own validation on default save button of openerp 7.0 in partners where I check validation for certain fields.

5

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11456
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 5/17/13, 3:34 PM

For that you need to override two methods in res.partner class.

  1. create: Which is called when new record is created.
  2. write: Which is when existing record is updated.

Override create:

def create(self, cr, uid, vals, context=None):
    #Your code goes here
    res = super(your_class_name, self).create(cr, uid, vals, context=context)
    #Your code goes here
    return res

Override write:

def write(self, cr, uid, ids, vals, context=None):
    #Your code goes here
    res = super(your_class_name, self).write(cr, uid, ids, vals, context=context)
    #Your code goes here
    return res

You can use _constraints also to validate your fields.

def _my_check_method(self, cr, uid, ids, context=None):
    #Your code goes here
    return True or False

_constraints = [(_my_check_method, 'Your Message', ['your_field']),]

Return True if your validation condition satisfy, False otherwise from your method of constraints.

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

2 follower(s)

Stats

Asked: 5/17/13, 1:32 PM
Seen: 4413 times
Last updated: 4/10/15, 7:18 AM