Skip to Content
Menu
This question has been flagged
1 Reply
2178 Views


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
Discard
Best Answer

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
Discard
Author

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

Related Posts Replies Views Activity
2
Sep 23
2100
1
Dec 22
1079
3
Nov 22
2881
1
Nov 22
2930
1
May 22
2649