Odoo Help

0

0
3 Answers
1
Avatar

Cybrosys Techno Solutions Pvt.Ltd India

--Cybrosys Techno Solutions Pvt.Ltd--
Cybrosys Techno Solutions Pvt.Ltd
https://www.cybrosys.com
17125
| 7 6 10
Calicut, India
--Cybrosys Techno Solutions Pvt.Ltd--

Cybrosys Technologies is a private limited ISO certified company in Technology and Software Engineering sector. We serve as one of the best and trusted Odoo official partner, providing ultimate Customization and Implementation services in Odoo ERP. A frequent contributor to Odoo Apps, our customized free apps are downloaded by more than one lakh users. Most of our apps augment the potentialities of Odoo and are trending in the Odoo app store.

Cybrosys keeps privilege to be one among the finest Odoo Official Partners with 200+ free apps contribution towards the Odoo community. Cybrosys also stands number one in Odoo-social Media Integration empowering every kind of business solutions.

We are also enriched with highly skilled UI/UX technical experts for Developing, Implementing and Designing, thereby providing ultimate benefit to our customer base.

Today Cybrosys has reached par excellent in Odoo Implementation and allied services, proving its credibility and reliability. Our proven services are used by customers sprawling across 160+ countries including Middle East, African continents, UK, Germany, Spain, Thailand, Hong Kong, New Zealand, Australia, Malaysia, Singapore, Egypt etc.

We are rapidly expanding our base with robust quality management and business process re-engineering to meet the ultimate customer desire.

To know more about Cybrosys Technologies and our Odoo Apps, Kindly visit:

Cybrosys Technologies 

Odoo Apps 

And inbox us your queries to odoo@cybrosys.com

Cybrosys Techno Solutions Pvt.Ltd India
2/26/19, 3:10 AM

Hi,

You can remove the deafult=True from the field, or make default=False

customer = fields.Boolean(string='Is a Customer', default=False,
help="Check this box if this contact is a customer.")


Then to prevent the saving of record without ticking customer, supplier or your third field. Add a constrain for the model res.partner.

@api.constrains('customer', 'supplier', 'third_field')
def check_ticks(self):
if not self.customer and not self.supplier and not self.third_filed_name:
raise ValidationError(_("Customer or Vendor Has to be Ticked..!"))


Full Code:

from odoo.exceptions import ValidationError

class ResPartner(models.Model):
_inherit = 'res.partner'

customer = fields.Boolean(string='Is a Customer', default=False,
help="Check this box if this contact is a customer.")

@api.constrains('customer', 'supplier', 'third_field')
def check_ticks(self):
if not self.customer and not self.supplier and not self.third_filed_name:
raise ValidationError(_("Customer or Vendor Has to be Ticked..!"))

Thanks

1 Comment
Bill Ennals Australia
2/26/19, 3:14 AM

wow, thank you. I will try it and report back

0
Krithika Ravindran India
2/26/19, 2:28 AM

Give default=False in he field that has to remain unchecked by default

For example,

isacustomer=fields.Boolean(string="IS A CUSTOMER",default=False,readonly=True)

readonly=True will make the boolean field non-accessible
2 Comments
Bill Ennals Australia
2/26/19, 2:40 AM

Thanks for answering. Do you mean I should create a module that inherits from Contacts? Also, what about the second part of my question. I have edited it above to make it more clear.

Krithika Ravindran India
2/26/19, 3:28 AM

Yes. The changes must be done in a new inherited module for Contacts

Ask a Question
Writer
Keep Informed
1 follower(s)
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