Use Server Actions to set a contact to be a customer or supplier

In Odoo, customer, suppliers, and other types of contacts are all stored in the same model (database table).

In Odoo 12 it was easy to see whether a contact was a customer or a vendor (supplier), and you could make changes.

In Odoo 13, the fields “Is a Customer” and “Is a Supplier” on a contact have been removed. Instead there are two new fields: Customer Rank and Supplier Rank – but they are not displayed.

Remove customer/supplier fields on res.partner [GitHub]

Fortunately, if you create a contact from the Customer menu option it will be a Customer, which means that it will have Customer Rank set to 1 (the equivalent of Is a Customer set to ‘True’ in Odoo 12).

Note: In Odoo 13 it is possible to select any contact as a customer on a Quotation / Sales Order whether or not the Customer Rank is set.

Similar logic applies for suppliers / vendors.

The possible problems in Odoo 13 are

  1. We create a contact and then remember they should have been a customer (or a supplier)
  2. We have a contact who is both a customer and a supplier

So we will create a Server Action to set Customer Rank, or Supplier Rank, or both, to 1.

You need to be in Developer mode. Then navigate to Settings / Technical / Server Actions

Click on “Create”

  1. Enter an action name (“Set as Customer”)
  2. Select the Model (Contact / res.partner)
  3. In “Data to Write”
    1. Select the field (Customer Rank)
    2. Enter the value (1)

Press Save.

Contextual Action

The next step is to click on “Create Contextual Action”

And you will find it in the “Action” dropdown:

It’s simple to go a little bit further, and set a contact to be both a customer and a supplier:

You could do the same in Odoo 12 or earlier, the only differences being the field names and values:

8 thoughts on “Use Server Actions to set a contact to be a customer or supplier

  1. 1. Created server actions , and set Yangon Factory as Vendor.
    2. Tried applied this record on both Yangon factory and SBAYW company.
    3. PO > Vendor (still can’t see)
    4. PO > Change company from SBAYW to Yangon Factory, can see all contact from Yangon Factory.

    My goal is to set Yangon Factory as Vendor in Inventory > A product > Purchase.
    Please check vendor5.png from Google drive link .

    Thank you.


  2. I tried this, but a contact I set as customer is showing up as a vendor in the vendor selection field.

    Please I need help with this thanks


    1. As explained above, when creating an RFQ / PO you can select any contact, so it needs customization to limit it to vendors only. This seems odd, but that is how it currently works!


  3. Please, how can I return an action using server action?

    I want to create a record in a model from a button click, see code below:
    def create_po(self):
    action = {par}

    self.x_product_requisition.x_ven_id is the record I want to be in the partner_id field i.e vendor field, in Purchase module

    but it is not working

    Please help me out


Leave a Reply to Chris Tringham Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s