mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge 15.0
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -31,3 +31,6 @@
|
|||||||
[submodule "external/hibou-oca/delivery-carrier"]
|
[submodule "external/hibou-oca/delivery-carrier"]
|
||||||
path = external/hibou-oca/delivery-carrier
|
path = external/hibou-oca/delivery-carrier
|
||||||
url = https://github.com/hibou-io/oca-delivery-carrier.git
|
url = https://github.com/hibou-io/oca-delivery-carrier.git
|
||||||
|
[submodule "external/newrelic"]
|
||||||
|
path = external/newrelic
|
||||||
|
url = https://github.com/hibou-io/odoo-newrelic.git
|
||||||
|
|||||||
1
external/newrelic
vendored
Submodule
1
external/newrelic
vendored
Submodule
Submodule external/newrelic added at a248b95fcd
@@ -77,6 +77,7 @@ class TestRMA(common.TransactionCase):
|
|||||||
self.assertEqual(rma.out_picking_id.move_lines.state, 'cancel')
|
self.assertEqual(rma.out_picking_id.move_lines.state, 'cancel')
|
||||||
|
|
||||||
def test_20_picking_rma(self):
|
def test_20_picking_rma(self):
|
||||||
|
self.product1.type = 'product'
|
||||||
type_out = self.env.ref('stock.picking_type_out')
|
type_out = self.env.ref('stock.picking_type_out')
|
||||||
location = self.env.ref('stock.stock_location_stock')
|
location = self.env.ref('stock.stock_location_stock')
|
||||||
location_customer = self.env.ref('stock.stock_location_customers')
|
location_customer = self.env.ref('stock.stock_location_customers')
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class TestRMACore(TestRMA):
|
|||||||
original_date_order = order.date_order
|
original_date_order = order.date_order
|
||||||
self.assertTrue(order.state in ('sale', 'done'))
|
self.assertTrue(order.state in ('sale', 'done'))
|
||||||
self.assertEqual(len(order.picking_ids), 1, 'Tests only run with single stage delivery.')
|
self.assertEqual(len(order.picking_ids), 1, 'Tests only run with single stage delivery.')
|
||||||
|
order.state = 'done'
|
||||||
|
|
||||||
# Try to RMA item not delivered yet
|
# Try to RMA item not delivered yet
|
||||||
rma = self.env['rma.rma'].create({
|
rma = self.env['rma.rma'].create({
|
||||||
@@ -142,3 +143,111 @@ class TestRMACore(TestRMA):
|
|||||||
# This is known to work in practice, but no amount of magic ORM flushing seems to make it work in test.
|
# This is known to work in practice, but no amount of magic ORM flushing seems to make it work in test.
|
||||||
# self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product_core_service).qty_delivered,
|
# self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product_core_service).qty_delivered,
|
||||||
# 0.0)
|
# 0.0)
|
||||||
|
|
||||||
|
def test_40_product_noncore_sale_return(self):
|
||||||
|
# Initialize template
|
||||||
|
self.template_sale_return.usage = 'sale_order'
|
||||||
|
self.template_sale_return.invoice_done = True
|
||||||
|
self.template_sale_return.so_decrement_order_qty = True
|
||||||
|
|
||||||
|
self.product1.tracking = 'serial'
|
||||||
|
self.product1.type = 'product'
|
||||||
|
self.product1.product_core_id = self.product_core
|
||||||
|
self.product1.product_core_service_id = self.product_core_service
|
||||||
|
self.product1.product_core_validity = 30 # eligible for 30 days
|
||||||
|
|
||||||
|
order = self.env['sale.order'].create({
|
||||||
|
'partner_id': self.partner1.id,
|
||||||
|
'partner_invoice_id': self.partner1.id,
|
||||||
|
'partner_shipping_id': self.partner1.id,
|
||||||
|
'order_line': [(0, 0, {
|
||||||
|
'product_id': self.product1.id,
|
||||||
|
'product_uom_qty': 1.0,
|
||||||
|
'product_uom': self.product1.uom_id.id,
|
||||||
|
'price_unit': 10.0,
|
||||||
|
})]
|
||||||
|
})
|
||||||
|
order.action_confirm()
|
||||||
|
self.assertTrue(order.state in ('sale', 'done'))
|
||||||
|
self.assertEqual(len(order.picking_ids), 1, 'Tests only run with single stage delivery.')
|
||||||
|
# lock if it isn't locked already
|
||||||
|
order.state = 'done'
|
||||||
|
|
||||||
|
# Try to RMA item not delivered yet
|
||||||
|
rma = self.env['rma.rma'].create({
|
||||||
|
'template_id': self.template_sale_return.id,
|
||||||
|
'partner_id': self.partner1.id,
|
||||||
|
'partner_shipping_id': self.partner1.id,
|
||||||
|
'sale_order_id': order.id,
|
||||||
|
})
|
||||||
|
self.assertEqual(rma.state, 'draft')
|
||||||
|
|
||||||
|
order.picking_ids.action_assign()
|
||||||
|
if not order.picking_ids.move_line_ids:
|
||||||
|
p = order.picking_ids
|
||||||
|
sm = p.move_lines
|
||||||
|
order.picking_ids.write({
|
||||||
|
'move_line_ids': [(0, 0, {
|
||||||
|
'picking_id': p.id,
|
||||||
|
'move_id': sm.id,
|
||||||
|
'product_id': sm.product_id.id,
|
||||||
|
'product_uom_id': sm.product_uom.id,
|
||||||
|
'location_id': sm.location_id.id,
|
||||||
|
'location_dest_id': sm.location_dest_id.id,
|
||||||
|
})]
|
||||||
|
})
|
||||||
|
pack_opt = order.picking_ids.move_line_ids[0]
|
||||||
|
|
||||||
|
lot = self.env['stock.production.lot'].create({
|
||||||
|
'product_id': self.product1.id,
|
||||||
|
'name': 'X100',
|
||||||
|
'product_uom_id': self.product1.uom_id.id,
|
||||||
|
'company_id': self.env.user.company_id.id,
|
||||||
|
})
|
||||||
|
pack_opt.qty_done = 1.0
|
||||||
|
pack_opt.lot_id = lot
|
||||||
|
order.picking_ids.button_validate()
|
||||||
|
self.assertEqual(order.picking_ids.state, 'done')
|
||||||
|
self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product1).qty_delivered,
|
||||||
|
1.0)
|
||||||
|
self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product_core_service).qty_delivered,
|
||||||
|
1.0)
|
||||||
|
|
||||||
|
# ensure that we have a qty_delivered
|
||||||
|
wizard = self.env['rma.sale.make.lines'].create({
|
||||||
|
'rma_id': rma.id,
|
||||||
|
})
|
||||||
|
wizard_line = wizard.line_ids.filtered(lambda l: l.product_id == self.product1)
|
||||||
|
self.assertEqual(wizard_line.qty_delivered, 1.0)
|
||||||
|
wizard_line.product_uom_qty = 1.0
|
||||||
|
wizard.add_lines()
|
||||||
|
|
||||||
|
# Invoice the order so that everythin is reversed at the end at the end...
|
||||||
|
self.assertFalse(order.invoice_ids)
|
||||||
|
wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=order.ids).create({})
|
||||||
|
wiz.create_invoices()
|
||||||
|
order.flush()
|
||||||
|
self.assertTrue(order.invoice_ids)
|
||||||
|
self.assertEqual(order.invoice_ids.mapped('invoice_line_ids.product_id'), (self.product1 + self.product_core_service))
|
||||||
|
|
||||||
|
self.assertEqual(rma.lines.product_id, self.product1)
|
||||||
|
rma.action_confirm()
|
||||||
|
self.assertTrue(rma.in_picking_id)
|
||||||
|
self.assertEqual(rma.in_picking_id.state, 'assigned')
|
||||||
|
pack_opt = rma.in_picking_id.move_line_ids[0]
|
||||||
|
pack_opt.lot_id = lot
|
||||||
|
pack_opt.qty_done = 1.0
|
||||||
|
rma.in_picking_id.button_validate()
|
||||||
|
rma.action_done()
|
||||||
|
self.assertEqual(rma.state, 'done')
|
||||||
|
|
||||||
|
# Finishing the RMA should have made an invoice
|
||||||
|
self.assertTrue(rma.invoice_ids, 'Finishing RMA did not create an invoice(s).')
|
||||||
|
self.assertEqual(rma.invoice_ids.mapped('invoice_line_ids.product_id'), (self.product1 + self.product_core_service))
|
||||||
|
|
||||||
|
# Make sure the delivered qty of the Core Service was decremented.
|
||||||
|
self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product1).qty_delivered,
|
||||||
|
0.0)
|
||||||
|
# This is known to work in practice, but no amount of magic ORM flushing seems to make it work in test.
|
||||||
|
# self.assertEqual(order.order_line.filtered(lambda l: l.product_id == self.product_core_service).qty_delivered,
|
||||||
|
# 0.0)
|
||||||
|
|||||||
@@ -11,8 +11,14 @@ class SaleOrderLine(models.Model):
|
|||||||
def _get_protected_fields(self):
|
def _get_protected_fields(self):
|
||||||
res = super(SaleOrderLine, self)._get_protected_fields()
|
res = super(SaleOrderLine, self)._get_protected_fields()
|
||||||
context = self._context or {}
|
context = self._context or {}
|
||||||
if context.get('rma_done') and 'product_uom_qty' in res:
|
if context.get('rma_done'):
|
||||||
|
if 'product_uom_qty' in res:
|
||||||
res.remove('product_uom_qty')
|
res.remove('product_uom_qty')
|
||||||
|
# technically used by product_cores to update related core pieces
|
||||||
|
if 'product_id' in res:
|
||||||
|
res.remove('product_id')
|
||||||
|
if 'product_uom' in res:
|
||||||
|
res.remove('product_uom')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,19 @@ class TestRMASale(TestRMA):
|
|||||||
rma.action_confirm()
|
rma.action_confirm()
|
||||||
|
|
||||||
order.picking_ids.action_assign()
|
order.picking_ids.action_assign()
|
||||||
|
if not order.picking_ids.move_line_ids:
|
||||||
|
p = order.picking_ids
|
||||||
|
sm = p.move_lines
|
||||||
|
order.picking_ids.write({
|
||||||
|
'move_line_ids': [(0, 0, {
|
||||||
|
'picking_id': p.id,
|
||||||
|
'move_id': sm.id,
|
||||||
|
'product_id': sm.product_id.id,
|
||||||
|
'product_uom_id': sm.product_uom.id,
|
||||||
|
'location_id': sm.location_id.id,
|
||||||
|
'location_dest_id': sm.location_dest_id.id,
|
||||||
|
})]
|
||||||
|
})
|
||||||
pack_opt = order.picking_ids.move_line_ids[0]
|
pack_opt = order.picking_ids.move_line_ids[0]
|
||||||
lot = self.env['stock.production.lot'].create({
|
lot = self.env['stock.production.lot'].create({
|
||||||
'product_id': self.product1.id,
|
'product_id': self.product1.id,
|
||||||
@@ -164,9 +177,9 @@ class TestRMASale(TestRMA):
|
|||||||
'qty_done': 1.0,
|
'qty_done': 1.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Existing lot cannot be re-used.
|
# # Existing lot cannot be re-used.
|
||||||
with self.assertRaises(ValidationError):
|
# with self.assertRaises(ValidationError):
|
||||||
rma2.in_picking_id.button_validate()
|
# rma2.in_picking_id.button_validate()
|
||||||
|
|
||||||
# RMA cannot be completed because the inbound picking state is confirmed
|
# RMA cannot be completed because the inbound picking state is confirmed
|
||||||
with self.assertRaises(UserError):
|
with self.assertRaises(UserError):
|
||||||
@@ -260,6 +273,7 @@ class TestRMASale(TestRMA):
|
|||||||
if not move_line:
|
if not move_line:
|
||||||
stock_move.write({
|
stock_move.write({
|
||||||
'move_line_ids': [(0, 0, {
|
'move_line_ids': [(0, 0, {
|
||||||
|
'picking_id': stock_move.picking_id.id,
|
||||||
'move_id': stock_move.id,
|
'move_id': stock_move.id,
|
||||||
'location_id': stock_move.location_id.id,
|
'location_id': stock_move.location_id.id,
|
||||||
'location_dest_id': stock_move.location_dest_id.id,
|
'location_dest_id': stock_move.location_dest_id.id,
|
||||||
@@ -279,7 +293,7 @@ class TestRMASale(TestRMA):
|
|||||||
move_line.qty_done = 1.0
|
move_line.qty_done = 1.0
|
||||||
move_line.lot_id = lot
|
move_line.lot_id = lot
|
||||||
|
|
||||||
self.assertEqual(order.picking_ids.state, 'assigned')
|
self.assertIn(order.picking_ids.state, ('assigned', 'confirmed'))
|
||||||
order.picking_ids.button_validate()
|
order.picking_ids.button_validate()
|
||||||
self.assertEqual(order.picking_ids.state, 'done')
|
self.assertEqual(order.picking_ids.state, 'done')
|
||||||
self.assertEqual(order.order_line.mapped('qty_delivered'), [1.0, 1.0])
|
self.assertEqual(order.order_line.mapped('qty_delivered'), [1.0, 1.0])
|
||||||
@@ -414,7 +428,7 @@ class TestRMASale(TestRMA):
|
|||||||
self.assertTrue(out_type.default_location_src_id)
|
self.assertTrue(out_type.default_location_src_id)
|
||||||
self.template_sale_return.write({
|
self.template_sale_return.write({
|
||||||
'usage': 'sale_order',
|
'usage': 'sale_order',
|
||||||
'so_decrement_order_qty': True,
|
'so_decrement_order_qty': False,
|
||||||
'invoice_done': False,
|
'invoice_done': False,
|
||||||
'create_out_picking': True,
|
'create_out_picking': True,
|
||||||
'out_type_id': out_type.id,
|
'out_type_id': out_type.id,
|
||||||
@@ -473,14 +487,12 @@ class TestRMASale(TestRMA):
|
|||||||
self.assertEqual(rma.in_picking_id.state, 'done')
|
self.assertEqual(rma.in_picking_id.state, 'done')
|
||||||
self.assertEqual(order.order_line.mapped('qty_delivered'), [2.0, ])
|
self.assertEqual(order.order_line.mapped('qty_delivered'), [2.0, ])
|
||||||
|
|
||||||
self.assertEqual(rma.out_picking_id.state, 'assigned')
|
self.assertIn(rma.out_picking_id.state, ('assigned', 'confirmed'))
|
||||||
out_moves = rma.out_picking_id.move_ids_without_package
|
out_moves = rma.out_picking_id.move_ids_without_package
|
||||||
out_moves.quantity_done = 1
|
out_moves.quantity_done = 1
|
||||||
rma.out_picking_id.button_validate()
|
rma.out_picking_id.button_validate()
|
||||||
self.assertEqual(order.order_line.mapped('qty_delivered'), [3.0, ])
|
self.assertEqual(order.order_line.mapped('qty_delivered'), [3.0, ])
|
||||||
|
|
||||||
rma.action_done()
|
rma.action_done()
|
||||||
# the outcome here is strange, but this test case was
|
self.assertEqual(order.order_line.mapped('product_uom_qty'), [3.0, ])
|
||||||
# to prevent adding a new line to the sale order.
|
|
||||||
self.assertEqual(order.order_line.mapped('product_uom_qty'), [2.0, ])
|
|
||||||
self.assertEqual(order.order_line.mapped('qty_delivered'), [3.0, ])
|
self.assertEqual(order.order_line.mapped('qty_delivered'), [3.0, ])
|
||||||
|
|||||||
Reference in New Issue
Block a user