Skip to Content
Menu
This question has been flagged
1 Reply
2723 Views

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.

Avatar
Discard
Best Answer

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

       

   

   


Avatar
Discard
Related Posts Replies Views Activity
0
Jun 24
386
2
Jan 20
3913
0
Sep 23
1061
0
Nov 21
2099
0
Jun 21
2980