mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP]delivery_policy based on repair quantities
[IMP]better repair icons
This commit is contained in:
committed by
JasminSForgeFlow
parent
0a13de623d
commit
a0ec3460d7
@@ -11,3 +11,5 @@ class RmaOperation(models.Model):
|
|||||||
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
||||||
('received', 'Based on Received Quantities')],
|
('received', 'Based on Received Quantities')],
|
||||||
string="Repair Policy", default='no')
|
string="Repair Policy", default='no')
|
||||||
|
delivery_policy = fields.Selection(selection_add=[
|
||||||
|
('repair', 'Based on Repair Quantities')])
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ class RmaOrderLine(models.Model):
|
|||||||
repair_count = fields.Integer(
|
repair_count = fields.Integer(
|
||||||
compute='_compute_repair_count', string='# of Repairs')
|
compute='_compute_repair_count', string='# of Repairs')
|
||||||
|
|
||||||
|
delivery_policy = fields.Selection(selection_add=[
|
||||||
|
('repair', 'Based on Repair Quantities')])
|
||||||
|
qty_to_deliver = fields.Float(
|
||||||
|
compute='_compute_qty_to_deliver')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_repair_order(self):
|
def action_view_repair_order(self):
|
||||||
action = self.env.ref('repair.action_repair_order_tree')
|
action = self.env.ref('repair.action_repair_order_tree')
|
||||||
@@ -80,3 +85,21 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
qty += repair_qty
|
qty += repair_qty
|
||||||
return qty
|
return qty
|
||||||
|
|
||||||
|
@api.onchange('operation_id')
|
||||||
|
def _onchange_operation_id(self):
|
||||||
|
result = super(RmaOrderLine, self)._onchange_operation_id()
|
||||||
|
if self.operation_id:
|
||||||
|
self.repair_type = self.operation_id.repair_type or 'no'
|
||||||
|
return result
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('move_ids', 'move_ids.state',
|
||||||
|
'delivery_policy', 'product_qty', 'type', 'qty_delivered',
|
||||||
|
'qty_received', 'repair_ids', 'repair_type',
|
||||||
|
'repair_ids.state')
|
||||||
|
def _compute_qty_to_deliver(self):
|
||||||
|
res = super(RmaOrderLine, self)._compute_qty_to_deliver()
|
||||||
|
for rec in self.filtered(lambda l: l.delivery_policy == 'repair'):
|
||||||
|
rec.qty_to_deliver = rec.qty_repaired - rec.qty_delivered
|
||||||
|
return res
|
||||||
|
|||||||
@@ -50,7 +50,16 @@ class TestRmaRepair(common.SingleTransactionCase):
|
|||||||
'in_route_id': cls.rma_route_cust.id,
|
'in_route_id': cls.rma_route_cust.id,
|
||||||
'out_route_id': cls.rma_route_cust.id,
|
'out_route_id': cls.rma_route_cust.id,
|
||||||
})
|
})
|
||||||
|
cls.operation_3 = cls.rma_op.create({
|
||||||
|
'code': 'TEST',
|
||||||
|
'name': 'Deliver after repair',
|
||||||
|
'type': 'customer',
|
||||||
|
'receipt_policy': 'ordered',
|
||||||
|
'repair_type': 'ordered',
|
||||||
|
'delivery_policy': 'repair',
|
||||||
|
'in_route_id': cls.rma_route_cust.id,
|
||||||
|
'out_route_id': cls.rma_route_cust.id,
|
||||||
|
})
|
||||||
# Create products
|
# Create products
|
||||||
cls.product_1 = cls.product_obj.create({
|
cls.product_1 = cls.product_obj.create({
|
||||||
'name': 'Test Product 1',
|
'name': 'Test Product 1',
|
||||||
@@ -64,7 +73,12 @@ class TestRmaRepair(common.SingleTransactionCase):
|
|||||||
'list_price': 150.0,
|
'list_price': 150.0,
|
||||||
'rma_customer_operation_id': cls.operation_2.id,
|
'rma_customer_operation_id': cls.operation_2.id,
|
||||||
})
|
})
|
||||||
|
cls.product_3 = cls.product_obj.create({
|
||||||
|
'name': 'Test Product 3',
|
||||||
|
'type': 'product',
|
||||||
|
'list_price': 1.0,
|
||||||
|
'rma_customer_operation_id': cls.operation_3.id,
|
||||||
|
})
|
||||||
# Create Invoices:
|
# Create Invoices:
|
||||||
customer_account = cls.acc_obj.search(
|
customer_account = cls.acc_obj.search(
|
||||||
[('user_type_id', '=', receivable_type.id)], limit=1).id
|
[('user_type_id', '=', receivable_type.id)], limit=1).id
|
||||||
@@ -91,6 +105,24 @@ class TestRmaRepair(common.SingleTransactionCase):
|
|||||||
'uom_id': cls.product_2.uom_id.id,
|
'uom_id': cls.product_2.uom_id.id,
|
||||||
'account_id': customer_account,
|
'account_id': customer_account,
|
||||||
})
|
})
|
||||||
|
cls.inv_customer2 = cls.inv_obj.create({
|
||||||
|
'partner_id': customer1.id,
|
||||||
|
'account_id': customer_account,
|
||||||
|
'type': 'out_invoice',
|
||||||
|
})
|
||||||
|
cls.inv_line_3 = cls.invl_obj.create({
|
||||||
|
'name': cls.product_3.name,
|
||||||
|
'product_id': cls.product_3.id,
|
||||||
|
'quantity': 1.0,
|
||||||
|
'price_unit': 1000.0,
|
||||||
|
'invoice_id': cls.inv_customer2.id,
|
||||||
|
'uom_id': cls.product_3.uom_id.id,
|
||||||
|
'account_id': customer_account,
|
||||||
|
})
|
||||||
|
cls.rma_group_customer_2 = cls.rma_obj.create({
|
||||||
|
'partner_id': customer1.id,
|
||||||
|
'type': 'customer',
|
||||||
|
})
|
||||||
|
|
||||||
def test_01_add_from_invoice_customer(self):
|
def test_01_add_from_invoice_customer(self):
|
||||||
"""Test wizard to create RMA from a customer invoice."""
|
"""Test wizard to create RMA from a customer invoice."""
|
||||||
@@ -152,3 +184,32 @@ class TestRmaRepair(common.SingleTransactionCase):
|
|||||||
self.assertEqual(rma.repair_count, 1)
|
self.assertEqual(rma.repair_count, 1)
|
||||||
self.assertEqual(rma.qty_to_repair, 0.0)
|
self.assertEqual(rma.qty_to_repair, 0.0)
|
||||||
self.assertEqual(rma.qty_repaired, 15.0)
|
self.assertEqual(rma.qty_repaired, 15.0)
|
||||||
|
|
||||||
|
def test_04_deliver_after_repair(self):
|
||||||
|
"""Only deliver after repair"""
|
||||||
|
add_inv = self.rma_add_invoice_wiz.with_context({
|
||||||
|
'customer': True,
|
||||||
|
'active_ids': self.rma_group_customer_2.id,
|
||||||
|
'active_model': 'rma.order',
|
||||||
|
}).create({
|
||||||
|
'invoice_line_ids':
|
||||||
|
[(6, 0, self.inv_customer2.invoice_line_ids.ids)],
|
||||||
|
})
|
||||||
|
add_inv.add_lines()
|
||||||
|
rma = self.rma_group_customer_2.rma_line_ids.filtered(
|
||||||
|
lambda r: r.product_id == self.product_3)
|
||||||
|
rma.operation_id = self.operation_3.id
|
||||||
|
rma._onchange_operation_id()
|
||||||
|
rma.action_rma_to_approve()
|
||||||
|
rma.action_rma_approve()
|
||||||
|
self.assertEqual(rma.qty_to_deliver, 0.0)
|
||||||
|
make_repair = self.rma_make_repair_wiz.with_context({
|
||||||
|
'customer': True,
|
||||||
|
'active_ids': rma.ids,
|
||||||
|
'active_model': 'rma.order.line',
|
||||||
|
}).create({
|
||||||
|
'description': 'Test deliver',
|
||||||
|
})
|
||||||
|
make_repair.make_repair_order()
|
||||||
|
rma.repair_ids.action_repair_confirm()
|
||||||
|
self.assertEqual(rma.qty_to_deliver, 1.0)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div name='button_box' position="inside">
|
<div name='button_box' position="inside">
|
||||||
<button type="object" name="action_view_repair_order"
|
<button type="object" name="action_view_repair_order"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-strikethrough"
|
icon="fa-wrench"
|
||||||
groups="stock.group_stock_user">
|
groups="stock.group_stock_user">
|
||||||
<field name="repair_count" widget="statinfo"
|
<field name="repair_count" widget="statinfo"
|
||||||
string="Repair Orders"/>
|
string="Repair Orders"/>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div name="button_box" position="inside">
|
<div name="button_box" position="inside">
|
||||||
<button type="object" name="action_view_repair_order"
|
<button type="object" name="action_view_repair_order"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-pencil-square-o"
|
icon="fa-wrench"
|
||||||
groups="stock.group_stock_user">
|
groups="stock.group_stock_user">
|
||||||
<field name="repair_count" widget="statinfo"
|
<field name="repair_count" widget="statinfo"
|
||||||
string="Repair Orders"/>
|
string="Repair Orders"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user