mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of hr_expense_recruitment for 11.0
This commit is contained in:
1
hr_expense_recruitment/__init__.py
Normal file
1
hr_expense_recruitment/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
21
hr_expense_recruitment/__manifest__.py
Normal file
21
hr_expense_recruitment/__manifest__.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
'name': 'HR Expense Recruitment',
|
||||||
|
'version': '11.0.1.0.0',
|
||||||
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
|
'category': 'Human Resources',
|
||||||
|
'summary': 'Assign Recruitment to expenses for reporting.',
|
||||||
|
'description': """
|
||||||
|
Assign Recruitment to expenses for reporting.
|
||||||
|
""",
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'depends': [
|
||||||
|
'hr_expense',
|
||||||
|
'hr_recruitment',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/hr_expense_views.xml',
|
||||||
|
'views/hr_job_views.xml'
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
||||||
2
hr_expense_recruitment/models/__init__.py
Normal file
2
hr_expense_recruitment/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import hr_expense_job
|
||||||
|
from . import hr_job
|
||||||
7
hr_expense_recruitment/models/hr_expense_job.py
Normal file
7
hr_expense_recruitment/models/hr_expense_job.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class HRExpenseJob(models.Model):
|
||||||
|
_inherit = 'hr.expense'
|
||||||
|
|
||||||
|
job_id = fields.Many2one('hr.job', string='Job')
|
||||||
18
hr_expense_recruitment/models/hr_job.py
Normal file
18
hr_expense_recruitment/models/hr_job.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class HRJob(models.Model):
|
||||||
|
_inherit = 'hr.job'
|
||||||
|
|
||||||
|
company_currency = fields.Many2one('res.currency', string='Currency',
|
||||||
|
related='company_id.currency_id', readonly=True)
|
||||||
|
expense_total_amount = fields.Float(string='Expenses Total',
|
||||||
|
compute='_compute_expense_total_amount',
|
||||||
|
compute_sudo=True)
|
||||||
|
expense_ids = fields.One2many('hr.expense', 'job_id', string='Expenses')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('expense_ids.total_amount')
|
||||||
|
def _compute_expense_total_amount(self):
|
||||||
|
for job in self:
|
||||||
|
job.expense_total_amount = sum(job.expense_ids.mapped('total_amount'))
|
||||||
1
hr_expense_recruitment/tests/__init__.py
Normal file
1
hr_expense_recruitment/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_expenses
|
||||||
16
hr_expense_recruitment/tests/test_expenses.py
Normal file
16
hr_expense_recruitment/tests/test_expenses.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
|
class TestJobExpense(common.TransactionCase):
|
||||||
|
def test_fields(self):
|
||||||
|
job = self.env['hr.job'].create({'name': 'Test Job'})
|
||||||
|
expense = self.env['hr.expense'].create({
|
||||||
|
'name': 'Test Expense',
|
||||||
|
'product_id': self.env['product.product'].search([('can_be_expensed', '=', True)], limit=1).id,
|
||||||
|
'unit_amount': 34.0,
|
||||||
|
})
|
||||||
|
self.assertFalse(job.expense_ids)
|
||||||
|
self.assertEqual(job.expense_total_amount, 0.0)
|
||||||
|
expense.job_id = job
|
||||||
|
self.assertTrue(job.expense_ids)
|
||||||
|
self.assertEqual(job.expense_total_amount, 34.0)
|
||||||
24
hr_expense_recruitment/views/hr_expense_views.xml
Normal file
24
hr_expense_recruitment/views/hr_expense_views.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_hr_expense_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">hr.expense.form.inherit</field>
|
||||||
|
<field name="model">hr.expense</field>
|
||||||
|
<field name="inherit_id" ref="hr_expense.hr_expense_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='employee_id']" position="after">
|
||||||
|
<field name="job_id"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_hr_expense_filter_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">hr.expense.filter.inherit</field>
|
||||||
|
<field name="model">hr.expense</field>
|
||||||
|
<field name="inherit_id" ref="hr_expense.view_hr_expense_filter"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='product_id']" position="after">
|
||||||
|
<field name="job_id"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
19
hr_expense_recruitment/views/hr_job_views.xml
Normal file
19
hr_expense_recruitment/views/hr_job_views.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_hr_job_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">hr.job.form.inherit</field>
|
||||||
|
<field name="model">hr.job</field>
|
||||||
|
<field name="inherit_id" ref="hr.view_hr_job_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//sheet/div[@name='button_box']" position="inside">
|
||||||
|
<field name="company_currency" invisible="1"/>
|
||||||
|
<button name="%(hr_expense.hr_expense_actions_all)d" class="oe_stat_button" icon="fa-money" type="action" context="{'search_default_job_id': active_id}">
|
||||||
|
<div class="o_stat_info">
|
||||||
|
<field name="expense_total_amount" widget="monetary" nolabel="1" options="{'currency_field': 'company_currency'}"/>
|
||||||
|
<span class="o_stat_text"> Expenses</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user