Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2881 Vistas


Hi,


On Odoo13, I would like to allow users to create a quotation without having to set a fill some fields such as Fiscal Position or Delivery Date, but force them to fill that data before confirming that quotation.


I'm trying to use:

<field name="fiscal_position_id" attrs="{'required': [('state', 'in', ['sale'])]}"/>
But this doesn't restrict the user from Confirming the quotation, it only restricts when I try to edit a confirmed quotation.

How can I do this ?


Thanks in advance!

Avatar
Descartar
Mejor respuesta

Hi,

You can override the action_confirm button and show the warning to the user if the fields are not set.

Sample Code:

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


class SaleOrder(models.Model):
_name = "sale.order"

def action_confirm(self):
if not self.fiscal_position_id:
raise ValidationError(_('Fiscal Position Is Required'))
res = super(SaleOrder, self).action_confirm()
return res

Thanks

Avatar
Descartar
Autor

Worked perfectly! Sorry for not marking this as best answer before, only today I actually got to implement your solution

Publicaciones relacionadas Respuestas Vistas Actividad
2
sept 23
3879
1
dic 22
2163
3
nov 22
4392
1
nov 22
4684
1
may 22
4005