Skip to content

Commit

Permalink
fixup! [FIX] base_delivery_carrier_files: more fixes on migration to …
Browse files Browse the repository at this point in the history
…10.0
  • Loading branch information
thomaspaulb committed Jul 17, 2019
1 parent f815316 commit 947cf64
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 238 deletions.
6 changes: 4 additions & 2 deletions base_delivery_carrier_files/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
89 changes: 89 additions & 0 deletions base_delivery_carrier_files/demo/carrier_file_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="delivery_carrier_file" model="delivery.carrier.file">
<field name="name">Generic</field>
<field name="type">generic</field>
<field name="auto_export" eval="True"/>
<field name="group_pickings" eval="False"/>
<field name="write_mode">disk</field>
<field name="export_path">/tmp</field>
</record>

<record id="delivery_carrier_file_manual" model="delivery.carrier.file">
<field name="name">Generic Manual</field>
<field name="type">generic</field>
<field name="auto_export" eval="False"/>
<field name="group_pickings" eval="True"/>
<field name="write_mode">disk</field>
<field name="export_path">/tmp</field>
</record>

<record id="delivery.delivery_carrier" model="delivery.carrier">
<field name="carrier_file_id" ref="delivery_carrier_file"/>
</record>

<record id="delivery.free_delivery_carrier" model="delivery.carrier">
<field name="carrier_file_id" ref="delivery_carrier_file_manual"/>
</record>

<record id="location_refrigerator" model="stock.location">
<field name="name">Refrigerator</field>
<field name="usage">internal</field>
</record>

<record id="location_delivery_counter" model="stock.location">
<field name="name">Delivery Counter</field>
<field name="usage">internal</field>
</record>

<record id="location_opening" model="stock.location">
<field name="name">opening</field>
<field name="usage">inventory</field>
</record>

<record id="stock.product_icecream" model="product.product">
<field name="property_stock_inventory" ref="base_delivery_carrier_files.location_opening"/>
</record>

<record id="outgoing_shipment_type_carrier_file" model="stock.picking.type">
<field name="name">Outgoing Ice Cream</field>
<field name="code">outgoing</field>
<field name="sequence_id" ref="stock.sequence_mrp_op"/>
</record>

<record id="outgoing_shipment_carrier_file" model="stock.picking">
<field name="picking_type_id" ref="base_delivery_carrier_files.outgoing_shipment_type_carrier_file"/>
<field name="location_id" ref="base_delivery_carrier_files.location_refrigerator"/>
<field name="location_dest_id" ref="base_delivery_carrier_files.location_delivery_counter"/>
<field name="carrier_id" ref="delivery.delivery_carrier"/>
</record>

<record id="outgoing_shipment_icecream_carrier_file" model="stock.move">
<field name="name">Outgoing Ice Cream Move</field>
<field name="picking_id" ref="base_delivery_carrier_files.outgoing_shipment_carrier_file"/>
<field name="product_id" ref="stock.product_icecream"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_uom_qty">130.0</field>
<field name="location_id" ref="base_delivery_carrier_files.location_refrigerator"/>
<field name="location_dest_id" ref="base_delivery_carrier_files.location_delivery_counter"/>
</record>

<record id="outgoing_shipment_carrier_file_manual" model="stock.picking">
<field name="picking_type_id" ref="base_delivery_carrier_files.outgoing_shipment_type_carrier_file"/>
<field name="location_id" ref="base_delivery_carrier_files.location_refrigerator"/>
<field name="location_dest_id" ref="base_delivery_carrier_files.location_delivery_counter"/>
<field name="carrier_id" ref="delivery.free_delivery_carrier"/>
</record>

<record id="outgoing_shipment_icecream_carrier_file" model="stock.move">
<field name="name">Outgoing Ice Cream Move Manual</field>
<field name="picking_id" ref="base_delivery_carrier_files.outgoing_shipment_carrier_file_manual"/>
<field name="product_id" ref="stock.product_icecream"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_uom_qty">130.0</field>
<field name="location_id" ref="base_delivery_carrier_files.location_refrigerator"/>
<field name="location_dest_id" ref="base_delivery_carrier_files.location_delivery_counter"/>
</record>

</odoo>
104 changes: 0 additions & 104 deletions base_delivery_carrier_files/test/carrier_file_test_data.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand All @@ -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.
Expand All @@ -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'
Expand All @@ -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.
Expand Down
19 changes: 9 additions & 10 deletions base_delivery_carrier_files/views/carrier_file_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
<field name="model">delivery.carrier.file</field>
<field name="arch" type="xml">
<form string="Carrier File">
<group colspan="4" col="4" name="general">
<field name="name" select="1"/>
<field name="type" select="1"/>
<field name="auto_export"/>
<field name="group_pickings"/>
<separator string="Write options" colspan="4"/>
<group colspan="4" col="4">
<group name="general">
<group>
<field name="name" select="1"/>
<field name="type" select="1"/>
<field name="auto_export"/>
<field name="group_pickings"/>
</group>
<group string="Write options">
<field name="write_mode"/>
<group colspan="2" col="2">
<field name="export_path" attrs="{'required': [('write_mode', '=', 'disk')], 'invisible': [('write_mode', '!=', 'disk')]}"/>
</group>
<field name="export_path" attrs="{'required': [('write_mode', '=', 'disk')], 'invisible': [('write_mode', '!=', 'disk')]}"/>
</group>
</group>
</form>
Expand Down
22 changes: 9 additions & 13 deletions base_delivery_carrier_files_document/demo/carrier_file_demo.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<!-- Carrier File -->
<record id="base_delivery_carrier_files.delivery_carrier_file" model="delivery.carrier.file">
<field name="name">Automatic carrier file</field>
<field name="write_mode">document</field>
<field name="type">generic</field>
</record>
<!-- Carrier File -->
<record id="base_delivery_carrier_files.delivery_carrier_file" model="delivery.carrier.file">
<field name="write_mode">document</field>
<field name="type">generic</field>
</record>

<record id="base_delivery_carrier_files.delivery_carrier_file_manual" model="delivery.carrier.file">
<field name="name">Manual carrier file</field>
<field name="write_mode">document</field>
<field name="type">generic</field>
</record>
<record id="base_delivery_carrier_files.delivery_carrier_file_manual" model="delivery.carrier.file">
<field name="write_mode">document</field>
<field name="type">generic</field>
</record>

</data>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import base64

from openerp import api, models, fields
from openerp import api, models


class DeliveryCarrierFile(models.Model):
Expand Down
Loading

0 comments on commit 947cf64

Please sign in to comment.