How to set default values for a record?

  • language
      English
  • type
      technical
  • info created for version
      15.0
Add to Cart

    @api.model
    def default_get(self, fields):
        result = super(SaleOrder, self).default_get(fields)
        if result.get('task_id'):
            task_id = self.env['project.task'].browse(result.get('task_id'))
            if task_id:
                result.update({
                    'partner_invoice_id': task_id.partner_invoice_id if task_id.partner_invoice_id else task_id.partner_id,
                    'partner_shipping_id': task_id.partner_intervention_id if task_id.partner_intervention_id else task_id.partner_id})
        return result