mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] Improved Unit Test Case and Fixed Travis
This commit is contained in:
committed by
ahenriquez
parent
0b707ea7fc
commit
e161a9c57a
@@ -9,7 +9,7 @@
|
|||||||
'category': 'RMA',
|
'category': 'RMA',
|
||||||
'summary': 'Introduces the return merchandise authorization (RMA) process '
|
'summary': 'Introduces the return merchandise authorization (RMA) process '
|
||||||
'in odoo',
|
'in odoo',
|
||||||
'author': "Eficent",
|
'author': "Eficent, Odoo Community Association (OCA)",
|
||||||
'website': 'http://www.github.com/OCA/rma',
|
'website': 'http://www.github.com/OCA/rma',
|
||||||
'depends': ['stock', 'mail', 'procurement'],
|
'depends': ['stock', 'mail', 'procurement'],
|
||||||
'demo': ['demo/stock_demo.xml',
|
'demo': ['demo/stock_demo.xml',
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ class RmaOrder(models.Model):
|
|||||||
res = self.env.ref('rma.view_rma_line_form', False)
|
res = self.env.ref('rma.view_rma_line_form', False)
|
||||||
else:
|
else:
|
||||||
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
||||||
|
|
||||||
result['views'] = [(res and res.id or False, 'form')]
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
result['res_id'] = lines.id
|
result['res_id'] = lines.id
|
||||||
return result
|
return result
|
||||||
@@ -181,13 +180,14 @@ class RmaOrder(models.Model):
|
|||||||
action = self.env.ref('rma.action_rma_supplier_lines')
|
action = self.env.ref('rma.action_rma_supplier_lines')
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
lines = self.rma_line_ids
|
lines = self.rma_line_ids
|
||||||
related_lines = [line.id for line in lines.supplier_rma_line_ids]
|
for line_id in lines:
|
||||||
# choose the view_mode accordingly
|
related_lines = [line.id for line in line_id.supplier_rma_line_ids]
|
||||||
if len(related_lines) != 1:
|
# choose the view_mode accordingly
|
||||||
result['domain'] = "[('id', 'in', " + \
|
if len(related_lines) != 1:
|
||||||
str(related_lines) + ")]"
|
result['domain'] = "[('id', 'in', " + \
|
||||||
elif len(related_lines) == 1:
|
str(related_lines) + ")]"
|
||||||
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
elif len(related_lines) == 1:
|
||||||
result['views'] = [(res and res.id or False, 'form')]
|
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
||||||
result['res_id'] = related_lines[0]
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
|
result['res_id'] = related_lines[0]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -372,21 +372,21 @@ class RmaOrderLine(models.Model):
|
|||||||
operation = self.env['rma.operation'].search(
|
operation = self.env['rma.operation'].search(
|
||||||
[('type', '=', self.type)], limit=1)
|
[('type', '=', self.type)], limit=1)
|
||||||
if not operation:
|
if not operation:
|
||||||
raise ValidationError("Please define an operation first.")
|
raise ValidationError(_("Please define an operation first."))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env['stock.location.route'].search(
|
route = self.env['stock.location.route'].search(
|
||||||
[('rma_selectable', '=', True)], limit=1)
|
[('rma_selectable', '=', True)], limit=1)
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError("Please define an RMA route.")
|
raise ValidationError(_("Please define an RMA route."))
|
||||||
|
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env['stock.warehouse'].search(
|
warehouse = self.env['stock.warehouse'].search(
|
||||||
[('company_id', '=', self.company_id.id),
|
[('company_id', '=', self.company_id.id),
|
||||||
('lot_rma_id', '!=', False)], limit=1)
|
('lot_rma_id', '!=', False)], limit=1)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError(
|
raise ValidationError(_(
|
||||||
"Please define a warehouse with a default RMA location.")
|
"Please define a warehouse with a default RMA location."))
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'product_id': sm.product_id.id,
|
'product_id': sm.product_id.id,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class TestRma(common.TransactionCase):
|
class TestRma(common.TransactionCase):
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ class TestRmaDropship(test_rma.TestRma):
|
|||||||
}).create({})
|
}).create({})
|
||||||
res = wizard.make_supplier_rma()
|
res = wizard.make_supplier_rma()
|
||||||
supplier_rma = self.rma.browse(res['res_id'])
|
supplier_rma = self.rma.browse(res['res_id'])
|
||||||
supplier_rma.action_rma_to_approve()
|
for line in supplier_rma.rma_line_ids:
|
||||||
supplier_rma.action_rma_approve()
|
line.action_rma_to_approve()
|
||||||
|
line.action_rma_approve()
|
||||||
wizard = self.rma_make_picking.with_context({
|
wizard = self.rma_make_picking.with_context({
|
||||||
'active_id': 1,
|
'active_id': 1,
|
||||||
'active_ids': supplier_rma.rma_line_ids.ids,
|
'active_ids': supplier_rma.rma_line_ids.ids,
|
||||||
@@ -89,3 +90,7 @@ class TestRmaDropship(test_rma.TestRma):
|
|||||||
"Wrong qty to supplier rma")
|
"Wrong qty to supplier rma")
|
||||||
self.assertEquals(line.qty_in_supplier_rma, 2,
|
self.assertEquals(line.qty_in_supplier_rma, 2,
|
||||||
"Wrong qty in supplier rma")
|
"Wrong qty in supplier rma")
|
||||||
|
for line in self.rma_droship_id.rma_line_ids:
|
||||||
|
line.action_rma_done()
|
||||||
|
self.assertEquals(line.state, 'done',
|
||||||
|
"Wrong State")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo.addons.rma.tests import test_rma
|
from . import test_rma
|
||||||
|
|
||||||
|
|
||||||
class TestSupplierRma(test_rma.TestRma):
|
class TestSupplierRma(test_rma.TestRma):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="procurement_form_view" model="ir.ui.view">
|
<record id="procurement_form_view_0" model="ir.ui.view">
|
||||||
<field name="name">procurement.order.form</field>
|
<field name="name">procurement.order.form</field>
|
||||||
<field name="model">procurement.order</field>
|
<field name="model">procurement.order</field>
|
||||||
<field name="inherit_id"
|
<field name="inherit_id"
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
'location_id': (operation.location_id.id or
|
'location_id': (operation.location_id.id or
|
||||||
operation.in_warehouse_id.lot_rma_id.id or
|
operation.in_warehouse_id.lot_rma_id.id or
|
||||||
warehouse.lot_rma_id.id)
|
warehouse.lot_rma_id.id)
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
elif item.line_id.partner_id:
|
elif item.line_id.partner_id:
|
||||||
delivery_address = item.line_id.partner_id
|
delivery_address = item.line_id.partner_id
|
||||||
else:
|
else:
|
||||||
raise ValidationError('Unknown delivery address')
|
raise ValidationError(_('Unknown delivery address'))
|
||||||
return delivery_address
|
return delivery_address
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -111,9 +111,9 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
warehouse = line.out_warehouse_id
|
warehouse = line.out_warehouse_id
|
||||||
route = line.out_route_id
|
route = line.out_route_id
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError("No route specified")
|
raise ValidationError(_("No route specified"))
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError("No warehouse specified")
|
raise ValidationError(_("No warehouse specified"))
|
||||||
procurement_data = {
|
procurement_data = {
|
||||||
'name': line.rma_id and line.rma_id.name or line.name,
|
'name': line.rma_id and line.rma_id.name or line.name,
|
||||||
'group_id': group.id,
|
'group_id': group.id,
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
'location_id': (operation.location_id.id or
|
'location_id': (operation.location_id.id or
|
||||||
operation.in_warehouse_id.lot_rma_id.id or
|
operation.in_warehouse_id.lot_rma_id.id or
|
||||||
warehouse.lot_rma_id.id)
|
warehouse.lot_rma_id.id)
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
Reference in New Issue
Block a user