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

Hi,


class EmployeeTravelReqest(models.Model):
_name = 'hr.emp.travel.request'
_description = "Travel Request"
_inherit = ['mail.thread', 'mail.activity.mixin']

@api.multi
def hr_manager_user_ids_get(self):
self.ensure_one()
hr_group_ids = self.env.ref('hr.group_hr_manager').users.ids
self.hr_manager_user_ids = [(6, 0, hr_group_ids)]

user_id = fields.Many2one('res.users')
hr_manager_user_ids = fields.Many2many('res.users', compute="hr_manager_user_ids_get")

name = fields.Char(string="Name")
employee_id = fields.Many2one('hr.employee', string="Employee")
# related fields
department_id = fields.Many2one(related="employee_id.department_id", store=True)
company_id = fields.Many2one(related="employee_id.company_id", store=True)
parent_id = fields.Many2one(related="employee_id.parent_id", store=True)
job_id = fields.Many2one(related="employee_id.job_id", store=True)
grade_id = fields.Many2one(related="employee_id.grade_id", store=True)
currency_id = fields.Many2one(related="employee_id.company_id.currency_id", store=True)
# Travel Dates
from_date = fields.Date(string='From Date')
to_date = fields.Date(string='To Date')
expect_travel_days = fields.Integer(string="Days", compute="compute_days")
state = fields.Selection(
[('draft', 'Draft'), ('waiting', 'Waiting for confirmation'), ('confirmed', 'Confirmed'), ('approved', 'Approved'),
('closed', 'Closed'), ('rejected', 'Rejected'), ('canceled', 'Canceled')], default="draft", track_visibility="onchange")
# travel locations
travel_location_ids = fields.One2many('hr.emp.travel.location', 'travel_request_id_ref', required=True)
total_travel_days = fields.Integer(string="Days", compute="compute_days_travel_location")
# Expenses(proposed/actual)
expense_amount_ids = fields.One2many('hr.expense.amount', 'travel_request_id')
total_expense_amount = fields.Monetary(string="Grand Total", compute="compute_total_expense_amount", store=False)
ticket_book = fields.Boolean(string="Company Books ticket for You", track_visibility="onchange")
# Log
request_by = fields.Many2one('res.users', default=lambda self: self.env.uid)
approved_by = fields.Many2one('res.users')
rejected_by = fields.Many2one('res.users')
request_date = fields.Date(string="Requested Date", default=date.today())
approved_date = fields.Date()
rejected_date = fields.Date()
reject_reason = fields.Char("Reason For Reject")
# Reason
reason = fields.Text(string="Reason")
# Currency
currency_ids = fields.One2many('hr.travel.currency', 'travel_request_id')

# Expenses expenses_ids = fields.One2many('hr.expense', 'travel_request_id_ref'
@api.multi
def action_send_manager(self):
for rec in self:
if not rec.travel_location_ids:
raise Warning("Please enter the travel information before submit to manager")
else:
rec.state = 'waiting'

I get this error when I try to save more than one line in one2many field.


Thank you in advance for any help.



Avatar
Discard

Instead of sharing whole code, please check log and see which section throws the error, and please share it.
To understand single ton error in odoo and to learn its solution see: https://www.youtube.com/watch?v=Rv44nFVn_5U

you can check with one2many class(hr.emp.travel.location) like function, search, domain etc.

Related Posts Replies Views Activity
3
Oct 23
5981
1
Sep 23
1972
1
May 23
1005
2
Apr 23
1379
1
Mar 23
997