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:

5 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 . https://drive.google.com/open?id=1nuu1Ay9-vfq9-bPruG6PwDClLEUz6ZYV

    Thank you.

    Like

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s