跳至内容
菜单
此问题已终结
1 回复
2890 查看


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!

形象
丢弃
最佳答案

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

形象
丢弃
编写者

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

相关帖文 回复 查看 活动
2
9月 23
3889
1
12月 22
2176
3
11月 22
4422
1
11月 22
4699
1
5月 22
4022