[FIX]rma_analytic tests

This commit is contained in:
aheficent
2018-10-31 18:06:57 +01:00
committed by Aaron ForgeFlow
parent 3288021d8d
commit 7b119f8872

View File

@@ -2,22 +2,39 @@
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo.addons.rma.tests import test_rma
from odoo.tests import common
class TestRmaAnalytic(test_rma.TestRma):
class TestRmaAnalytic(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestRmaAnalytic, cls).setUpClass()
products2move = [(cls.product_1, 3), (cls.product_2, 5),
(cls.product_3, 2)]
analytic_1 = cls.env['account.analytic.account'].create({
cls.stock_picking_model = cls.env['stock.picking']
cls.rma_line_model = cls.env['rma.order.line']
cls.rma_model = cls.env['rma.order']
cls.rma_add_stock_move = cls.env['rma_add_stock_move']
cls.stock_location = cls.env.ref('stock.stock_location_stock')
cls.product_1 = cls.env.ref('product.product_product_25')
cls.customer_location = cls.env.ref(
'stock.stock_location_customers')
cls.product_uom_id = cls.env.ref('product.product_uom_unit')
products2move = [(cls.product_1, 3), ]
cls.analytic_1 = cls.env['account.analytic.account'].create({
'name': 'Test account #1',
})
cls.partner_id = cls.env.ref('base.res_partner_1')
cls.rma_ana_id = cls._create_rma_analytic(
products2move, 'supplier', cls.env.ref('base.res_partner_1'),
analytic=analytic_1)
products2move, cls.partner_id)
@classmethod
def _create_picking(cls, partner):
return cls.stock_picking_model.create({
'partner_id': partner.id,
'picking_type_id': cls.env.ref('stock.picking_type_in').id,
'location_id': cls.stock_location.id,
'location_dest_id': cls.customer_location.id
})
@classmethod
def _prepare_anal_move(cls, product, qty, src, dest, picking_in, analytic):
@@ -37,59 +54,38 @@ class TestRmaAnalytic(test_rma.TestRma):
return res
@classmethod
def _create_rma_analytic(cls, products2move, type, partner, analytic):
def _create_rma_analytic(cls, products2move, partner):
picking_in = cls._create_picking(partner)
moves = []
for item in products2move:
move_values = cls._prepare_anal_move(
item[0], item[1], cls.supplier_location,
cls.stock_rma_location, picking_in, analytic)
item[0], item[1], cls.stock_location,
cls.customer_location, picking_in, cls.analytic_1)
moves.append(cls.env['stock.move'].create(move_values))
# Create the RMA from the stock_move
rma_id = cls.rma.create(
rma_id = cls.rma_model.create(
{
'reference': '0001',
'type': type,
'type': 'customer',
'partner_id': partner.id,
'company_id': cls.env.ref('base.main_company').id
})
for move in moves:
wizard = cls.rma_add_stock_move.with_context(
{'stock_move_id': move.id, 'supplier': True,
{'stock_move_id': move.id, 'customer': True,
'active_ids': rma_id.id,
'active_model': 'rma.order',
}
).create({'rma_id': rma_id.id,
'partner_id': partner.id})
).create({})
data = wizard._prepare_rma_line_from_stock_move(move)
wizard.add_lines()
wizard = cls.rma_add_stock_move.with_context(
{'stock_move_id': move.id, 'supplier': True,
'active_ids': [],
'active_model': 'rma.order',
}
).create({})
wizard.add_lines()
wizard.add_lines()
for operation in move.product_id.rma_customer_operation_id:
operation.in_route_id = False
move.product_id.categ_id.rma_customer_operation_id = False
move.product_id.rma_customer_operation_id = False
wizard._prepare_rma_line_from_stock_move(move)
wizard.add_lines()
cls.line = cls.rma_line.create(data)
# approve the RMA Line
cls.line.action_rma_to_approve()
cls.line.action_rma_approve()
rma_id._get_default_type()
rma_id._compute_in_shipment_count()
rma_id._compute_out_shipment_count()
rma_id._compute_supplier_line_count()
rma_id._compute_line_count()
rma_id.action_view_in_shipments()
rma_id.action_view_out_shipments()
rma_id.action_view_lines()
rma_id.partner_id.action_open_partner_rma()
rma_id.partner_id._compute_rma_line_count()
cls.line = cls.rma_line_model.create(data)
return rma_id
def test_analytic(cls):