Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

How to validate required fields on CRM stage change?

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
validatechangestagecrm_leadodooV12
6 Trả lời
11314 Lượt xem
Ảnh đại diện
Muhammad Anees

Hii,

I have made some fields as required through xpath in xml on CRM Pipeline form. I dont want to set required in python.
When I change stage this validation dont apply. I tried on stage_id onchange function but crm.lead fields are not available.
I tried overriding write method, in this case when creating new lead in Kanban quick create dont work.

How to validate required fields on CRM stage change?

Thanks,

 


2
Ảnh đại diện
Huỷ bỏ
Ermin Trevisan

Please refrain from obviously boosting your own karma with your "fake" Q&A games, especially when your answers are questionable.

Muhammad Anees
Tác giả

twanda AG, Ermin Trevisan Switzerland, very disgraceful remarks. I am helping me and the community and for you its answer and question game?

Ảnh đại diện
Muhammad Anees
Tác giả Câu trả lời hay nhất

I done it by overriding the write() method. Here is the code.

class AbcCrmLead(models.Model):     
    _inherit = 'crm.lead' 
@api.multi
def write(self, values):
result = super(AbcCrmLead, self).write(values)
for record in self:
if not record.partner_id:
raise UserError(_('Customer is required'))
if not record.mobile:
raise UserError(_('Mobile is required'))
if record.stage_id.need_quotation and record.sale_number <= 0:
raise UserError(_('Opportunity with No Quotation can\'t be moved to %s stage. Please add quotation(s) to move to next stage.' % record.stage_id.name))
return result

The issue was when creating new opportunity from Kanban Quick Create Form. So I inherited the Kanban Quick Create Form and added required fields. 

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="abc_quick_create_opportunity_form" model="ir.ui.view">
<field name="name">abc.crm.lead.form.quick_create</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.quick_create_opportunity_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="required">1</attribute>
</xpath>
<xpath expr="//field[@name='partner_id']" position="after">
<field name="mobile" required="1"/>
<field name="date_deadline" required="1"/>
<field name="user_id" required="1"/>
<field name="team_id" required="1"/>
</xpath>
<xpath expr="//field[@name='planned_revenue']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='priority']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>

Now all validation is working by drag and drop from kanabn view, changing stage from form view.

4
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Sudhir Arya (ERP Harbor Consulting Services)
Câu trả lời hay nhất

You can use attrs to make the fields required based on condition.

Create a related name field of the stage_id and use it in the attrs.

stage_name = fields.Char(related='stage_id.name', string='Stage') # Create this field in the py file

<field name="stage_name" invisible="1"/>
<field name="field1" attrs="{'required': [('stage_name', '=', 'Draft')]}"/>


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

Thanks Arya,

<xpath expr="//field[@name='partner_id']" position="attributes">

<attribute name="attrs">{'required': [('stage_id.name', '=', 'New')]}</attribute>

</xpath>

Getting following error...

Error: Unknown field stage_id.name in domain

Sudhir Arya (ERP Harbor Consulting Services)

You need to create a related field of the stage name:

stage_name = fields.Char(related="stage_id.name", string='Stage Name')

<field name="stage_name" invisible="1"/>

<field name="field1" attrs="{'required': [('stage_name', '=', 'Draft')]}"/>

Muhammad Anees
Tác giả

I added the stage_name related field updated required domain as you said. But in following two cases validation dont apply.

1. Drag and Drop from kanban to next stage validation dont apply.

2. On the opportunity form, if I click on the next stage, opportunity stage changes to next and validation dont apply

3. On the opportunity form, if I edit and click on next stage, validation applied, on save also applied

I think solution id somewhere in the python code by overriding write method?

What you say Arya.

Sudhir Arya (ERP Harbor Consulting Services)

Ok in that case, you would need to override the write method, check the stage and the fields values in the vals dict, and raise exception as per your condition.

Muhammad Anees
Tác giả

Thanks Arya, your support was helpful.

Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
How can I send an email notification when a Document changes stage?
email notification change stage
Ảnh đại diện
Ảnh đại diện
1
thg 8 22
4261
edited invoice doesn't show the changes when printed
invoice validate print change edit
Ảnh đại diện
Ảnh đại diện
1
thg 3 15
6091
uniqe phone number odoo v15
crm_lead
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 8 24
245
uniqe phone number odoo v15
crm_lead
Ảnh đại diện
0
thg 8 24
12
Data Exceeded error while importing data in Odoo v12 Đã xử lý
odooV12
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
4
thg 5 24
8311
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now