diff --git a/odex25_hr/.idea/.gitignore b/odex25_hr/.idea/.gitignore new file mode 100644 index 000000000..26d33521a --- /dev/null +++ b/odex25_hr/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/odex25_hr/.idea/inspectionProfiles/profiles_settings.xml b/odex25_hr/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/odex25_hr/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/odex25_hr/.idea/misc.xml b/odex25_hr/.idea/misc.xml new file mode 100644 index 000000000..e86843da6 --- /dev/null +++ b/odex25_hr/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/odex25_hr/.idea/modules.xml b/odex25_hr/.idea/modules.xml new file mode 100644 index 000000000..12039e5ea --- /dev/null +++ b/odex25_hr/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/odex25_hr/.idea/odex25_hr.iml b/odex25_hr/.idea/odex25_hr.iml new file mode 100644 index 000000000..082498fdb --- /dev/null +++ b/odex25_hr/.idea/odex25_hr.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/odex25_hr/.idea/vcs.xml b/odex25_hr/.idea/vcs.xml new file mode 100644 index 000000000..6c0b86358 --- /dev/null +++ b/odex25_hr/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/odex25_hr/exp_official_mission/models/hr_official_mission.py b/odex25_hr/exp_official_mission/models/hr_official_mission.py index e061885f1..3fd844745 100644 --- a/odex25_hr/exp_official_mission/models/hr_official_mission.py +++ b/odex25_hr/exp_official_mission/models/hr_official_mission.py @@ -128,25 +128,15 @@ class HrOfficialMission(models.Model): rec.attachment_count = attachment.search_count([('res_model', '=', self._name), ('res_id', '=', rec.id)]) def action_get_attachment_view(self): - domain = ['&', ('res_model', '=', self._name), ('res_id', 'in', self.ids)] - res_id = self.ids and self.ids[0] or False - return { - 'name': _('Attachments'), - 'domain': domain, - 'res_model': 'ir.attachment', - 'type': 'ir.actions.act_window', - 'view_id': False, - 'view_mode': 'kanban,tree,form', - 'view_type': 'form', - 'help': _('''

- - Attach - documents of %s .

''' % (self._description)), - 'limit': 80, - 'context': "{'default_res_model': '%s','default_res_id': %d}" - % (self._name, res_id) + res = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') + res['domain'] = [('res_model', '=', 'hr.official.mission.employee'), ('res_id', 'in', self.employee_ids.ids)] + res['context'] = { + 'default_res_model': 'hr.official.mission.employee', + 'default_res_id': self.id, + 'create': False, + 'edit': False, } - + return res def get_user_id(self): @@ -670,6 +660,8 @@ class OfficialMissionAttach(models.Model): _inherit = 'ir.attachment' mission_id = fields.Many2one(comodel_name='hr.official.mission') + # employee_mission_id = fields.Many2one(comodel_name='hr.official.mission.employee') + class EmployeeCourseName(models.Model): diff --git a/odex25_hr/exp_official_mission/views/hr_official_mission.xml b/odex25_hr/exp_official_mission/views/hr_official_mission.xml index 28de4265b..8baa2f647 100644 --- a/odex25_hr/exp_official_mission/views/hr_official_mission.xml +++ b/odex25_hr/exp_official_mission/views/hr_official_mission.xml @@ -99,8 +99,7 @@ - + diff --git a/odex25_hr/exp_official_mission/views/training_menus.xml b/odex25_hr/exp_official_mission/views/training_menus.xml index 1acc4ac3b..ef3f93991 100644 --- a/odex25_hr/exp_official_mission/views/training_menus.xml +++ b/odex25_hr/exp_official_mission/views/training_menus.xml @@ -3,8 +3,7 @@ + parent="hr.menu_hr_root" sequence="3"/> 0.0: + debit_line_vals = { + 'name': item.employee_id.name + ' in official mission "%s" ' % self.mission_type.name, + 'debit': item.amount, + 'account_id': self.mission_type.account_id.id, + 'partner_id': item.employee_id.user_id.partner_id.id + } + credit_line_vals = { + 'name': item.employee_id.name + ' in official mission "%s" ' % self.mission_type.name, + 'credit': item.amount, + 'account_id': self.mission_type.journal_id.default_account_id.id, + 'partner_id': item.employee_id.user_id.partner_id.id + } + move = self.env['account.move'].create({ + 'state': 'draft', + 'journal_id': self.mission_type.journal_id.id, + 'date': date.today(), + 'ref': 'Official mission for employee "%s" ' % item.employee_id.name, + 'line_ids': [(0, 0, debit_line_vals), (0, 0, credit_line_vals)] + }) + # fill account move for each employee + item.write({'account_move_id': move.id}) + else: + raise exceptions.Warning( + _('You do not have account or journal in mission type "%s" ') % self.mission_type.name) + + # move amounts to advantages of employee in contract + elif self.move_type == 'payroll': + # get start and end date of the current month + current_date = date.today() + month_start = date(current_date.year, current_date.month, 1) + month_end = date(current_date.year, current_date.month, calendar.mdays[current_date.month]) + for line in self.employee_ids: + if line.employee_id.contract_id: + + advantage_arc = line.env['contract.advantage'].create({ + 'benefits_discounts': self.official_mission.id, + 'date_from': month_start, + 'date_to': month_end, + 'amount': line.amount, + 'official_mission_id': True, + 'employee_id': line.employee_id.id, + 'contract_advantage_id': line.employee_id.contract_id.id, + 'out_rule': True, + 'state': 'confirm', + 'comments': self.mission_purpose}) + line.advantage_id = advantage_arc.id + + print(advantage_arc,"the type is payroll advantage created>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + else: + raise exceptions.Warning(_( + 'Employee "%s" has no contract Please create contract to add line to advantages') + % line.employee_id.name) + + for item in self: + # create ticket request from all employee + if item.issuing_ticket == 'yes': + for emp in item.employee_ids: + ticket = self.env['hr.ticket.request'].create({ + 'employee_id': emp.employee_id.id, + 'mission_request_id': item.id, + 'mission_check': True, + 'request_for': item.ticket_cash_request_for, + 'request_type': item.ticket_cash_request_type.id, + 'cost_of_tickets': item.get_ticket_cost(emp.employee_id), + 'destination': item.destination.id, + }) + item.write({'ticket_request_id': ticket.id}) + + # move invoice training cost our trining center + if item.Training_cost > 0: + invoice_line_vals = { + 'name': 'Training Cost for Course Name %s Training Center %s' % ( + item.course_name.name, item.partner_id.name), + 'price_unit': item.Training_cost, + # 'account_id': self.mission_type.journal_id.default_credit_account_id.id, + 'account_id': item.partner_id.property_account_payable_id.id, + # 'partner_id': item.employee_id.user_id.partner_id.id + } + invoice = self.env['account.move'].create({ + 'state': 'draft', + 'move_type': 'in_invoice', + 'journal_id': item.mission_type.journal_id.id, + 'partner_id': item.partner_id.id, + 'invoice_date': date.today(), + 'ref': 'Training Cost for Course Name %s ' % item.course_name.name, + 'invoice_line_ids': [(0, 0, invoice_line_vals)] + }) + item.write({'Tra_cost_invo_id': invoice.id}) + + self.state = "approve" + if self.mission_type.work_state and self.mission_type.duration_type == 'days': + for emp in self.employee_ids: + if emp.date_to >= fields.Date.today() >= emp.date_from: + emp.employee_id.write({'work_state': self.mission_type.work_state, 'active_mission_id': emp.id}) + self.call_cron_function() + + diff --git a/odex25_hr/hr_training_payment/models/mission_type.py b/odex25_hr/hr_training_payment/models/mission_type.py new file mode 100644 index 000000000..ee2328759 --- /dev/null +++ b/odex25_hr/hr_training_payment/models/mission_type.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api + + +class HrOfficialMissionType(models.Model): + _inherit = 'hr.official.mission.type' + pr_product_id = fields.Many2one(comodel_name='product.product', string="PR Product") + diff --git a/odex25_hr/hr_training_payment/views/hr_official_mission.xml b/odex25_hr/hr_training_payment/views/hr_official_mission.xml new file mode 100644 index 000000000..17e9dd990 --- /dev/null +++ b/odex25_hr/hr_training_payment/views/hr_official_mission.xml @@ -0,0 +1,23 @@ + + + + + + + hr.official.mission.view.form + hr.official.mission + + + + + + + + True + + + + + + + diff --git a/odex25_hr/hr_training_payment/views/mission_type.xml b/odex25_hr/hr_training_payment/views/mission_type.xml new file mode 100644 index 000000000..b77937c1a --- /dev/null +++ b/odex25_hr/hr_training_payment/views/mission_type.xml @@ -0,0 +1,19 @@ + + + + + + + hr.official.mission.type.view.form + hr.official.mission.type + + + + + + + + + + +