SlideShare a Scribd company logo
Model Attribute
_check_company_auto
Property
Enterprise
Introduction
Enterprise
In Odoo, the multi-company feature allows you to manage
multiple companies within a single Odoo database instance.
Each company can have its own configurations while still
sharing common resources such as products, customers, and
suppliers.
In some cases, we need to consider some important factors in
order to make sure that the data in each company don't get
mixed up and lead to access errors. That is, for example if we
want to restrict a particular product’s access in only one
branch of the company, it can be done with this
_check_company_auto attribute.
Enterprise
When we are using the company_id field in our model, then
creating a relational field like a many2one, many2many
one2many etc needs to be from the same company.
The _check_company_auto and check_company are set to
True to and each create and write on this model will check that
the company given is correct.
When a field is defined without any domain and
check_company is set to true, then a domain of the form:
['|', '('company_id', '=', False), ('company_id', '=', company_id)]
gets added to the field by default.
Enterprise
First, lets create a setup Odoo with multiple companies as here we
can see Head Office, Branch Company 1 and Branch Company 2.
Enterprise
Then, lets create a module, here for example
travel_management. Lets create a simple model which stores
data of the travel booking. And just define some basic fields,
menus, tree view, form view for the model.
Enterprise
Create a product, lets say ‘Booking’, which can be selected
from our travel management booking system through a
Many2one field later. Set the Company of the product as Head
Office.
Enterprise
Define some fields to manage Travel booking. Here, I’ve created
the class and fields as
class TravelBooking(models.Model):
_name = 'travel.booking'
_description = 'Travel Card'
_rec_name = 'booking_id'
booking_id = fields.Char(string="Booking ID",
required=True,
readonly=True,
default='New')
partner_id = fields.Many2one('res.partner',string="Partner
Name",required=True)
company_id = fields.Many2one('res.company',string="Company Name")
product_id = fields.Many2one('product.product',string="Product")
partner_mobile = fields.Char(string="Mobile")
passenger_count = fields.Integer(string="No of Passengers")
Enterprise
And while creating travel booking records, we can see the
product Booking will be accessible for all the companies when we
switch
Enterprise
Here comes the need for the access control for any such resources
like products here. A person can log in to one company and create
records for another company which may not be accurate in all cases.
So, we use the class attribute _check_company_auto and set it to
true. This will make sure that each create and write on this model will
check that the company given is correct. ie,
class TravelBooking(models.Model):
_name = 'travel.booking'
_description = 'Travel Card'
_rec_name = 'booking_id'
_check_company_auto = True
Also, set the attribute check_company=True for the
relational field which needs to be available only in the created
company.
product_id =
fields.Many2one('product.product',string="Product",
check_company=True)
Enterprise
The product ‘booking’ can be selected and the record gets
saved without as before itself, without any issue
Now, let's check the Booking creation from the current company
first.
Enterprise
The product ‘Booking’ can’t be seen.
Then, let's check the Booking creation from the other company.
Enterprise
Here comes the error which says that the product doesn’t belong to the
selected company.
Now, just try to edit any previous record by changing the company name,
keeping the product as same. Here, even the change in company must
manage to check whether the already saved product’s access is correctly
working or not.
The check_company and _check_company_auto will work here.
For More Info.
Check our company website for related
blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

Similar to Model Attribute Check Company Auto Property

Sfdc documentation
Sfdc documentationSfdc documentation
Sfdc documentation
TUSHAR VARSHNEY
 
Sales force class-3
Sales force class-3Sales force class-3
Sales force class-3
Amit Sharma
 
Check printing in_r12
Check printing in_r12Check printing in_r12
Check printing in_r12
Rajesh Khatri
 
Correlation id token in share point 2010
Correlation id token in share point 2010Correlation id token in share point 2010
Correlation id token in share point 2010
UGAIA
 
Embellish bureau
Embellish bureauEmbellish bureau
Embellish bureau
siraj10
 
Sales force certification-lab
Sales force certification-labSales force certification-lab
Sales force certification-lab
Amit Sharma
 
eresource 3GL ERP | ERP For Transportation Business | Admin Module
eresource 3GL ERP | ERP For Transportation Business | Admin Moduleeresource 3GL ERP | ERP For Transportation Business | Admin Module
eresource 3GL ERP | ERP For Transportation Business | Admin Module
eresource infotech pvt ltd
 
Salesforce crm projects
Salesforce crm projects Salesforce crm projects
Salesforce crm projects
Advanz Knowledge Systems P Ltd
 
How To Use CherryPie: Creating Offers
How To Use CherryPie: Creating OffersHow To Use CherryPie: Creating Offers
How To Use CherryPie: Creating Offers
PassKit
 
AIResume Automated Generation Of Resume Work History
AIResume  Automated Generation Of Resume Work HistoryAIResume  Automated Generation Of Resume Work History
AIResume Automated Generation Of Resume Work History
Lisa Garcia
 
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
Magento Imagine eCommerce Conference 2011: Using Magento's Import ModuleMagento Imagine eCommerce Conference 2011: Using Magento's Import Module
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
varien
 
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
MagentoImagine
 
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docxThis is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
abhi353063
 
Open erp v7 contacts issue
Open erp v7 contacts issueOpen erp v7 contacts issue
Open erp v7 contacts issue
Open erp v7 contacts issueOpen erp v7 contacts issue
Open erp v7 contacts issue
Raphaël Valyi
 
Data Modeling in Looker
Data Modeling in LookerData Modeling in Looker
Data Modeling in Looker
Looker
 
OfficeCentral Manual-en-procurement v3-r4
OfficeCentral Manual-en-procurement v3-r4OfficeCentral Manual-en-procurement v3-r4
OfficeCentral Manual-en-procurement v3-r4
venturesmarketing
 
What is sap security
What is sap securityWhat is sap security
What is sap security
grconlinetraining
 
Part A Entity Relationship Diagram This new system would.pdf
Part A Entity Relationship Diagram This new system would.pdfPart A Entity Relationship Diagram This new system would.pdf
Part A Entity Relationship Diagram This new system would.pdf
sdfghj21
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
Celine George
 

Similar to Model Attribute Check Company Auto Property (20)

Sfdc documentation
Sfdc documentationSfdc documentation
Sfdc documentation
 
Sales force class-3
Sales force class-3Sales force class-3
Sales force class-3
 
Check printing in_r12
Check printing in_r12Check printing in_r12
Check printing in_r12
 
Correlation id token in share point 2010
Correlation id token in share point 2010Correlation id token in share point 2010
Correlation id token in share point 2010
 
Embellish bureau
Embellish bureauEmbellish bureau
Embellish bureau
 
Sales force certification-lab
Sales force certification-labSales force certification-lab
Sales force certification-lab
 
eresource 3GL ERP | ERP For Transportation Business | Admin Module
eresource 3GL ERP | ERP For Transportation Business | Admin Moduleeresource 3GL ERP | ERP For Transportation Business | Admin Module
eresource 3GL ERP | ERP For Transportation Business | Admin Module
 
Salesforce crm projects
Salesforce crm projects Salesforce crm projects
Salesforce crm projects
 
How To Use CherryPie: Creating Offers
How To Use CherryPie: Creating OffersHow To Use CherryPie: Creating Offers
How To Use CherryPie: Creating Offers
 
AIResume Automated Generation Of Resume Work History
AIResume  Automated Generation Of Resume Work HistoryAIResume  Automated Generation Of Resume Work History
AIResume Automated Generation Of Resume Work History
 
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
Magento Imagine eCommerce Conference 2011: Using Magento's Import ModuleMagento Imagine eCommerce Conference 2011: Using Magento's Import Module
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
 
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
Magento's Imagine eCommerce Conference 2011 - Import Export in a Flash with t...
 
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docxThis is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
 
Open erp v7 contacts issue
Open erp v7 contacts issueOpen erp v7 contacts issue
Open erp v7 contacts issue
 
Open erp v7 contacts issue
Open erp v7 contacts issueOpen erp v7 contacts issue
Open erp v7 contacts issue
 
Data Modeling in Looker
Data Modeling in LookerData Modeling in Looker
Data Modeling in Looker
 
OfficeCentral Manual-en-procurement v3-r4
OfficeCentral Manual-en-procurement v3-r4OfficeCentral Manual-en-procurement v3-r4
OfficeCentral Manual-en-procurement v3-r4
 
What is sap security
What is sap securityWhat is sap security
What is sap security
 
Part A Entity Relationship Diagram This new system would.pdf
Part A Entity Relationship Diagram This new system would.pdfPart A Entity Relationship Diagram This new system would.pdf
Part A Entity Relationship Diagram This new system would.pdf
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 

More from Celine George

Reports in Odoo 17 Point of Sale - Odoo Slides
Reports in Odoo 17 Point of Sale - Odoo SlidesReports in Odoo 17 Point of Sale - Odoo Slides
Reports in Odoo 17 Point of Sale - Odoo Slides
Celine George
 
New Features in Odoo 17 Email Marketing - Odoo Slides
New Features in Odoo 17 Email Marketing - Odoo SlidesNew Features in Odoo 17 Email Marketing - Odoo Slides
New Features in Odoo 17 Email Marketing - Odoo Slides
Celine George
 
How to define Related field in Odoo 17 - Odoo 17 Slides
How to define Related field in Odoo 17 - Odoo 17 SlidesHow to define Related field in Odoo 17 - Odoo 17 Slides
How to define Related field in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Make a Field Storable in Odoo 17 - Odoo Slides
How to Make a Field Storable in Odoo 17 - Odoo SlidesHow to Make a Field Storable in Odoo 17 - Odoo Slides
How to Make a Field Storable in Odoo 17 - Odoo Slides
Celine George
 
How to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
How to Set Default Filter in Search View / Set Default Filter For Menu In OdooHow to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
How to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
Celine George
 
How To Set Default Group By For Menu Action In Odoo
How To Set Default Group By For Menu Action In OdooHow To Set Default Group By For Menu Action In Odoo
How To Set Default Group By For Menu Action In Odoo
Celine George
 
How to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
How to Use Pre Init hook in Odoo 17 -Odoo 17 SlidesHow to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
How to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
Celine George
 
Demonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 SlidesDemonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Activate & Create Sales Receipts in Odoo 17
How to Activate & Create Sales Receipts in Odoo 17How to Activate & Create Sales Receipts in Odoo 17
How to Activate & Create Sales Receipts in Odoo 17
Celine George
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
Celine George
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
Celine George
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
Celine George
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Manage Line Discount in Odoo 17 POS
How to Manage Line Discount in Odoo 17 POSHow to Manage Line Discount in Odoo 17 POS
How to Manage Line Discount in Odoo 17 POS
Celine George
 
How to Manage Access Rights & User Types in Odoo 17
How to Manage Access Rights & User Types in Odoo 17How to Manage Access Rights & User Types in Odoo 17
How to Manage Access Rights & User Types in Odoo 17
Celine George
 
How to Manage Shipping Connectors & Shipping Methods in Odoo 17
How to Manage Shipping Connectors & Shipping Methods in Odoo 17How to Manage Shipping Connectors & Shipping Methods in Odoo 17
How to Manage Shipping Connectors & Shipping Methods in Odoo 17
Celine George
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
 
New Features in Odoo 17 Sign - Odoo 17 Slides
New Features in Odoo 17 Sign - Odoo 17 SlidesNew Features in Odoo 17 Sign - Odoo 17 Slides
New Features in Odoo 17 Sign - Odoo 17 Slides
Celine George
 
How to Manage Early Receipt Printing in Odoo 17 POS
How to Manage Early Receipt Printing in Odoo 17 POSHow to Manage Early Receipt Printing in Odoo 17 POS
How to Manage Early Receipt Printing in Odoo 17 POS
Celine George
 
What is Rescue Session in Odoo 17 POS - Odoo 17 Slides
What is Rescue Session in Odoo 17 POS - Odoo 17 SlidesWhat is Rescue Session in Odoo 17 POS - Odoo 17 Slides
What is Rescue Session in Odoo 17 POS - Odoo 17 Slides
Celine George
 

More from Celine George (20)

Reports in Odoo 17 Point of Sale - Odoo Slides
Reports in Odoo 17 Point of Sale - Odoo SlidesReports in Odoo 17 Point of Sale - Odoo Slides
Reports in Odoo 17 Point of Sale - Odoo Slides
 
New Features in Odoo 17 Email Marketing - Odoo Slides
New Features in Odoo 17 Email Marketing - Odoo SlidesNew Features in Odoo 17 Email Marketing - Odoo Slides
New Features in Odoo 17 Email Marketing - Odoo Slides
 
How to define Related field in Odoo 17 - Odoo 17 Slides
How to define Related field in Odoo 17 - Odoo 17 SlidesHow to define Related field in Odoo 17 - Odoo 17 Slides
How to define Related field in Odoo 17 - Odoo 17 Slides
 
How to Make a Field Storable in Odoo 17 - Odoo Slides
How to Make a Field Storable in Odoo 17 - Odoo SlidesHow to Make a Field Storable in Odoo 17 - Odoo Slides
How to Make a Field Storable in Odoo 17 - Odoo Slides
 
How to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
How to Set Default Filter in Search View / Set Default Filter For Menu In OdooHow to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
How to Set Default Filter in Search View / Set Default Filter For Menu In Odoo
 
How To Set Default Group By For Menu Action In Odoo
How To Set Default Group By For Menu Action In OdooHow To Set Default Group By For Menu Action In Odoo
How To Set Default Group By For Menu Action In Odoo
 
How to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
How to Use Pre Init hook in Odoo 17 -Odoo 17 SlidesHow to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
How to Use Pre Init hook in Odoo 17 -Odoo 17 Slides
 
Demonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 SlidesDemonstration module in Odoo 17 - Odoo 17 Slides
Demonstration module in Odoo 17 - Odoo 17 Slides
 
How to Activate & Create Sales Receipts in Odoo 17
How to Activate & Create Sales Receipts in Odoo 17How to Activate & Create Sales Receipts in Odoo 17
How to Activate & Create Sales Receipts in Odoo 17
 
Odoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List ScanningOdoo 17 Events - Attendees List Scanning
Odoo 17 Events - Attendees List Scanning
 
E-learning Odoo 17 New features - Odoo 17 Slides
E-learning Odoo 17  New features - Odoo 17 SlidesE-learning Odoo 17  New features - Odoo 17 Slides
E-learning Odoo 17 New features - Odoo 17 Slides
 
Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17Mail Server Configuration Using App passwords in Odoo 17
Mail Server Configuration Using App passwords in Odoo 17
 
View Inheritance in Odoo 17 - Odoo 17 Slides
View Inheritance in Odoo 17 - Odoo 17  SlidesView Inheritance in Odoo 17 - Odoo 17  Slides
View Inheritance in Odoo 17 - Odoo 17 Slides
 
How to Manage Line Discount in Odoo 17 POS
How to Manage Line Discount in Odoo 17 POSHow to Manage Line Discount in Odoo 17 POS
How to Manage Line Discount in Odoo 17 POS
 
How to Manage Access Rights & User Types in Odoo 17
How to Manage Access Rights & User Types in Odoo 17How to Manage Access Rights & User Types in Odoo 17
How to Manage Access Rights & User Types in Odoo 17
 
How to Manage Shipping Connectors & Shipping Methods in Odoo 17
How to Manage Shipping Connectors & Shipping Methods in Odoo 17How to Manage Shipping Connectors & Shipping Methods in Odoo 17
How to Manage Shipping Connectors & Shipping Methods in Odoo 17
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
 
New Features in Odoo 17 Sign - Odoo 17 Slides
New Features in Odoo 17 Sign - Odoo 17 SlidesNew Features in Odoo 17 Sign - Odoo 17 Slides
New Features in Odoo 17 Sign - Odoo 17 Slides
 
How to Manage Early Receipt Printing in Odoo 17 POS
How to Manage Early Receipt Printing in Odoo 17 POSHow to Manage Early Receipt Printing in Odoo 17 POS
How to Manage Early Receipt Printing in Odoo 17 POS
 
What is Rescue Session in Odoo 17 POS - Odoo 17 Slides
What is Rescue Session in Odoo 17 POS - Odoo 17 SlidesWhat is Rescue Session in Odoo 17 POS - Odoo 17 Slides
What is Rescue Session in Odoo 17 POS - Odoo 17 Slides
 

Recently uploaded

11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
mansk2
 
Imagination in Computer Science Research
Imagination in Computer Science ResearchImagination in Computer Science Research
Imagination in Computer Science Research
Abhik Roychoudhury
 
JavaScript Interview Questions PDF By ScholarHat
JavaScript Interview  Questions PDF By ScholarHatJavaScript Interview  Questions PDF By ScholarHat
JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
The Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdfThe Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdf
luzmilaglez334
 
NAEYC Code of Ethical Conduct Resource Book
NAEYC Code of Ethical Conduct Resource BookNAEYC Code of Ethical Conduct Resource Book
NAEYC Code of Ethical Conduct Resource Book
lakitawilson
 
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
Cátedra Banco Santander
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
thanhluan21
 
Allopathic M1 Srudent Orientation Powerpoint
Allopathic M1 Srudent Orientation PowerpointAllopathic M1 Srudent Orientation Powerpoint
Allopathic M1 Srudent Orientation Powerpoint
Julie Sarpy
 
A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...
Association for Project Management
 
How to Create & Publish a Blog in Odoo 17 Website
How to Create & Publish a Blog in Odoo 17 WebsiteHow to Create & Publish a Blog in Odoo 17 Website
How to Create & Publish a Blog in Odoo 17 Website
Celine George
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
SarahAlie1
 
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptxKesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
artenzmartenkai
 
Introduction to Google Productivity Tools for Office and Personal Use
Introduction to Google Productivity Tools for Office and Personal UseIntroduction to Google Productivity Tools for Office and Personal Use
Introduction to Google Productivity Tools for Office and Personal Use
Excellence Foundation for South Sudan
 
2 Post harvest Physiology of Horticulture produce.pptx
2 Post harvest Physiology of Horticulture  produce.pptx2 Post harvest Physiology of Horticulture  produce.pptx
2 Post harvest Physiology of Horticulture produce.pptx
UmeshTimilsina1
 
Node JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHatNode JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHat
Scholarhat
 
Parent PD Design for Professional Development .docx
Parent PD Design for Professional Development .docxParent PD Design for Professional Development .docx
Parent PD Design for Professional Development .docx
AntonioJarligoCompra
 
How To Update One2many Field From OnChange of Field in Odoo 17
How To Update One2many Field From OnChange of Field in Odoo 17How To Update One2many Field From OnChange of Field in Odoo 17
How To Update One2many Field From OnChange of Field in Odoo 17
Celine George
 
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Alvaro Barbosa
 
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
ASP.NET Core Interview Questions PDF By ScholarHat.pdfASP.NET Core Interview Questions PDF By ScholarHat.pdf
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
Scholarhat
 

Recently uploaded (20)

11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
11EHS Term 3 Week 1 Unit 1 Review: Feedback and improvementpptx
 
Imagination in Computer Science Research
Imagination in Computer Science ResearchImagination in Computer Science Research
Imagination in Computer Science Research
 
JavaScript Interview Questions PDF By ScholarHat
JavaScript Interview  Questions PDF By ScholarHatJavaScript Interview  Questions PDF By ScholarHat
JavaScript Interview Questions PDF By ScholarHat
 
C Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdfC Interview Questions PDF By Scholarhat.pdf
C Interview Questions PDF By Scholarhat.pdf
 
The Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdfThe Cruelty of Animal Testing in the Industry.pdf
The Cruelty of Animal Testing in the Industry.pdf
 
NAEYC Code of Ethical Conduct Resource Book
NAEYC Code of Ethical Conduct Resource BookNAEYC Code of Ethical Conduct Resource Book
NAEYC Code of Ethical Conduct Resource Book
 
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
Cómo crear video-tutoriales con ScreenPal (2 de julio de 2024)
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
 
Allopathic M1 Srudent Orientation Powerpoint
Allopathic M1 Srudent Orientation PowerpointAllopathic M1 Srudent Orientation Powerpoint
Allopathic M1 Srudent Orientation Powerpoint
 
A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...A beginner’s guide to project reviews - everything you wanted to know but wer...
A beginner’s guide to project reviews - everything you wanted to know but wer...
 
How to Create & Publish a Blog in Odoo 17 Website
How to Create & Publish a Blog in Odoo 17 WebsiteHow to Create & Publish a Blog in Odoo 17 Website
How to Create & Publish a Blog in Odoo 17 Website
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
 
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptxKesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
 
Introduction to Google Productivity Tools for Office and Personal Use
Introduction to Google Productivity Tools for Office and Personal UseIntroduction to Google Productivity Tools for Office and Personal Use
Introduction to Google Productivity Tools for Office and Personal Use
 
2 Post harvest Physiology of Horticulture produce.pptx
2 Post harvest Physiology of Horticulture  produce.pptx2 Post harvest Physiology of Horticulture  produce.pptx
2 Post harvest Physiology of Horticulture produce.pptx
 
Node JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHatNode JS Interview Question PDF By ScholarHat
Node JS Interview Question PDF By ScholarHat
 
Parent PD Design for Professional Development .docx
Parent PD Design for Professional Development .docxParent PD Design for Professional Development .docx
Parent PD Design for Professional Development .docx
 
How To Update One2many Field From OnChange of Field in Odoo 17
How To Update One2many Field From OnChange of Field in Odoo 17How To Update One2many Field From OnChange of Field in Odoo 17
How To Update One2many Field From OnChange of Field in Odoo 17
 
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...
 
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
ASP.NET Core Interview Questions PDF By ScholarHat.pdfASP.NET Core Interview Questions PDF By ScholarHat.pdf
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
 

Model Attribute Check Company Auto Property

  • 2. Introduction Enterprise In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers. In some cases, we need to consider some important factors in order to make sure that the data in each company don't get mixed up and lead to access errors. That is, for example if we want to restrict a particular product’s access in only one branch of the company, it can be done with this _check_company_auto attribute.
  • 3. Enterprise When we are using the company_id field in our model, then creating a relational field like a many2one, many2many one2many etc needs to be from the same company. The _check_company_auto and check_company are set to True to and each create and write on this model will check that the company given is correct. When a field is defined without any domain and check_company is set to true, then a domain of the form: ['|', '('company_id', '=', False), ('company_id', '=', company_id)] gets added to the field by default.
  • 4. Enterprise First, lets create a setup Odoo with multiple companies as here we can see Head Office, Branch Company 1 and Branch Company 2.
  • 5. Enterprise Then, lets create a module, here for example travel_management. Lets create a simple model which stores data of the travel booking. And just define some basic fields, menus, tree view, form view for the model.
  • 6. Enterprise Create a product, lets say ‘Booking’, which can be selected from our travel management booking system through a Many2one field later. Set the Company of the product as Head Office.
  • 7. Enterprise Define some fields to manage Travel booking. Here, I’ve created the class and fields as class TravelBooking(models.Model): _name = 'travel.booking' _description = 'Travel Card' _rec_name = 'booking_id' booking_id = fields.Char(string="Booking ID", required=True, readonly=True, default='New') partner_id = fields.Many2one('res.partner',string="Partner Name",required=True) company_id = fields.Many2one('res.company',string="Company Name") product_id = fields.Many2one('product.product',string="Product") partner_mobile = fields.Char(string="Mobile") passenger_count = fields.Integer(string="No of Passengers")
  • 8. Enterprise And while creating travel booking records, we can see the product Booking will be accessible for all the companies when we switch
  • 9. Enterprise Here comes the need for the access control for any such resources like products here. A person can log in to one company and create records for another company which may not be accurate in all cases. So, we use the class attribute _check_company_auto and set it to true. This will make sure that each create and write on this model will check that the company given is correct. ie, class TravelBooking(models.Model): _name = 'travel.booking' _description = 'Travel Card' _rec_name = 'booking_id' _check_company_auto = True Also, set the attribute check_company=True for the relational field which needs to be available only in the created company. product_id = fields.Many2one('product.product',string="Product", check_company=True)
  • 10. Enterprise The product ‘booking’ can be selected and the record gets saved without as before itself, without any issue Now, let's check the Booking creation from the current company first.
  • 11. Enterprise The product ‘Booking’ can’t be seen. Then, let's check the Booking creation from the other company.
  • 12. Enterprise Here comes the error which says that the product doesn’t belong to the selected company. Now, just try to edit any previous record by changing the company name, keeping the product as same. Here, even the change in company must manage to check whether the already saved product’s access is correctly working or not. The check_company and _check_company_auto will work here.
  • 13. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com