mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-21 14:22:02 +02:00
Initial commit: Accounting packages
This commit is contained in:
commit
4ef34c2317
2661 changed files with 1709616 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import test_fleet_log_services
|
||||
from . import test_account_fleet
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
from freezegun import freeze_time
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.tests import tagged, Form
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAccountFleet(AccountTestInvoicingCommon):
|
||||
|
||||
@freeze_time('2021-09-15')
|
||||
def test_transfer_wizard_vehicle_info_propagation(self):
|
||||
brand = self.env["fleet.vehicle.model.brand"].create({
|
||||
"name": "Audi",
|
||||
})
|
||||
model = self.env["fleet.vehicle.model"].create({
|
||||
"brand_id": brand.id,
|
||||
"name": "A3",
|
||||
})
|
||||
car_1 = self.env["fleet.vehicle"].create({
|
||||
"model_id": model.id,
|
||||
"plan_to_change_car": False
|
||||
})
|
||||
|
||||
bill = self.init_invoice('in_invoice', products=self.product_a, invoice_date='2021-09-01', post=False)
|
||||
bill.invoice_line_ids.write({'vehicle_id': car_1.id})
|
||||
bill.action_post()
|
||||
|
||||
context = {'active_model': 'account.move.line', 'active_ids': bill.invoice_line_ids.ids}
|
||||
expense_account = self.company_data['default_account_expense']
|
||||
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
|
||||
wizard_form.action = 'change_period'
|
||||
wizard_form.date = '2021-09-15'
|
||||
wizard_form.expense_accrual_account = expense_account
|
||||
wizard_form.journal_id = bill.journal_id
|
||||
wizard = wizard_form.save()
|
||||
|
||||
result_action = wizard.do_action()
|
||||
transfer_moves = self.env['account.move'].search(result_action['domain'])
|
||||
self.assertEqual(transfer_moves.line_ids.filtered(lambda l: l.account_id == expense_account).vehicle_id, car_1, "Vehicle info is missing")
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.tests import common, tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestFleetLogServices(AccountTestInvoicingCommon, common.TransactionCase):
|
||||
|
||||
def test_fleet_log_services_amount(self):
|
||||
brand = self.env["fleet.vehicle.model.brand"].create({
|
||||
"name": "Audi",
|
||||
})
|
||||
model = self.env["fleet.vehicle.model"].create({
|
||||
"brand_id": brand.id,
|
||||
"name": "A3",
|
||||
})
|
||||
car = self.env["fleet.vehicle"].create({
|
||||
"model_id": model.id,
|
||||
"plan_to_change_car": False
|
||||
})
|
||||
|
||||
partner = self.env['res.partner'].create({
|
||||
"name": "Test Partner",
|
||||
})
|
||||
|
||||
move = self.env['account.move'].create({
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': partner.id,
|
||||
'invoice_date': '2019-01-01',
|
||||
'date': '2019-01-01',
|
||||
'currency_id': self.env.ref('base.EUR').id,
|
||||
'line_ids': [
|
||||
(0, 0, {
|
||||
'currency_id': self.currency_data['currency'].id,
|
||||
'account_id': self.company_data['default_account_expense'].id,
|
||||
'vehicle_id': car.id,
|
||||
'quantity': 1,
|
||||
'price_unit': 5000
|
||||
})
|
||||
],
|
||||
})
|
||||
move.action_post()
|
||||
line = move.line_ids[0]
|
||||
fleet_service = self.env['fleet.vehicle.log.services'].search([('vendor_id', '=', partner.id),
|
||||
('description', '=', False)])
|
||||
|
||||
self.assertNotEqual(line.debit, line.price_subtotal)
|
||||
self.assertEqual(fleet_service.amount, line.debit)
|
||||
Loading…
Add table
Add a link
Reference in a new issue