This commit sets up the logic and adds the button for "Put in Pack" action that already exists in stock.picking. Reuse/extension of logic from stock.picking reused where possible, including extension of pack wizard to handle products with different destination. Note that logic to handle "Delivery Packaging" wizard when "Delivery Methods" is active was purposely not extended to work correctly in batch pickings due to complexity of adding in a new module just to handle conflicting carrier_ids across pickings in the same batch. It is expected that this use case will not occur except in case of user error. Additionally, stock.picking implementation of 'put_in_pack' method has been renamed to 'action_put_in_pack' to have consistent naming (and support enterprise level code). Part of "1. Improve Batch Pickings" specification of overall barcode improvements task. Task: 1884520 Enterprise PR: odoo/enterprise#12086 Closes: odoo/odoo#55096
79 lines
3.2 KiB
Python
79 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.addons.stock.tests.test_packing import TestPackingCommon
|
|
|
|
|
|
class TestPacking(TestPackingCommon):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestPacking, cls).setUpClass()
|
|
cls.uom_kg = cls.env.ref('uom.product_uom_kgm')
|
|
cls.product_aw = cls.env['product.product'].create({
|
|
'name': 'Product AW',
|
|
'type': 'product',
|
|
'weight': 2.4,
|
|
'uom_id': cls.uom_kg.id,
|
|
'uom_po_id': cls.uom_kg.id
|
|
})
|
|
cls.product_bw = cls.env['product.product'].create({
|
|
'name': 'Product BW',
|
|
'type': 'product',
|
|
'weight': 0.3,
|
|
'uom_id': cls.uom_kg.id,
|
|
'uom_po_id': cls.uom_kg.id
|
|
})
|
|
test_carrier_product = cls.env['product.product'].create({
|
|
'name': 'Test carrier product',
|
|
'type': 'service',
|
|
})
|
|
cls.test_carrier = cls.env['delivery.carrier'].create({
|
|
'name': 'Test carrier',
|
|
'delivery_type': 'fixed',
|
|
'product_id': test_carrier_product.id,
|
|
})
|
|
|
|
def test_put_in_pack_weight_wizard(self):
|
|
""" Check that de default weight is correctly set by default when using the 'choose.delivery.package' wizard.
|
|
This purpose of this wizard is
|
|
"""
|
|
self.env['stock.quant']._update_available_quantity(self.product_aw, self.stock_location, 20.0)
|
|
self.env['stock.quant']._update_available_quantity(self.product_bw, self.stock_location, 20.0)
|
|
|
|
picking_ship = self.env['stock.picking'].create({
|
|
'partner_id': self.env['res.partner'].create({'name': 'A partner'}).id,
|
|
'picking_type_id': self.warehouse.out_type_id.id,
|
|
'location_id': self.stock_location.id,
|
|
'location_dest_id': self.customer_location.id,
|
|
'carrier_id': self.test_carrier.id
|
|
})
|
|
move_line_paw = self.env['stock.move.line'].create({
|
|
'product_id': self.product_aw.id,
|
|
'product_uom_id': self.uom_kg.id,
|
|
'picking_id': picking_ship.id,
|
|
'qty_done': 5,
|
|
'location_id': self.stock_location.id,
|
|
'location_dest_id': self.customer_location.id
|
|
})
|
|
move_line_pbw = self.env['stock.move.line'].create({
|
|
'product_id': self.product_bw.id,
|
|
'product_uom_id': self.uom_kg.id,
|
|
'picking_id': picking_ship.id,
|
|
'qty_done': 5,
|
|
'location_id': self.stock_location.id,
|
|
'location_dest_id': self.customer_location.id
|
|
})
|
|
picking_ship.action_confirm()
|
|
pack_action = picking_ship.action_put_in_pack()
|
|
pack_action_ctx = pack_action['context']
|
|
pack_action_model = pack_action['res_model']
|
|
|
|
# We make sure the correct action was returned
|
|
self.assertEqual(pack_action_model, 'choose.delivery.package')
|
|
|
|
# We instanciate the wizard with the context of the action and check that the
|
|
# default weight was set.
|
|
pack_wiz = self.env['choose.delivery.package'].with_context(pack_action_ctx).create({})
|
|
self.assertEqual(pack_wiz.shipping_weight, 13.5)
|