mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
multiple fixes
This commit is contained in:
committed by
ahenriquez
parent
0f0558b88f
commit
e3de350b91
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo noupdate="1">
|
||||
<odoo noupdate="0">
|
||||
<record id="rma_operation_customer_replace" model="rma.operation">
|
||||
<field name="name">Replace After Receive</field>
|
||||
<field name="code">RPLC</field>
|
||||
@@ -21,29 +21,24 @@
|
||||
</record>
|
||||
|
||||
<record id="rma_operation_ds_replace" model="rma.operation">
|
||||
<field name="name">Replace deliver to vendor</field>
|
||||
<field name="name">Drop Ship - Replace deliver to vendor</field>
|
||||
<field name="code">DSRPLB</field>
|
||||
<field name="receipt_policy">ordered</field>
|
||||
<field name="delivery_policy">no</field>
|
||||
<field name="type">customer</field>
|
||||
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
||||
</record>
|
||||
|
||||
<record id="rma_operation_ds_replace_customer" model="rma.operation">
|
||||
<field name="name">Replace receive in vendor</field>
|
||||
<field name="code">DSRPLV</field>
|
||||
<field name="receipt_policy">no</field>
|
||||
<field name="delivery_policy">received</field>
|
||||
<field name="type">customer</field>
|
||||
<field name="customer_to_supplier">True</field>
|
||||
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
||||
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
||||
</record>
|
||||
|
||||
<record id="rma_operation_ds_replace_supplier" model="rma.operation">
|
||||
<field name="name">Replace deliver to customer</field>
|
||||
<field name="name">Drop Ship - Replace deliver to customer</field>
|
||||
<field name="code">DSRPC</field>
|
||||
<field name="receipt_policy">no</field>
|
||||
<field name="delivery_policy">received</field>
|
||||
<field name="receipt_policy">ordered</field>
|
||||
<field name="delivery_policy">no</field>
|
||||
<field name="type">supplier</field>
|
||||
<field name="supplier_to_customer">True</field>
|
||||
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
||||
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class RmaOrderLine(models.Model):
|
||||
def _compute_qty_supplier_rma(self):
|
||||
for rec in self:
|
||||
qty = rec._get_supplier_rma_qty()
|
||||
rec.qty_to_supplier_rma = rec.qty_to_receive - qty
|
||||
rec.qty_to_supplier_rma = rec.product_qty - qty
|
||||
rec.qty_in_supplier_rma = qty
|
||||
|
||||
delivery_address_id = fields.Many2one(
|
||||
@@ -489,7 +489,9 @@ class RmaOrderLine(models.Model):
|
||||
self.in_warehouse_id.lot_rma_id
|
||||
self.customer_to_supplier = self.operation_id.customer_to_supplier
|
||||
self.supplier_to_customer = self.operation_id.supplier_to_customer
|
||||
if self.operation_id.in_route_id:
|
||||
self.in_route_id = self.operation_id.in_route_id
|
||||
if self.operation_id.out_route_id:
|
||||
self.out_route_id = self.operation_id.out_route_id
|
||||
return result
|
||||
|
||||
@@ -511,9 +513,10 @@ class RmaOrderLine(models.Model):
|
||||
def action_view_in_shipments(self):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = self.env['stock.picking'].search(
|
||||
[('origin', '=', self.name),
|
||||
('picking_type_code', '=', 'incoming')]).ids
|
||||
moves = self.env['stock.move'].search([
|
||||
('rma_line_id', 'in', self.ids)])
|
||||
picking_ids = moves.mapped('picking_id').filtered(
|
||||
lambda p: p.picking_type_code == 'incoming').ids
|
||||
# choose the view_mode accordingly
|
||||
if len(picking_ids) > 1:
|
||||
result['domain'] = [('id', 'in', picking_ids)]
|
||||
@@ -527,9 +530,10 @@ class RmaOrderLine(models.Model):
|
||||
def action_view_out_shipments(self):
|
||||
action = self.env.ref('stock.action_picking_tree_all')
|
||||
result = action.read()[0]
|
||||
picking_ids = self.env['stock.picking'].search(
|
||||
[('origin', '=', self.name),
|
||||
('picking_type_code', '=', 'outgoing')]).ids
|
||||
moves = self.env['stock.move'].search([
|
||||
('rma_line_id', 'in', self.ids)])
|
||||
picking_ids = moves.mapped('picking_id').filtered(
|
||||
lambda p: p.picking_type_code == 'outgoing').ids
|
||||
# choose the view_mode accordingly
|
||||
if len(picking_ids) > 1:
|
||||
result['domain'] = [('id', 'in', picking_ids)]
|
||||
|
||||
@@ -160,6 +160,8 @@ class TestRma(common.TransactionCase):
|
||||
supplier_address_id=supplier_address_id.id)
|
||||
data['partner_id'] = move.partner_id.id
|
||||
data['rma_id'] = rma_id.id
|
||||
if type == 'supplier':
|
||||
self.rma_line = self.rma_line.with_context(supplier=True)
|
||||
self.line = self.rma_line.create(data)
|
||||
# approve the RMA Line
|
||||
self.rma_line.action_rma_to_approve()
|
||||
@@ -264,18 +266,18 @@ class TestRma(common.TransactionCase):
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'incoming',
|
||||
'active_id': 1
|
||||
}).create({'rma_id': self.rma_customer_id.id})
|
||||
}).create({})
|
||||
wizard.with_context({
|
||||
'active_ids': self.rma_customer_id.rma_line_ids.ids,
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'incoming',
|
||||
'active_id': 1
|
||||
}).default_get({})
|
||||
procurements = wizard._create_picking()
|
||||
domain = [('origin', '=', procurements)]
|
||||
picking = self.stockpicking.search(domain)
|
||||
self.assertEquals(len(picking), 1,
|
||||
wizard._create_picking()
|
||||
res = self.rma_customer_id.rma_line_ids.action_view_in_shipments()
|
||||
self.assertTrue('res_id' in res,
|
||||
"Incorrect number of pickings created")
|
||||
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||
moves = picking.move_lines
|
||||
self.assertEquals(len(moves), 3,
|
||||
"Incorrect number of moves created")
|
||||
@@ -309,33 +311,29 @@ class TestRma(common.TransactionCase):
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_incoming, 2,
|
||||
"Wrong qty incoming")
|
||||
picking.action_confirm()
|
||||
picking.action_assign()
|
||||
picking.force_assign()
|
||||
picking.do_new_transfer()
|
||||
for line in picking.move_line_ids:
|
||||
line.qty_done = line.product_uom_qty
|
||||
picking.action_done()
|
||||
for line in self.rma_customer_id.rma_line_ids:
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
self.assertEquals(line.qty_to_receive, 0,
|
||||
"Wrong qty to_receive")
|
||||
# self.assertEquals(line.qty_incoming, 5,
|
||||
# "Wrong qty incoming")
|
||||
self.assertEquals(line.qty_incoming, 0,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
"Wrong qty outgoing")
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_incoming, 3,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_received, 3,
|
||||
"Wrong qty received")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_to_receive, 5,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_incoming, 5,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_received, 5,
|
||||
"Wrong qty received")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_to_receive, 2,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_incoming, 2,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_received, 2,
|
||||
"Wrong qty received")
|
||||
|
||||
wizard = self.rma_make_picking.with_context({
|
||||
'active_id': 1,
|
||||
@@ -343,72 +341,51 @@ class TestRma(common.TransactionCase):
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'outgoing',
|
||||
}).create({})
|
||||
procurements = wizard._create_picking()
|
||||
domain = [('origin', '=', procurements)]
|
||||
pickings = self.stockpicking.search(domain)
|
||||
self.assertEquals(len(pickings), 2,
|
||||
wizard._create_picking()
|
||||
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
|
||||
self.assertTrue('res_id' in res,
|
||||
"Incorrect number of pickings created")
|
||||
picking_out = pickings[0]
|
||||
moves = picking_out.move_lines
|
||||
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||
moves = picking.move_lines
|
||||
self.assertEquals(len(moves), 3,
|
||||
"Incorrect number of moves created")
|
||||
for line in self.rma_customer_id.rma_line_ids:
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
"Wrong qty receive")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
"Wrong qty outgoing")
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_to_deliver, 0,
|
||||
self.assertEquals(line.qty_to_deliver, 3,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
self.assertEquals(line.qty_outgoing, 3,
|
||||
"Wrong qty outgoing")
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
"Wrong qty received")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_to_receive, 5,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_incoming, 5,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
self.assertEquals(line.qty_to_deliver, 5,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 5,
|
||||
"Wrong qty outgoing")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_to_receive, 2,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_incoming, 2,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
self.assertEquals(line.qty_to_deliver, 2,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 2,
|
||||
"Wrong qty outgoing")
|
||||
picking_out.action_assign()
|
||||
picking_out.do_new_transfer()
|
||||
picking.action_confirm()
|
||||
picking.action_assign()
|
||||
for line in picking.move_line_ids:
|
||||
line.qty_done = line.product_uom_qty
|
||||
picking.action_done()
|
||||
for line in self.rma_customer_id.rma_line_ids[0]:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_incoming, 3,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_to_deliver, 0,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
"Wrong qty outgoing")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to received")
|
||||
self.assertEquals(line.qty_to_deliver, 0,
|
||||
"Wrong qty to delivered")
|
||||
self.assertEquals(line.qty_delivered, 3,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_received, 5,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_delivered, 5,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_received, 2,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_delivered, 2,
|
||||
"Wrong qty delivered")
|
||||
self.line.action_rma_done()
|
||||
self.assertEquals(self.line.state, 'done',
|
||||
"Wrong State")
|
||||
self.rma_customer_id.action_view_in_shipments()
|
||||
self.rma_customer_id.action_view_out_shipments()
|
||||
self.rma_customer_id.action_view_lines()
|
||||
|
||||
@@ -8,18 +8,26 @@ class TestRmaDropship(test_rma.TestRma):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRmaDropship, self).setUp()
|
||||
rma_operation_ds_replace = self.env.ref(
|
||||
'rma.rma_operation_ds_replace')
|
||||
self.rma_operation_ds_replace_supplier = self.env.ref(
|
||||
'rma.rma_operation_ds_replace_supplier')
|
||||
self.product_id.write(
|
||||
{'rma_customer_operation_id': self.rma_cust_replace_op_id.id,
|
||||
'rma_supplier_operation_id': self.rma_sup_replace_op_id.id})
|
||||
{'rma_customer_operation_id': rma_operation_ds_replace.id,
|
||||
'rma_supplier_operation_id':
|
||||
self.rma_operation_ds_replace_supplier.id})
|
||||
self.product_1.write(
|
||||
{'rma_customer_operation_id': self.rma_cust_replace_op_id.id,
|
||||
'rma_supplier_operation_id': self.rma_sup_replace_op_id.id})
|
||||
{'rma_customer_operation_id': rma_operation_ds_replace.id,
|
||||
'rma_supplier_operation_id':
|
||||
self.rma_operation_ds_replace_supplier.id})
|
||||
self.product_2.write(
|
||||
{'rma_customer_operation_id': self.rma_cust_replace_op_id.id,
|
||||
'rma_supplier_operation_id': self.rma_sup_replace_op_id.id})
|
||||
{'rma_customer_operation_id': rma_operation_ds_replace.id,
|
||||
'rma_supplier_operation_id':
|
||||
self.rma_operation_ds_replace_supplier.id})
|
||||
self.product_3.write(
|
||||
{'rma_customer_operation_id': self.rma_cust_replace_op_id.id,
|
||||
'rma_supplier_operation_id': self.rma_sup_replace_op_id.id})
|
||||
{'rma_customer_operation_id': rma_operation_ds_replace.id,
|
||||
'rma_supplier_operation_id':
|
||||
self.rma_operation_ds_replace_supplier.id})
|
||||
products2move = [(self.product_1, 3), (self.product_2, 5),
|
||||
(self.product_3, 2)]
|
||||
self.rma_droship_id = self._create_rma_from_move(
|
||||
@@ -32,13 +40,14 @@ class TestRmaDropship(test_rma.TestRma):
|
||||
'active_ids': self.rma_droship_id.rma_line_ids.ids,
|
||||
'active_model': 'rma.order.line',
|
||||
'active_id': 1
|
||||
}).create({'partner_id': self.partner_id.id,
|
||||
'supplier_rma_id': self.rma_droship_id.id,
|
||||
})
|
||||
}).create({})
|
||||
|
||||
res = wizard.make_supplier_rma()
|
||||
supplier_rma = self.rma.browse(res['res_id'])
|
||||
for line in supplier_rma.rma_line_ids:
|
||||
line.delivery_address_id = self.env.ref('base.res_partner_2')
|
||||
line.operation_id = self.rma_operation_ds_replace_supplier
|
||||
line._onchange_operation_id()
|
||||
line.action_rma_to_approve()
|
||||
line.action_rma_approve()
|
||||
wizard = self.rma_make_picking.with_context({
|
||||
@@ -47,22 +56,15 @@ class TestRmaDropship(test_rma.TestRma):
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'incoming',
|
||||
}).create({})
|
||||
procurements = wizard._create_picking()
|
||||
domain = [('origin', '=', procurements)]
|
||||
picking = self.stockpicking.search(domain)
|
||||
self.assertEquals(len(picking), 1,
|
||||
wizard._create_picking()
|
||||
res = supplier_rma.rma_line_ids.action_view_in_shipments()
|
||||
self.assertTrue('res_id' in res,
|
||||
"Incorrect number of pickings created")
|
||||
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||
moves = picking.move_lines
|
||||
self.assertEquals(len(moves), 3,
|
||||
"Incorrect number of moves created")
|
||||
for line in supplier_rma.rma_line_ids:
|
||||
# common qtys for all products
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_outgoing, 0,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
"Wrong qty delivered")
|
||||
# product specific
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
|
||||
@@ -8,6 +8,8 @@ class TestSupplierRma(test_rma.TestRma):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSupplierRma, self).setUp()
|
||||
self.rma_operation_supplier_replace = self.env.ref(
|
||||
'rma.rma_operation_supplier_replace')
|
||||
products2move = [(self.product_1, 3), (self.product_2, 5),
|
||||
(self.product_3, 2)]
|
||||
self.rma_supplier_id = self._create_rma_from_move(
|
||||
@@ -15,17 +17,22 @@ class TestSupplierRma(test_rma.TestRma):
|
||||
dropship=False)
|
||||
|
||||
def test_supplier_rma(self):
|
||||
for line in self.rma_supplier_id.rma_line_ids:
|
||||
line.operation_id = self.rma_operation_supplier_replace
|
||||
line._onchange_operation_id()
|
||||
line.action_rma_to_approve()
|
||||
line.action_rma_approve()
|
||||
wizard = self.rma_make_picking.with_context({
|
||||
'active_ids': self.rma_supplier_id.rma_line_ids.ids,
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'outgoing',
|
||||
'active_id': 1
|
||||
}).create({})
|
||||
procurements = wizard._create_picking()
|
||||
domain = [('origin', '=', procurements)]
|
||||
picking = self.stockpicking.search(domain)
|
||||
self.assertEquals(len(picking), 1,
|
||||
wizard._create_picking()
|
||||
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
|
||||
self.assertTrue('res_id' in res,
|
||||
"Incorrect number of pickings created")
|
||||
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||
moves = picking.move_lines
|
||||
self.assertEquals(len(moves), 3,
|
||||
"Incorrect number of moves created")
|
||||
@@ -59,26 +66,27 @@ class TestSupplierRma(test_rma.TestRma):
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 2,
|
||||
"Wrong qty outgoing")
|
||||
|
||||
picking.action_assign()
|
||||
picking.do_new_transfer()
|
||||
picking.force_assign()
|
||||
for line in picking.move_lines:
|
||||
line.quantity_done = line.product_uom_qty
|
||||
picking.button_validate()
|
||||
for line in self.rma_supplier_id.rma_line_ids:
|
||||
self.assertEquals(line.qty_incoming, 0,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
"Wrong qty received")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
self.assertEquals(line.qty_delivered, 3,
|
||||
"Wrong qty delivered")
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to receive")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
self.assertEquals(line.qty_delivered, 5,
|
||||
"Wrong qty delivered")
|
||||
self.assertEquals(line.qty_to_receive, 5,
|
||||
"Wrong qty to receive")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
self.assertEquals(line.qty_delivered, 2,
|
||||
"Wrong qty delivered")
|
||||
self.assertEquals(line.qty_to_receive, 2,
|
||||
"Wrong qty to receive")
|
||||
@@ -88,63 +96,48 @@ class TestSupplierRma(test_rma.TestRma):
|
||||
'active_model': 'rma.order.line',
|
||||
'picking_type': 'incoming',
|
||||
}).create({})
|
||||
procurements = wizard._create_picking()
|
||||
domain = [('origin', '=', procurements)]
|
||||
pickings = self.stockpicking.search(domain)
|
||||
self.assertEquals(len(pickings), 2,
|
||||
wizard._create_picking()
|
||||
res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments()
|
||||
self.assertTrue('res_id' in res,
|
||||
"Incorrect number of pickings created")
|
||||
picking_out = pickings[0]
|
||||
moves = picking_out.move_lines
|
||||
picking = self.env['stock.picking'].browse(res['res_id'])
|
||||
moves = picking.move_lines
|
||||
self.assertEquals(len(moves), 3,
|
||||
"Incorrect number of moves created")
|
||||
for line in self.rma_supplier_id.rma_line_ids:
|
||||
self.assertEquals(line.qty_incoming, 0,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
"Wrong qty received")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_incoming, 0,
|
||||
self.assertEquals(line.qty_incoming, 3,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_to_receive, 5,
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_to_deliver, 5,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_incoming, 5,
|
||||
"Wrong qty incoming")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_to_receive, 2,
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_to_deliver, 2,
|
||||
"Wrong qty to deliver")
|
||||
picking_out.action_assign()
|
||||
picking_out.do_new_transfer()
|
||||
self.assertEquals(line.qty_incoming, 2,
|
||||
"Wrong qty incoming")
|
||||
picking.action_assign()
|
||||
for line in picking.move_line_ids:
|
||||
line.qty_done = line.product_uom_qty
|
||||
picking.action_done()
|
||||
for line in self.rma_supplier_id.rma_line_ids[0]:
|
||||
self.assertEquals(line.qty_to_receive, 3,
|
||||
"Wrong qty to receive")
|
||||
self.assertEquals(line.qty_incoming, 0,
|
||||
"Wrong qty incoming")
|
||||
self.assertEquals(line.qty_to_deliver, 3,
|
||||
"Wrong qty to deliver")
|
||||
self.assertEquals(line.qty_outgoing, 6,
|
||||
"Wrong qty outgoing")
|
||||
if line.product_id == self.product_1:
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
self.assertEquals(line.qty_received, 3,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_delivered, 0,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_2:
|
||||
self.assertEquals(line.qty_received, 0,
|
||||
self.assertEquals(line.qty_received, 5,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_delivered, 5,
|
||||
"Wrong qty delivered")
|
||||
if line.product_id == self.product_3:
|
||||
self.assertEquals(line.qty_received, 2,
|
||||
"Wrong qty received")
|
||||
self.assertEquals(line.qty_delivered, 2,
|
||||
"Wrong qty delivered")
|
||||
for line in self.rma_supplier_id.rma_line_ids:
|
||||
line.action_rma_done()
|
||||
self.assertEquals(line.state, 'done',
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
<field name="location_id"
|
||||
domain="[('usage', '=', 'internal')]"/>
|
||||
<field name="customer_to_supplier"
|
||||
attrs="{'invisible':[('type', '=', 'supplier')]}"/>
|
||||
<field name="supplier_to_customer"
|
||||
attrs="{'invisible':[('type', '=', 'customer')]}"/>
|
||||
</group>
|
||||
<group name="outbound" string="Outbound">
|
||||
<field name="out_route_id"/>
|
||||
<field name="out_warehouse_id"/>
|
||||
<field name="supplier_to_customer"
|
||||
attrs="{'invisible':[('type', '=', 'supplier')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
|
||||
@@ -144,9 +144,12 @@
|
||||
</group>
|
||||
<group name="outbound" string="Outbound">
|
||||
<field name="out_warehouse_id"/>
|
||||
<field name="out_route_id"/>
|
||||
</group>
|
||||
<group name="delivery_address"
|
||||
string="Delivery Address (drop ship">
|
||||
<field name="delivery_address_id"
|
||||
groups='rma.group_rma_delivery_invoice_address'/>
|
||||
<field name="out_route_id"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import time
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
|
||||
import odoo.addons.decimal_precision as dp
|
||||
|
||||
@@ -103,6 +103,9 @@ class RmaMakePicking(models.TransientModel):
|
||||
if line.customer_to_supplier:
|
||||
location = self._get_address_location(
|
||||
delivery_address_id, 'supplier')
|
||||
elif line.supplier_to_customer:
|
||||
location = self._get_address_location(
|
||||
delivery_address_id, 'customer')
|
||||
else:
|
||||
location = line.location_id
|
||||
warehouse = line.in_warehouse_id
|
||||
@@ -134,6 +137,7 @@ class RmaMakePicking(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _create_procurement(self, item, picking_type):
|
||||
errors = []
|
||||
group = self.find_procurement_group(item)
|
||||
if not group:
|
||||
pg_data = self._get_procurement_group_data(item)
|
||||
@@ -144,6 +148,7 @@ class RmaMakePicking(models.TransientModel):
|
||||
qty = item.qty_to_deliver
|
||||
values = self._get_procurement_data(item, group, qty, picking_type)
|
||||
# create picking
|
||||
try:
|
||||
self.env['procurement.group'].run(
|
||||
item.line_id.product_id,
|
||||
qty,
|
||||
@@ -153,6 +158,10 @@ class RmaMakePicking(models.TransientModel):
|
||||
values.get('origin'),
|
||||
values
|
||||
)
|
||||
except UserError as error:
|
||||
errors.append(error.name)
|
||||
if errors:
|
||||
raise UserError('\n'.join(errors))
|
||||
return values.get('origin')
|
||||
|
||||
@api.multi
|
||||
@@ -198,7 +207,6 @@ class RmaMakePicking(models.TransientModel):
|
||||
@api.multi
|
||||
def action_create_picking(self):
|
||||
procurement = self._create_picking()
|
||||
pickings = False
|
||||
action = self.env.ref('stock.do_view_pickings')
|
||||
action = action.read()[0]
|
||||
if procurement:
|
||||
|
||||
@@ -66,13 +66,14 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
||||
raise ValidationError(_('Enter a supplier.'))
|
||||
return {
|
||||
'partner_id': self.partner_id.id,
|
||||
'delivery_address_id': self.partner_id.id,
|
||||
'type': 'supplier',
|
||||
'company_id': company.id,
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _prepare_supplier_rma_line(self, rma, item):
|
||||
operation = item.line_id.product_id.rma_supplier_operation_id
|
||||
if not operation:
|
||||
operation = self.env['rma.operation'].search(
|
||||
[('type', '=', 'supplier')], limit=1)
|
||||
if not operation.in_route_id or not operation.out_route_id:
|
||||
@@ -97,7 +98,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
||||
'customer_rma_id': item.line_id.id,
|
||||
'product_qty': item.product_qty,
|
||||
'rma_id': rma.id,
|
||||
'uom_id': item.uom_id.id,
|
||||
'uom_id': item.line_id.uom_id.id,
|
||||
'operation_id': operation.id,
|
||||
'receipt_policy': operation.receipt_policy,
|
||||
'delivery_policy': operation.delivery_policy,
|
||||
|
||||
Reference in New Issue
Block a user