Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2909 Lượt xem


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!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
3998
1
thg 12 22
2253
3
thg 11 22
4509
1
thg 11 22
4792
1
thg 5 22
4099