Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4216 มุมมอง

Hello. I have 2 models, appointment.order and report.appointment.order. In appointment.order I have 1 field that I want to show or use in the pivot table (the model for the pivot table is report. appointment.order).


Here's my python code in appointment.order:


from odoo import api, fields, models, _

class AppointmentOrder(models.Model):
    _inherit = 'appointment.order'
    
    time= fields.Float('Time')


In the XML files, I use the float_time widget for the time field.


I need to use the time field in report. appointment.order so I can show the time field in pivot table, but I don't know how to do that since the model is different. Does anyone know how to do that? 


Thank you.

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

Hello @Ori J, You can try this code,


In report py file


# -- coding: utf-8 --


from odoo import models, fields, api


from functools import lru_cache



class ReportAppointmentOrder(models.Model):

    _name = "report.appointment.order"

    _description = "Appointment Analysis"

    _auto = False


    time= fields.Float('Time', readonly=True)


    @property

    def _table_query(self):

        return '%s %s' % (self._select(), self._from())


    @api.model

    def _select(self):

        return '''

            SELECT

              order.id,

            order.time

           '''


    @api.model

    def _from(self):

        return '''

        FROM appointment_order order

        '''


In Report xml file,


    report.appointment.order.pivot

    report.appointment.order

   

   Somehow, I am not able to add the complete code. Have a look at the screenshot:

https://prnt.sc/0C3AqTyCnYnd

       

   

   


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 25
1422
2
ม.ค. 20
4827
0
มี.ค. 25
2440
0
พ.ย. 21
3017
0
มิ.ย. 21
4015