-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] hr_expense_event_commute: pre-commit stuff
- Loading branch information
Showing
6 changed files
with
84 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
'name': "Hr Expense Event Commute", | ||
'version': '14.0.1.0.0', | ||
'author': 'AvanzOSC', | ||
'website': 'http://www.avanzosc.es', | ||
'category': 'Marketing/Events', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'hr_expense_from_analytic', | ||
'event_commute', | ||
"name": "Hr Expense Event Commute", | ||
"version": "14.0.1.0.0", | ||
"author": "AvanzOSC", | ||
"website": "https://github.com/avanzosc/hr-addons", | ||
"category": "Marketing/Events", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"hr_expense_from_analytic", | ||
"event_commute", | ||
], | ||
'data': [ | ||
'views/event_view.xml' | ||
"data": [ | ||
"views/event_view.xml", | ||
], | ||
'installable': True, | ||
'auto_install': True, | ||
"installable": True, | ||
"auto_install": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class EventTrack(models.Model): | ||
_inherit = 'event.track' | ||
_inherit = "event.track" | ||
|
||
hr_expense_ids = fields.One2many( | ||
string='Expenses', comodel_name='hr.expense', inverse_name='track_id') | ||
string="Expenses", | ||
comodel_name="hr.expense", | ||
inverse_name="track_id", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class HrExpense(models.Model): | ||
_inherit = 'hr.expense' | ||
_inherit = "hr.expense" | ||
|
||
track_id = fields.Many2one( | ||
string='Event track', comodel_name='event.track') | ||
string="Event track", | ||
comodel_name="event.track", | ||
) |
84 changes: 50 additions & 34 deletions
84
hr_expense_event_commute/tests/test_hr_expense_event_commute.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,64 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo.tests import common, tagged | ||
from odoo import fields | ||
from odoo.tests import common, tagged | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestHrExpenseEventCommute(common.SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestHrExpenseEventCommute, cls).setUpClass() | ||
cls.uom_unit = cls.env.ref('uom.product_uom_unit') | ||
cls.product = cls.env['product.product'].create({ | ||
'name': 'Product Hr Expense Event With Commute', | ||
'default_code': 'PHEEWC', | ||
'uom_id': cls.uom_unit.id, | ||
'uom_po_id': cls.uom_unit.id, | ||
'type': 'service', | ||
'can_be_expensed': True}) | ||
vals = {'name': 'User Hr Expense Event With Commute', | ||
'login': '[email protected]'} | ||
cls.user = cls.env['res.users'].create(vals) | ||
vals = {'name': 'Employee Hr Expense Event With Commute', | ||
'user_id': cls.user.id} | ||
cls.employee = cls.env['hr.employee'].create(vals) | ||
cls.analytic_account = cls.env['account.analytic.account'].create({ | ||
'name': 'Analytic Hr Expense Event With Commute', | ||
'partner_id': cls.user.partner_id.id}) | ||
cls.track = cls.env['event.track'].search([], limit=1) | ||
cls.uom_unit = cls.env.ref("uom.product_uom_unit") | ||
cls.product = cls.env["product.product"].create( | ||
{ | ||
"name": "Product Hr Expense Event With Commute", | ||
"default_code": "PHEEWC", | ||
"uom_id": cls.uom_unit.id, | ||
"uom_po_id": cls.uom_unit.id, | ||
"type": "service", | ||
"can_be_expensed": True, | ||
} | ||
) | ||
vals = { | ||
"name": "User Hr Expense Event With Commute", | ||
"login": "[email protected]", | ||
} | ||
cls.user = cls.env["res.users"].create(vals) | ||
vals = { | ||
"name": "Employee Hr Expense Event With Commute", | ||
"user_id": cls.user.id, | ||
} | ||
cls.employee = cls.env["hr.employee"].create(vals) | ||
cls.analytic_account = cls.env["account.analytic.account"].create( | ||
{ | ||
"name": "Analytic Hr Expense Event With Commute", | ||
"partner_id": cls.user.partner_id.id, | ||
} | ||
) | ||
cls.track = cls.env["event.track"].search([], limit=1) | ||
|
||
def test_hr_expense_event_commute(self): | ||
vals = { | ||
'account_id': self.analytic_account.id, | ||
'name': 'Analitic Line Sale Expense From Analytic', | ||
'date': fields.Date.today(), | ||
'amount': 222, | ||
'partner_id': self.user.partner_id.id, | ||
'product_id': self.product.id} | ||
analytic_line = self.env['account.analytic.line'].with_context( | ||
default_track_id=self.track).create(vals) | ||
cond = [('name', '=', analytic_line.name), | ||
('date', '=', analytic_line.date), | ||
('quantity', '=', 1), | ||
('product_id', '=', self.product.id), | ||
('employee_id', '=', self.employee.id), | ||
('track_id', '=', self.track.id)] | ||
hr_expense = self.env['hr.expense'].search(cond, limit=1) | ||
"account_id": self.analytic_account.id, | ||
"name": "Analitic Line Sale Expense From Analytic", | ||
"date": fields.Date.today(), | ||
"amount": 222, | ||
"partner_id": self.user.partner_id.id, | ||
"product_id": self.product.id, | ||
} | ||
analytic_line = ( | ||
self.env["account.analytic.line"] | ||
.with_context(default_track_id=self.track) | ||
.create(vals) | ||
) | ||
cond = [ | ||
("name", "=", analytic_line.name), | ||
("date", "=", analytic_line.date), | ||
("quantity", "=", 1), | ||
("product_id", "=", self.product.id), | ||
("employee_id", "=", self.employee.id), | ||
("track_id", "=", self.track.id), | ||
] | ||
hr_expense = self.env["hr.expense"].search(cond, limit=1) | ||
self.assertEqual(len(hr_expense), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters