diff --git a/base_delivery_carrier_files/__manifest__.py b/base_delivery_carrier_files/__manifest__.py index 1ac44d8b6a..c94f6813a2 100644 --- a/base_delivery_carrier_files/__manifest__.py +++ b/base_delivery_carrier_files/__manifest__.py @@ -14,14 +14,16 @@ 'stock', 'delivery' ], + 'demo': [ + 'demo/carrier_file_data.xml', + ], 'data': [ 'views/carrier_file_view.xml', 'views/stock_view.xml', 'wizards/generate_carrier_files_view.xml', - 'security/ir.model.access.csv' + 'security/ir.model.access.csv', ], 'summary': 'Base module for creation of delivery carrier files', - 'images': [], 'installable': True, 'auto_install': False, } diff --git a/base_delivery_carrier_files/demo/carrier_file_data.xml b/base_delivery_carrier_files/demo/carrier_file_data.xml new file mode 100644 index 0000000000..b4fac3b691 --- /dev/null +++ b/base_delivery_carrier_files/demo/carrier_file_data.xml @@ -0,0 +1,89 @@ + + + + + Generic + generic + + + disk + /tmp + + + + Generic Manual + generic + + + disk + /tmp + + + + + + + + + + + + Refrigerator + internal + + + + Delivery Counter + internal + + + + opening + inventory + + + + + + + + Outgoing Ice Cream + outgoing + + + + + + + + + + + + Outgoing Ice Cream Move + + + + 130.0 + + + + + + + + + + + + + Outgoing Ice Cream Move Manual + + + + 130.0 + + + + + diff --git a/base_delivery_carrier_files/test/carrier_file_test_data.xml b/base_delivery_carrier_files/test/carrier_file_test_data.xml deleted file mode 100644 index c906f39348..0000000000 --- a/base_delivery_carrier_files/test/carrier_file_test_data.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - Generic - generic - - - disk - /tmp - - - - Generic Manual - generic - - - disk - /tmp - - - - - - - - - - - - - - - - - - - Delivery Counter - internal - - - - opening - inventory - - - - 001 - Ice Cream - product - - 100.0 - 70.0 - - - - real_time - average - - - - - - Outgoing Ice Cream - outgoing - - - - - - - - - - - - - - 130.0 - - - - - - diff --git a/base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py b/base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py index 84fe889ba3..f4034496a2 100644 --- a/base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py +++ b/base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py @@ -5,16 +5,11 @@ import tempfile -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class CarrierFilesTest(TransactionCase): - def setUp(self): - super(CarrierFilesTest, self).setUp() - self._load('account', 'test', 'account_minimal_test.xml') - self._load('base_delivery_carrier_files', 'test', 'carrier_file_test_data.xml') - def test_carrier_file_generation(self): """ Test carrier file generation """ # I configure the carrier file configuration @@ -26,11 +21,6 @@ def test_carrier_file_generation(self): 'write_mode': 'disk' }) - # I set the carrier file configuration on the carrier - # 'Free delivery charges' - carrier = self.env.ref('delivery.delivery_carrier') - carrier.carrier_file_id = carrier_file.id - # I confirm outgoing shipment of 130 kgm Ice-cream. picking = self.env.ref( 'base_delivery_carrier_files.outgoing_shipment_carrier_file') @@ -40,14 +30,7 @@ def test_carrier_file_generation(self): picking.force_assign() # I deliver outgoing shipment. - wizard = self.env['stock.transfer_details'].with_context({ - 'active_model': 'stock.picking', - 'active_id': picking.id, - 'active_ids': picking.ids - }).create({ - 'picking_id': picking.id - }) - wizard.do_detailed_transfer() + picking.do_transfer() # I check shipment details after shipment # The carrier file must have been generated. @@ -63,17 +46,12 @@ def test_manual_carrier_file_generation(self): # I configure the carrier file configuration # to write to the root document directory. carrier_file = self.env.ref( - 'base_delivery_carrier_files.delivery_carrier_file') + 'base_delivery_carrier_files.delivery_carrier_file_manual') carrier_file.write({ 'export_path': tempfile.gettempdir(), 'write_mode': 'disk' }) - # I set the carrier file configuration on the carrier - # 'Free delivery charges' - carrier = self.env.ref('delivery.delivery_carrier') - carrier.carrier_file_id = carrier_file.id - # I confirm outgoing shipment of 130 kgm Ice-cream. picking = self.env.ref( 'base_delivery_carrier_files' @@ -84,14 +62,7 @@ def test_manual_carrier_file_generation(self): picking.force_assign() # I deliver outgoing shipment. - wizard = self.env['stock.transfer_details'].with_context({ - 'active_model': 'stock.picking', - 'active_id': picking.id, - 'active_ids': picking.ids - }).create({ - 'picking_id': picking.id - }) - wizard.do_detailed_transfer() + picking.do_transfer() # I check shipment details after shipment # The carrier file must NOT have been generated. diff --git a/base_delivery_carrier_files/views/carrier_file_view.xml b/base_delivery_carrier_files/views/carrier_file_view.xml index 622ecf7075..b637ea02f4 100644 --- a/base_delivery_carrier_files/views/carrier_file_view.xml +++ b/base_delivery_carrier_files/views/carrier_file_view.xml @@ -18,17 +18,16 @@ delivery.carrier.file
- - - - - - - + + + + + + + + - - - + diff --git a/base_delivery_carrier_files_document/demo/carrier_file_demo.xml b/base_delivery_carrier_files_document/demo/carrier_file_demo.xml index 2f602ad865..d528b61f9a 100644 --- a/base_delivery_carrier_files_document/demo/carrier_file_demo.xml +++ b/base_delivery_carrier_files_document/demo/carrier_file_demo.xml @@ -1,19 +1,15 @@ - - - - Automatic carrier file - document - generic - + + + document + generic + - - Manual carrier file - document - generic - + + document + generic + - diff --git a/base_delivery_carrier_files_document/models/delivery_carrier_file.py b/base_delivery_carrier_files_document/models/delivery_carrier_file.py index 00141c15b2..0cd82f2b55 100644 --- a/base_delivery_carrier_files_document/models/delivery_carrier_file.py +++ b/base_delivery_carrier_files_document/models/delivery_carrier_file.py @@ -5,7 +5,7 @@ import base64 -from openerp import api, models, fields +from openerp import api, models class DeliveryCarrierFile(models.Model): diff --git a/base_delivery_carrier_files_document/tests/test_base_delivery_carrier_files_document.py b/base_delivery_carrier_files_document/tests/test_base_delivery_carrier_files_document.py index 3825caa3dd..32f1744ca7 100644 --- a/base_delivery_carrier_files_document/tests/test_base_delivery_carrier_files_document.py +++ b/base_delivery_carrier_files_document/tests/test_base_delivery_carrier_files_document.py @@ -30,67 +30,13 @@ def test_carrier_file_generation(self): picking.force_assign() # I deliver outgoing shipment. - wizard = self.env['stock.transfer_details'].with_context({ - 'active_model': 'stock.picking', - 'active_id': picking.id, - 'active_ids': picking.ids - }).create({ - 'picking_id': picking.id - }) - wizard.do_detailed_transfer() + domain = [('datas_fname', '=ilike', '%.csv')] + count_before = self.env['ir.attachment'].search_count(domain) + picking.do_transfer() + count_after = self.env['ir.attachment'].search_count(domain) # I check shipment details after shipment # The carrier file must have been generated. self.assertTrue(picking.carrier_file_generated) - - # I check outgoing shipment copy - # The carrier_file_generated field must be unchecked. - new_picking = picking.copy() - self.assertFalse(new_picking.carrier_file_generated) - - def test_manual_carrier_file_generation(self): - """ Test manual carrier file generation """ - carrier_file = self.env.ref( - 'base_delivery_carrier_files.delivery_carrier_file_manual') - - # Save as attachment - carrier_file.write({'write_mode': 'document'}) - - # I set the carrier file configuration on the carrier - # 'Free delivery charges' - carrier = self.env.ref('delivery.delivery_carrier') - carrier.carrier_file_id = carrier_file.id - - # I confirm outgoing shipment of 130 kgm Ice-cream. - picking = self.env.ref( - 'base_delivery_carrier_files' - '.outgoing_shipment_carrier_file_manual') - picking.action_confirm() - - # I check outgoing shipment after stock availablity in refrigerator. - picking.force_assign() - - # I deliver outgoing shipment. - wizard = self.env['stock.transfer_details'].with_context({ - 'active_model': 'stock.picking', - 'active_id': picking.id, - 'active_ids': picking.ids - }).create({ - 'picking_id': picking.id - }) - wizard.do_detailed_transfer() - - # I check shipment details after shipment - # The carrier file must NOT have been generated. - self.assertFalse(picking.carrier_file_generated) - - # I generate the carrier files of my shipment from the wizard - wizard = self.env['delivery.carrier.file.generate'].with_context({ - 'active_ids': picking.ids, - 'active_model': 'stock.picking' - }).create({}) - wizard.action_generate() - - # I check shipment details after manual generation - # The carrier file must have been generated. - self.assertTrue(picking.carrier_file_generated) + # The carrier file attachment must be there + self.assertEquals(count_after - count_before, 1) diff --git a/base_delivery_carrier_files_document/views/carrier_file_view.xml b/base_delivery_carrier_files_document/views/carrier_file_view.xml deleted file mode 100644 index 1dc55e51b9..0000000000 --- a/base_delivery_carrier_files_document/views/carrier_file_view.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - delivery.carrier.file.form - delivery.carrier.file - - - - - - - - - -