How to add a new commercial field

Commercial fields are fields that are managed by the commercial entity to which a partner belongs. For example “vat” field is set in the parent company object and its value is transferred to all childs` contacts.

In case if you need to add a new field with the same functionality, then you would need to add the field in the res.partner model and to override the method _commercial_fields.

For example, let`s add the “credit_limit” field as a┬ácommercial field:

class ResPartner(models.Model):
    _inherit = "res.partner"

    credit_limit = fields.Float(string='Credit Limit')


    @api.model
    def _commercial_fields(self):
        return super(ResPartner, self)._commercial_fields() + ['credit_limit']
Share the knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *