mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] hr_expense_vendor: migrate to 14.0
This commit is contained in:
committed by
Jared Kipe
parent
a6c80c5097
commit
fceb12c4d0
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
'name': 'HR Expense Vendor',
|
'name': 'HR Expense Vendor',
|
||||||
'version': '13.0.1.0.0',
|
'version': '14.0.1.0.0',
|
||||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
'category': 'Human Resources',
|
'category': 'Human Resources',
|
||||||
'summary': 'Record the vendor paid on expenses.',
|
'summary': 'Record the vendor paid on expenses.',
|
||||||
|
|||||||
@@ -1,56 +1,59 @@
|
|||||||
from odoo.addons.hr_expense.tests.test_expenses import TestAccountEntry
|
from odoo.addons.hr_expense.tests.common import TestExpenseCommon
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tests import Form, tagged
|
||||||
|
|
||||||
|
|
||||||
class TestCheckVendor(TestAccountEntry):
|
@tagged('-at_install', 'post_install')
|
||||||
|
class TestCheckVendor(TestExpenseCommon):
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestCheckVendor, self).setUp()
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.vendor_id = self.env.ref('base.res_partner_3')
|
super(TestCheckVendor, cls).setUpClass(chart_template_ref=chart_template_ref)
|
||||||
|
cls.vendor_id = cls.env.ref('base.res_partner_3')
|
||||||
|
cls.tax = cls.env['account.tax'].create({
|
||||||
|
'name': 'Expense 10%',
|
||||||
|
'amount': 10,
|
||||||
|
'amount_type': 'percent',
|
||||||
|
'type_tax_use': 'purchase',
|
||||||
|
'price_include': True,
|
||||||
|
})
|
||||||
|
|
||||||
def test_journal_entry_vendor(self):
|
def test_journal_entry_vendor(self):
|
||||||
expense = self.env['hr.expense.sheet'].create({
|
expense_form = Form(self.env['hr.expense'])
|
||||||
'name': 'Expense for John Smith',
|
expense_form.name = 'Car Travel Expenses'
|
||||||
'employee_id': self.employee.id,
|
expense_form.employee_id = self.expense_employee
|
||||||
})
|
expense_form.product_id = self.product_a
|
||||||
expense_line = self.env['hr.expense'].create({
|
expense_form.unit_amount = 700.00
|
||||||
'name': 'Car Travel Expenses',
|
expense_form.tax_ids.clear()
|
||||||
'employee_id': self.employee.id,
|
expense_form.tax_ids.add(self.tax)
|
||||||
'product_id': self.product_expense.id,
|
expense_form.analytic_account_id = self.analytic_account_1
|
||||||
'unit_amount': 700.00,
|
expense_form.payment_mode = 'company_account'
|
||||||
'tax_ids': [(6, 0, [self.tax.id])],
|
expense = expense_form.save()
|
||||||
'sheet_id': expense.id,
|
|
||||||
'analytic_account_id': self.analytic_account.id,
|
|
||||||
})
|
|
||||||
expense.payment_mode = 'company_account'
|
|
||||||
expense_line.payment_mode = 'company_account'
|
|
||||||
expense_line._onchange_product_id()
|
|
||||||
|
|
||||||
# State should default to draft
|
action_submit_expenses = expense.action_submit_expenses()
|
||||||
self.assertEquals(expense.state, 'draft', 'Expense should be created in Draft state')
|
expense_sheet = self.env[action_submit_expenses['res_model']].browse(action_submit_expenses['res_id'])
|
||||||
# Submitted to Manager
|
|
||||||
expense.action_submit_sheet()
|
self.assertEqual(expense_sheet.state, 'submit', 'Expense is not in Submitted state')
|
||||||
self.assertEquals(expense.state, 'submit', 'Expense is not in Reported state')
|
|
||||||
# Approve
|
# Approve
|
||||||
expense.approve_expense_sheets()
|
expense_sheet.approve_expense_sheets()
|
||||||
self.assertEquals(expense.state, 'approve', 'Expense is not in Approved state')
|
self.assertEqual(expense_sheet.state, 'approve', 'Expense is not in Approved state')
|
||||||
# Create Expense Entries
|
# Create Expense Entries
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
expense.action_sheet_move_create()
|
expense_sheet.action_sheet_move_create()
|
||||||
|
|
||||||
expense_line.vendor_id = self.vendor_id
|
expense.vendor_id = self.vendor_id
|
||||||
expense.action_sheet_move_create()
|
expense_sheet.action_sheet_move_create()
|
||||||
self.assertEquals(expense.state, 'done')
|
self.assertEqual(expense_sheet.state, 'done')
|
||||||
self.assertTrue(expense.account_move_id.id, 'Expense Journal Entry is not created')
|
self.assertTrue(expense_sheet.account_move_id.id, 'Expense Journal Entry is not created')
|
||||||
|
|
||||||
# [(line.debit, line.credit, line.tax_line_id.id) for line in self.expense.expense_line_ids.account_move_id.line_ids]
|
# [(line.debit, line.credit, line.tax_line_id.id) for line in expense_sheet.account_move_id.line_ids]
|
||||||
# should git this result [(0.0, 700.0, False), (63.64, 0.0, 179), (636.36, 0.0, False)]
|
# should get this result [(0.0, 700.0, False), (63.64, 0.0, 179), (636.36, 0.0, False)]
|
||||||
for line in expense.account_move_id.line_ids:
|
for line in expense_sheet.account_move_id.line_ids:
|
||||||
if line.credit:
|
if line.credit:
|
||||||
self.assertEqual(line.partner_id, self.vendor_id)
|
self.assertEqual(line.partner_id, self.vendor_id)
|
||||||
self.assertAlmostEquals(line.credit, 700.00)
|
self.assertAlmostEqual(line.credit, 700.00)
|
||||||
else:
|
else:
|
||||||
if not line.tax_line_id == self.tax:
|
if not line.tax_line_id == self.tax:
|
||||||
self.assertAlmostEquals(line.debit, 636.36)
|
self.assertAlmostEqual(line.debit, 636.36)
|
||||||
else:
|
else:
|
||||||
self.assertAlmostEquals(line.debit, 63.64)
|
self.assertAlmostEqual(line.debit, 63.64)
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form"/>
|
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='name']" position="after">
|
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='name']" position="after">
|
||||||
<field name="vendor_id" domain="[('supplier', '=', True)]"
|
<field name="vendor_id" context="{'res_partner_search_mode': 'supplier'}" groups="account.group_account_user"/>
|
||||||
context="{'default_supplier': True}" groups="account.group_account_user"/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user