mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
156 lines
6.1 KiB
Python
156 lines
6.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# Author: Yannick Vaucher
|
|
# Yanina Aular
|
|
# Copyright 2015 Vauxoo
|
|
# Copyright 2014 Camptocamp SA
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
from openerp.tests import common
|
|
|
|
|
|
class TestPickingCreation(common.TransactionCase):
|
|
|
|
""" Test the correct pickings are created by the wizard. """
|
|
|
|
def setUp(self):
|
|
super(TestPickingCreation, self).setUp()
|
|
|
|
self.wizard_make_picking = self.env['claim_make_picking.wizard']
|
|
claim = self.env['crm.claim']
|
|
|
|
self.product_id = self.env.ref('product.product_product_4')
|
|
|
|
self.partner_id = self.env.ref('base.res_partner_12')
|
|
|
|
self.customer_location_id = self.env.ref(
|
|
'stock.stock_location_customers')
|
|
|
|
sale_order_agrolait_demo = self.env.ref('sale.sale_order_1')
|
|
self.assertTrue(sale_order_agrolait_demo.invoice_ids,
|
|
"The Order Sale of Agrolait not have Invoice")
|
|
invoice_agrolait = sale_order_agrolait_demo.invoice_ids[0]
|
|
invoice_agrolait.\
|
|
signal_workflow('invoice_open')
|
|
|
|
# Create the claim with a claim line
|
|
self.claim_id = claim.create(
|
|
{
|
|
'name': 'TEST CLAIM',
|
|
'code': '/',
|
|
'claim_type': self.env.ref('crm_claim_type.'
|
|
'crm_claim_type_customer').id,
|
|
'delivery_address_id': self.partner_id.id,
|
|
'partner_id': self.env.ref('base.res_partner_2').id,
|
|
'invoice_id': invoice_agrolait.id,
|
|
})
|
|
self.claim_id.with_context({'create_lines': True}).\
|
|
_onchange_invoice_warehouse_type_date()
|
|
self.warehouse_id = self.claim_id.warehouse_id
|
|
|
|
def test_00_new_product_return(self):
|
|
"""Test wizard creates a correct picking for product return
|
|
|
|
"""
|
|
wizard = self.wizard_make_picking.with_context({
|
|
'active_id': self.claim_id.id,
|
|
'partner_id': self.partner_id.id,
|
|
'warehouse_id': self.warehouse_id.id,
|
|
'picking_type': 'in',
|
|
'product_return': True,
|
|
}).create({})
|
|
wizard.action_create_picking()
|
|
|
|
self.assertEquals(len(self.claim_id.picking_ids), 1,
|
|
"Incorrect number of pickings created")
|
|
picking = self.claim_id.picking_ids[0]
|
|
self.assertEquals(picking.location_id, self.customer_location_id,
|
|
"Incorrect source location")
|
|
self.assertEquals(picking.location_dest_id,
|
|
self.warehouse_id.lot_stock_id,
|
|
"Incorrect destination location")
|
|
|
|
def test_01_new_delivery(self):
|
|
"""Test wizard creates a correct picking for a new delivery
|
|
|
|
"""
|
|
|
|
wizardchangeproductqty = self.env['stock.change.product.qty']
|
|
wizard_chg_qty = wizardchangeproductqty.with_context({
|
|
'active_id': self.product_id.id,
|
|
}).create({
|
|
'product_id': self.product_id.id,
|
|
'new_quantity': 12,
|
|
})
|
|
|
|
wizard_chg_qty.change_product_qty()
|
|
|
|
wizard = self.wizard_make_picking.with_context({
|
|
'active_id': self.claim_id.id,
|
|
'partner_id': self.partner_id.id,
|
|
'warehouse_id': self.warehouse_id.id,
|
|
'picking_type': 'out',
|
|
}).create({})
|
|
wizard.action_create_picking()
|
|
|
|
self.assertEquals(len(self.claim_id.picking_ids), 1,
|
|
"Incorrect number of pickings created")
|
|
picking = self.claim_id.picking_ids[0]
|
|
|
|
self.assertEquals(picking.location_id, self.warehouse_id.lot_stock_id,
|
|
"Incorrect source location")
|
|
self.assertEquals(picking.location_dest_id, self.customer_location_id,
|
|
"Incorrect destination location")
|
|
|
|
def test_02_new_product_return(self):
|
|
"""Test wizard creates a correct picking for product return
|
|
|
|
"""
|
|
company = self.env.ref('base.main_company')
|
|
warehouse_obj = self.env['stock.warehouse']
|
|
warehouse_rec = \
|
|
warehouse_obj.search([('company_id',
|
|
'=', company.id)])[0]
|
|
wizard = self.wizard_make_picking.with_context({
|
|
'active_id': self.claim_id.id,
|
|
'partner_id': self.partner_id.id,
|
|
'warehouse_id': self.warehouse_id.id,
|
|
'picking_type': warehouse_rec.in_type_id.id,
|
|
}).create({})
|
|
wizard.action_create_picking()
|
|
|
|
self.assertEquals(len(self.claim_id.picking_ids), 1,
|
|
"Incorrect number of pickings created")
|
|
picking = self.claim_id.picking_ids[0]
|
|
|
|
self.assertEquals(picking.location_id, self.customer_location_id,
|
|
"Incorrect source location")
|
|
self.assertEquals(picking.location_dest_id,
|
|
self.warehouse_id.lot_stock_id,
|
|
"Incorrect destination location")
|
|
|
|
def test_copy(self):
|
|
new_claim = self.claim_id.copy()
|
|
self.assertNotEqual(new_claim.code, self.claim_id.code)
|
|
|
|
def test_mail_thread_recipient(self):
|
|
recipients = self.claim_id.message_get_suggested_recipients()
|
|
recipients = recipients[self.claim_id.id]
|
|
recipient_ids = [r[0] for r in recipients]
|
|
self.assertEqual(recipient_ids,
|
|
[self.claim_id.partner_id.id])
|