This question has been flagged
1 Reply
3403 Views

Hello,

I am little confused because of customer in Sales and supplier in Purchase Module. These two things using the same class, but when we are searching supplier it automatically get the name as supplier and customer. Actually what i am saying, the sales module is called the " res.partner" for Customer, and in purchase also using the same "res.partner" for Supplier. And both of them(sales&Purchase) creating the customer with tags as customer, and supplier. How it is possible? is this possible by domain? if if yes can you explain me how its works?



Thanking You,

Prasanth.KS

Avatar
Discard
Best Answer

Yes, this is filtered by a domain, you could search for partners that are customers, or suppliers or employees or companies using this fields in the res.partner model

'customer': fields.boolean('Customer', help="Check this box if this contact is a customer."),
'supplier': fields.boolean('Supplier', help="Check this box if this contact is a supplier. If it's not checked, purchase people will not see it when encoding a purchase order."),
'employee': fields.boolean('Employee', help="Check this box if this contact is an Employee."),

'is_company': fields.boolean('Is a Company', help="Check if the contact is a company, otherwise it is a person"),

---Update--- How the specific fields get a True value using a menu or another

For example the suppliers partners are created using the menu suppliers in Accounting menu or in Purchase menu because of the use of a context value default_supplier with value 1 that makes that every Partner created using that menu get the field supplier with value 1 and finally True.

As a rule of thumbs always that you define a value in a context with a field name prefixed by "default_" you are giving that value for the field(if exist) of the model form that will be opened using that context. This could be used in the xml for actions, buttons, relation fields like many2one, many2many or one2many, or in the returned actions of buttons. It's like defining the default value for the field but in xml. Take this example from the supplier menu in base, this is the action definition:

<record id="action_partner_supplier_form" model="ir.actions.act_window">

...

<field name="context">{'search_default_supplier': 1,'default_customer': 0,'default_supplier': 1}</field>

...

</record>

For the sake of completeness the sames applies for the prefix value 'search_default_' use that it will select the filter field in the search view by default, like the supplier filter of the search view of the partners model defined like:
<filter string="Suppliers" name="supplier" domain="[('supplier','=',1)]" help="Supplier Partners"/>

That filter will be applied by default too. All of this will be done by the use of the 'default_' and 'search_default_' in the context always followed by a field name for the 'default_' and a filter name for the 'search_default_' 

Avatar
Discard
Author

@Axel Mendoza thank you for your reply, i understood these. But when we are creating customers or suppliers, we didn't put customer as true or supplier as true, but its automatically done when we are saving that data. How it is possible ?? this is what want to know .

Just see the answer update for more about this

Author

thank you @Axel Mendoza.

Happy to help you