Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2900 Widoki


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!

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 23
3902
1
gru 22
2191
3
lis 22
4442
1
lis 22
4724
1
maj 22
4038