Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

Qweb templating (Python side) : Access survey_user_input model on survey template using t-field ?

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
pythonqwebcontrollerst-field
1 ตอบกลับ
11440 มุมมอง
อวตาร
TEIMI Yassine

Dears,

As you know t-field gives fields access via browsable record.

For the survey module, it's used on survey qweb template. For example, for the survey_init template (the first page of every started survey, describing survey title, and description) here is the code using t-field :

 <template id="survey_init" name="Survey"> 

<t t-call="website.layout">
<div class="wrap">
<div class="oe_structure" />
<div class="container">
<div groups="base.group_website_publisher" t-ignore="true" class="text-right">
<a href="/web#action=survey.action_survey_form" class="btn btn-default">Go back to su rveys</a>
</div>
<div class='jumbotron mt32'>
<h1 t-field='survey.title' />
<div t-field='survey.description' class="oe_no_empty"/>
<a class="btn btn-primary btn-lg" t-att-href="'/survey/fill/%s/%s' % (slug(survey ), token)">
Start Survey
</a>
</div>
</div>
<div class="oe_structure" />
</div>
</t>
</template>

So how this is can be done ?

Humble answer : After inspecting the controllers code, it's the start_survey() method that is responsible of launching the survey, it takes the variable survey as a parameter, and send it via data dictionnary trough : website.request.render, wich allows access survey fields value using t-field.

Here is the code part (For one page rendering case "test survey" among others) explainig that :

 @http.route(['/survey/start/<model("survey.survey"):survey>', 
'/survey/start/<model("survey.survey"):survey>/<string:token>'],

type='http', auth='public', website=True)
def start_survey(self, survey, token=None, **post):
cr, uid, context = request.cr, request.uid, request.context
    survey_obj = request.registry['survey.survey']
    user_input_obj = request.registry['survey.user_input']
    # Test mode
    if token and token == "phantom":
        _logger.info("[survey] Phantom mode")
        user_input_id = user_input_obj.create(cr, uid, {'survey_id': survey.id, 'test_entry': True}, context=context)
        user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
        data = {'survey': survey, 'page': None, 'token': user_input.token}
    return request.website.render('survey.survey_init', data)

My question here is how survey is passed as a parameter ? is it by using @route ?

If I know how to pass more parameters to start_survey(), then maybe I can pass a parameter named like "survey_user_input" trough data dictionnary, allowing me to use it on t-field.

NB:

I'm calling my survey from hr_evaluation_interview model from the hr_evaluation module.

Here is the method calling survey from hr_evaluation module (maybe I can use it to pass a parameter to start survey via context) :

 def action_start_survey(self, cr, uid, ids, context=None): 
''' Open the website page with the survey form '''
    trail = ""
    context = dict(context or {}, relative_url=True)
    if 'survey_token' in context:
        trail = "/" + context['survey_token']
    return {
        'type': 'ir.actions.act_url',
        'name': "Start Survey",
        'target': 'self',
        'url': self.read(cr, uid, ids, ['public_url'], context=context)[0]['public_url'] + trail
        }

I hope my question is clear, if not, I'm here for further explainations.

Many thanks for your help.

0
อวตาร
ละทิ้ง
อวตาร
Axel Mendoza
คำตอบที่ดีที่สุด

The argument survey is converted and passed by the @route decorator, converting the positional param of the url to a model object using a model argument pattern converter declared in the url param of the @route decorator and passed to the handle method of the url. 

See more here about that:

https://www.odoo.com/documentation/8.0/howtos/website.html#urls-and-routing

Specifically:

Odoo provides an additional converter called model which provides records directly when given their id. Let's use this to create a generic page for teacher biographies:

So you need to redefine the method and the @route url pattern and the method arguments to match the url pattern.

The url returned on the method action_start_survey need to match the @route url pattern so add the id value of the survey_user_input param to the url obtained from the field public_url or to the trail var, the thing is that the result url need to match the url for the @route overrided

1
อวตาร
ละทิ้ง
TEIMI Yassine
ผู้เขียน

Thanks a lot Axel for your explainations, I'm now trying to override : action_start_survey method called from hr_interview (I did'nt included it on my post), it's the first called method, that calls action_start_survey of the survey model. (So functionnaly speaking, it's like using action_start_survey for a human ressources evaluation purpose). Then I'll override action_start_survey of the survey module, and then override @route decorator and start_survey() method. I'll post my code, and further details soon. Thanks for your valuable help.

TEIMI Yassine
ผู้เขียน

Hi Axel, it worked : On the first action_start_survey (on hr_interview object) I had to pass a browsable record of it, using context, and then on action_start_survey(survey object), modify trail, and add slug(context['interview']) to the url, and finally on the start_survey() method override @route decorator and pass the parameter, then send it via data dictionnary to the qweb view, and it's ready to use. I have to do the same for print_survey() and fill_survey(). Thanks a lot Axel for your help.

Axel Mendoza

Happy to help

สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
What's the difference between t-esc and t-field in a report ? แก้ไขแล้ว
qweb t-field
อวตาร
อวตาร
อวตาร
3
ก.ค. 23
32681
Issue with a new Product Label Template (102x102) in Odoo V17
development python qweb
อวตาร
0
ธ.ค. 24
1847
passing values to the react using Controller
qweb controllers ReactJs
อวตาร
อวตาร
อวตาร
2
ธ.ค. 23
2418
Email template - list of followers
python qweb email
อวตาร
อวตาร
อวตาร
2
มิ.ย. 23
3232
My custom report is changing when user Configured the Document Layout แก้ไขแล้ว
python qweb v14
อวตาร
อวตาร
1
ม.ค. 23
3395
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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