Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3536 Переглядів

I have created a table for Field service with one2many link to Timesheet. with 3 type of punch categories and i need to view them in separate notebook-page in form. 

class call_info(models.Model):
call_no=fields.Char("Call No")call_type=fields.Char("Call Type")call_timesheet_ids=fields.One2many('call.timesheet.info','call_id')

class Call_Timesheet(models.Model):
_name = "call.timesheet.info"
_rec_name="call_id"

call_id = fields.Many2one('cms.info.model')
task_id = fields.Char(related='call_id.task_no')
# punch_category=fields.Many2one('timepunch.category')

punch_category=fields.Selection([
('Callpunchin', 'Punch Time'),
('Equipmentfacetime', 'Equipment Facetime'),
('Labourtime', 'Labour Activity')], default='Callpunchin',store=1)
punch_type = fields.Char()
start_time = fields.Datetime()
end_time = fields.Datetime()
I am using the following view to display




The display works fine, but my requirement is to show all each punchin category in a separate page in same  form. Let me know how to do it



Аватар
Відмінити
Найкраща відповідь

According to my understanding, my suggestion is below:

1. Create 3 different pages under notebook and filter by punch category value in each page. Ref: https://www.odoo.com/forum/help-1/how-to-filter-fields-in-one2many-base-on-it-s-many2one-89978

2. Make default value in punch category of each page from view. Ref: https://www.odoo.com/forum/help-1/passing-default-value-to-form-view-118813

3. Make punch category readonly from view.

Hope it will work!

Аватар
Відмінити
Автор Найкраща відповідь

Thanks for the reply. But the context was not working in the views. I was not able to figure out why. so i have used the following .created another field and set a filter to it. it worked fine

call_labour_ids = fields.One2many('call.timesheet.info', 'call_id', compute='_get_labourevents_ids')
def _get_labourevents_ids(self):
self.call_labour_ids = self.call_timesheet_ids.search(['&',('punch_category', '=','Labourtime'),('call_id', '=',self.id)])

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
січ. 25
972
2
вер. 22
8695
0
лип. 21
6404
1
бер. 21
4327
5
серп. 20
18033