Skip to content

Commit

Permalink
[FIX] base_delivery_carrier_files: more fixes on migration to 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Jul 17, 2019
1 parent c4bc4f3 commit ac19795
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 143 deletions.
9 changes: 1 addition & 8 deletions base_delivery_carrier_files/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@
'wizards/generate_carrier_files_view.xml',
'security/ir.model.access.csv'
],
'demo': [
'demo/carrier_file_demo.xml',
'demo/carrier_file_demo.yml'
],
'summary': """
Base module for creation of carrier files (La Poste, TNT Express Shipper, ...).
Files are exported as text (csv, ...).
""",
'summary': 'Base module for creation of delivery carrier files',
'images': [],
'installable': True,
'auto_install': False,
Expand Down
36 changes: 0 additions & 36 deletions base_delivery_carrier_files/demo/carrier_file_demo.xml

This file was deleted.

64 changes: 0 additions & 64 deletions base_delivery_carrier_files/demo/carrier_file_demo.yml

This file was deleted.

104 changes: 104 additions & 0 deletions base_delivery_carrier_files/test/carrier_file_test_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">

<!-- Carrier File -->

<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>

<!-- Assign the carrier files on the delivery method -->

<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="Refrigerator"/>
<field usage="internal"/>
</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="product_icecream" model="product.product">
<field name="default_code">001</field>
<field name="name">Ice Cream</field>
<field name="type">product</field>
<field name="categ_id" ref="product.product_category_1"/>
<field name="list_price">100.0</field>
<field name="standard_price">70.0</field>
<field name="uom_id" ref="product.product_uom_kgm"/>
<field name="uom_po_id" ref="product.product_uom_kgm"/>
<field name="property_stock_inventory" ref="base_delivery_carrier_files.location_opening"/>
<field name="valuation">real_time</field>
<field name="cost_method">average</field>
<field name="property_stock_account_input" ref="account.o_expense"/>
<field name="property_stock_account_output" ref="account.o_income"/>
</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_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="picking_id" ref="base_delivery_carrier_files.outgoing_shipment_icecream_carrier_file"/>
<field name="product_id" ref="base_delivery_carrier_files.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 {model: stock.picking.type, id: outgoing_shipment_type_carrier_file_manual}:
name: Outgoing Ice Cream
code: outgoing
sequence_id: stock.sequence_mrp_op
-
!record {model: stock.picking, id: outgoing_shipment_carrier_file_manual}:
picking_type_id: outgoing_shipment_type_carrier_file_manual
location_dest_id: location_delivery_counter
carrier_id: delivery.free_delivery_carrier
-
!record {model: stock.move, id: outgoing_shipment_icecream_carrier_file_manual}:
picking_id: outgoing_shipment_carrier_file_manual
product_id: product_icecream
product_uom: product.product_uom_kgm
product_uom_qty: 130.0
location_id: location_refrigerator
location_dest_id: location_delivery_counter -->
</data>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

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 Down
8 changes: 5 additions & 3 deletions base_delivery_carrier_files/views/carrier_file_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@
<field name="inherit_id" ref="delivery.view_delivery_carrier_form" />
<field name="arch" type="xml">
<data>
<field name="name" position="after">
<field name="carrier_file_id"/>
</field>
<xpath expr="//h1" position="after">
<group>
<field name="carrier_file_id"/>
</group>
</xpath>
</data>
</field>
</record>
Expand Down
8 changes: 3 additions & 5 deletions base_delivery_carrier_files/views/stock_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<data>
<page name="extra" position="inside">
<group>
<field name="carrier_file_generated"/>
</group>
</page>
<group name="carrier_data" position="inside">
<field name="carrier_file_generated"/>
</group>
</data>
</field>
</record>
Expand Down
8 changes: 2 additions & 6 deletions base_delivery_carrier_files_document/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Author: Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Base module for picking carrier files creation for document',
'name': 'Store carrier files as attachments',
'version': '10.0.1.0.0',
'category': 'Generic Modules/Warehouse',
'summary': """
Allow to store the carrier files in a Document directory.
Allow to store carrier files as attachments.
Auto-install when the module Document and
Base Delivery Carrier Files are installed.
""",
Expand All @@ -18,13 +18,9 @@
'base_delivery_carrier_files',
'document'
],
'data': [
'views/carrier_file_view.xml'
],
'demo': [
'demo/carrier_file_demo.xml'
],
'images': [],
'installable': True,
'auto_install': True,
}
13 changes: 7 additions & 6 deletions base_delivery_carrier_files_document/demo/carrier_file_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
<data noupdate="1">

<!-- Carrier File -->

<record id="base_delivery_carrier_files.delivery_carrier_file" model="delivery.carrier.file">
<field name="write_mode">document</field>
<field name="document_directory_id" ref="document.dir_root"/>
</record>
<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>

<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="document_directory_id" ref="document.dir_root"/>
<field name="type">generic</field>
</record>

</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ def get_write_mode_selection(self):
res.append(('document', 'Document'))
return res

document_directory_id = fields.Many2one('document.directory')

@api.model
def _prepare_attachment(self, carrier_file, filename, file_content):
return {'name': "%s_%s" % (carrier_file.name, filename),
'datas_fname': filename,
'datas': base64.encodestring(file_content),
'parent_id': carrier_file.document_directory_id.id,
'type': 'binary'}

@api.multi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ class CarrierFilesDocumentTest(TransactionCase):

def test_carrier_file_generation(self):
""" Test carrier file generation """
# I set the system tempfile on the carrier file configuration
# to be sure the path will be writable
carrier_file = self.env.ref(
'base_delivery_carrier_files.delivery_carrier_file')
carrier_file.write({
'document_directory_id': self.env.ref('document.dir_root').id,
'write_mode': 'document'
})

# Save as attachment
carrier_file.write({'write_mode': 'document'})

# I set the carrier file configuration on the carrier
# 'Free delivery charges'
Expand Down Expand Up @@ -53,14 +50,11 @@ def test_carrier_file_generation(self):

def test_manual_carrier_file_generation(self):
""" Test manual carrier file generation """
# I set the system tempfile on the carrier file configuration
# to be sure the path will be writable
carrier_file = self.env.ref(
'base_delivery_carrier_files.delivery_carrier_file_manual')
carrier_file.write({
'document_directory_id': self.env.ref('document.dir_root').id,
'write_mode': 'document'
})

# Save as attachment
carrier_file.write({'write_mode': 'document'})

# I set the carrier file configuration on the carrier
# 'Free delivery charges'
Expand Down

0 comments on commit ac19795

Please sign in to comment.