Odoo Help


default_supplier and supplier

on 4/16/15, 7:00 PM 402 views

hi everyone while begging supplier is a boolean field of res.partner class that determines whether the partner is supplier or not... well I have two questions:

1- what is the difference between context={'default_supplier':True and context={'supplier':True

2 in the form fleet_vehicle_contract_form there is a field provider with context={'default_supplier':True, but that shows all partner not the only vendor


Brett Lehrer

--Brett Lehrer--
Brett Lehrer
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 4/16/15, 7:20 PM

1.  It depends.  Context is designed to carry specific, relevant information back and forth between the client and server, as well as through different functions run from a single action.  Context keys that start with 'default_' automatically trigger a response in the default_get() function of the ORM.  Using context={'default_some_field_name':'some_value'} means that when you're loading a form to create a new record, the field called 'some_field_name' will be automatically assigned the default value of 'some_value'.  In your example, that would be used from the Suppliers menu within Purchasing so that whenever you create a new partner, it's automatically a supplier as well as a partner.

The other option, context={'supplier':True} doesn't necessarily mean anything specific.  That's just some syntax that is relevant to a Python function.  It could be anything you wanted - context={'important_extra_thing_to_do':'ABC'} would be fine as well to program into a view or action, if your Python code checked the context for the key 'important_extra_thing_to_do'.

2. Context values aren't filters of information, that's the job of the Domain.  What probably should be in place in that instance is:

<field name="provider" context="{'default_supplier':True}" domain="[('supplier','=',True)]"/>

This means that the only partners that are visible must already be suppliers, and if you're creating a new partner directly from this field, it will automatically fill in the value of the supplier field as True.

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


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

1 follower(s)


Asked: 4/16/15, 7:00 PM
Seen: 402 times
Last updated: 4/18/15, 1:41 AM