Skip to content

Commit

Permalink
[MIG] base_delivery_carrier_files: Migration to 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mFlayyan committed May 9, 2019
1 parent f29f1d2 commit 0b5a08d
Show file tree
Hide file tree
Showing 26 changed files with 308 additions and 283 deletions.
33 changes: 33 additions & 0 deletions base_delivery_carrier_files/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

===========================
base_delivery_carrier_files
===========================

This module was written to extend the functionality of picking to support generating one or more files according to carrier_file configuration for all pickings
and writes this file to a configurable location on your computer eg. /opt/data/carrier_files

Discription:
Base module for creation of carrier files (La Poste, TNT Express Shipper, ...).
Files are exported as text (csv, ...).
It contains :
- the base structure to handle the export of files on Delivery Orders
- an API to ease the generation of the files for the developers in sub-modules.

The delivery orders can be grouped in one files
or be exported each one in a separate file.
The files can be generated automatically
on the shipment of a Delivery Order or from a manual action.
They are exported to a defined path or
in a document directory of your choice if the "document" module is installed.

A generic carrier file is included in the module.
It can also be used as a basis to create your own sub-module.

Sub-modules already exist to generate file according to specs of :
- La Poste (France) : delivery_carrier_file_laposte
- TNT Express Shipper (France) : delivery_carrier_file_tnt
- Make your own ! Look at the code of the modules above,
it's trivial to create a sub-module for a carrier.
29 changes: 5 additions & 24 deletions base_delivery_carrier_files/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,11 @@

{
'name': 'Base Delivery Carrier Files',
'version': '8.0.1.2.4',
'version': '10.0.1.0.1',
'category': 'Generic Modules/Warehouse',
'description': """
'summary': """
Base module for creation of carrier files (La Poste, TNT Express Shipper, ...).
Files are exported as text (csv, ...).
It contains :
- the base structure to handle the export of files on Delivery Orders
- an API to ease the generation of the files for the developers in sub-modules.
The delivery orders can be grouped in one files
or be exported each one in a separate file.
The files can be generated automatically
on the shipment of a Delivery Order or from a manual action.
They are exported to a defined path or
in a document directory of your choice if the "document" module is installed.
A generic carrier file is included in the module.
It can also be used as a basis to create your own sub-module.
Sub-modules already exist to generate file according to specs of :
- La Poste (France) : delivery_carrier_file_laposte
- TNT Express Shipper (France) : delivery_carrier_file_tnt
- Make your own ! Look at the code of the modules above,
it's trivial to create a sub-module for a carrier.
""",
'author': "Camptocamp,Odoo Community Association (OCA)",
'license': 'AGPL-3',
Expand All @@ -58,8 +38,9 @@
'wizard/generate_carrier_files_view.xml',
'security/ir.model.access.csv'],
'demo': ['carrier_file_demo.xml', 'carrier_file_demo.yml'],
'test': ['test/carrier_file.yml',
'test/carrier_file_manual.yml'],
'test': [ '../account/test/account_minimal_test.xml',
'test/carrier_file.yml',
'test/carrier_file_manual.yml'],
'images': [],
'installable': True,
'auto_install': False,
Expand Down
22 changes: 12 additions & 10 deletions base_delivery_carrier_files/carrier_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import os
import logging

from openerp import models, fields, api, exceptions
from openerp.tools.translate import _
from odoo import api, exceptions, fields, models
from odoo.tools.translate import _
from .generator import new_file_generator


Expand Down Expand Up @@ -66,7 +66,7 @@ def _write_file(self, filename, file_content):
file_handle.write(file_content)
return True

@api.one
@api.model
def _generate_files(self, picking_ids):
"""
Generate one or more files according to carrier_file configuration
Expand Down Expand Up @@ -105,7 +105,7 @@ def _generate_files(self, picking_ids):
picking_ids, e)
return True

@api.one
@api.model
def generate_files(self, picking_ids):
"""
Generate one or more files according to carrier_file
Expand All @@ -123,24 +123,26 @@ def generate_files(self, picking_ids):
name = fields.Char('Name', size=64, required=True)
type = fields.Selection(selection='get_type_selection',
string='Type', required=True)
group_pickings = fields.Boolean('Group all pickings in one file',
help='All the pickings will be '
group_pickings = fields.Boolean(help='All the pickings will be '
'grouped in the same file. '
'Has no effect when the files '
'are automatically exported at '
'the delivery order process.')
write_mode = fields.Selection(selection='get_write_mode_selection',
string='Write on', required=True)
export_path = fields.Char('Export Path', size=256)
auto_export = fields.Boolean('Export at delivery order process',
help='The file will be automatically '
auto_export = fields.Boolean(help='The file will be automatically '
'generated when a delivery order '
'is processed. If activated, each '
'delivery order will be exported '
'in a separate file.')


class delivery_carrier(models.Model):
class DeliveryCarrier(models.Model):
_inherit = 'delivery.carrier'

carrier_file_id = fields.Many2one('delivery.carrier.file', 'Carrier File')
carrier_file_id = fields.Many2one('delivery.carrier.file',
'Carrier File',
relation='dlv_carrier_dlv_file_rel',
column1='delivery_carrier',
column2='delivery_carrier_file')
4 changes: 2 additions & 2 deletions base_delivery_carrier_files/carrier_file_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">

<!-- Carrier File -->
Expand Down Expand Up @@ -33,4 +33,4 @@
</record>

</data>
</openerp>
</odoo>
105 changes: 51 additions & 54 deletions base_delivery_carrier_files/carrier_file_view.xml
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="view_delivery_carrier_file_tree" model="ir.ui.view">
<field name="name">delivery.carrier.file.tree</field>
<field name="model">delivery.carrier.file</field>
<field name="arch" type="xml">
<tree string="Carrier File">
<field name="name"/>
<field name="type"/>
<field name="auto_export"/>
<field name="group_pickings"/>
</tree>
</field>
</record>

<record id="view_delivery_carrier_file_tree" model="ir.ui.view">
<field name="name">delivery.carrier.file.tree</field>
<field name="model">delivery.carrier.file</field>
<field name="arch" type="xml">
<tree string="Carrier File">
<field name="name"/>
<field name="type"/>
<record id="view_delivery_carrier_file_form" model="ir.ui.view">
<field name="name">delivery.carrier.file.form</field>
<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"/>
</tree>
</field>
</record>

<record id="view_delivery_carrier_file_form" model="ir.ui.view">
<field name="name">delivery.carrier.file.form</field>
<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">
<field name="write_mode"/>
<group colspan="2" col="2">
<field name="export_path" attrs="{'required': [('write_mode', '=', 'disk')], 'invisible': [('write_mode', '!=', 'disk')]}"/>
</group>
<separator string="Write options" colspan="4"/>
<group colspan="4" col="4">
<field name="write_mode"/>
<group colspan="2" col="2">
<field name="export_path" attrs="{'required': [('write_mode', '=', 'disk')], 'invisible': [('write_mode', '!=', 'disk')]}"/>
</group>
</group>
</form>
</field>
</record>
</group>
</form>
</field>
</record>

<record id="action_delivery_carrier_file_form" model="ir.actions.act_window">
<field name="name">Carrier File</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">delivery.carrier.file</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="action_delivery_carrier_file_form" model="ir.actions.act_window">
<field name="name">Carrier File</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">delivery.carrier.file</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem action="action_delivery_carrier_file_form" id="menu_action_delivery_carrier_file_form" parent="delivery.menu_delivery"/>
<menuitem action="action_delivery_carrier_file_form" id="menu_action_delivery_carrier_file_form" parent="delivery.menu_delivery"/>

<record id="view_delivery_carrier_form_inherit" model="ir.ui.view">
<field name="name">delivery.carrier.form.file</field>
<field name="model">delivery.carrier</field>
<field name="inherit_id" ref="delivery.view_delivery_carrier_form" />
<field name="arch" type="xml">
<data>
<field name="product_id" position="after">
<field name="carrier_file_id"/>
</field>
</data>
</field>
</record>
<record id="view_delivery_carrier_form_inherit" model="ir.ui.view">
<field name="name">delivery.carrier.form.file</field>
<field name="model">delivery.carrier</field>
<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>
</data>
</field>
</record>

</data>
</openerp>
</odoo>
1 change: 1 addition & 0 deletions base_delivery_carrier_files/csv_writer/unicode_writer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# CSV writer from python doc
import csv
import codecs
Expand Down
2 changes: 1 addition & 1 deletion base_delivery_carrier_files/generator/generic_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from .file_generator import CarrierFileGenerator
from .base_line import BaseLine
from openerp.addons.base_delivery_carrier_files.csv_writer import UnicodeWriter
from ..csv_writer import UnicodeWriter


class GenericLine(BaseLine):
Expand Down
4 changes: 2 additions & 2 deletions base_delivery_carrier_files/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_delivery_carrier_file,delivery.carrier.file,model_delivery_carrier_file,base.group_sale_salesman,1,0,0,0
access_delivery_carrier_file_manager,delivery.carrier.file manager,model_delivery_carrier_file,base.group_sale_manager,1,1,1,1
access_delivery_carrier_file,delivery.carrier.file,model_delivery_carrier_file,sales_team.group_sale_salesman,1,0,0,0
access_delivery_carrier_file_manager,delivery.carrier.file manager,model_delivery_carrier_file,sales_team.group_sale_manager,1,1,1,1
access_delivery_carrier_file_partner_manager,delivery.carrier.file partner_manager,model_delivery_carrier_file,base.group_partner_manager,1,0,0,0
10 changes: 5 additions & 5 deletions base_delivery_carrier_files/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#
##############################################################################

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


class stock_picking(models.Model):
class StockPicking(models.Model):
_inherit = "stock.picking"

@api.multi
Expand Down Expand Up @@ -68,7 +68,7 @@ def generate_carrier_files(self, auto=True,

@api.multi
def action_done(self):
result = super(stock_picking, self).action_done()
result = super(StockPicking, self).action_done()
self.generate_carrier_files(auto=True)
return result

Expand All @@ -77,12 +77,12 @@ def action_done(self):
help="The file for the delivery carrier has been generated.")


class stock_move(models.Model):
class StockMove(models.Model):
_inherit = 'stock.move'

@api.multi
def write(self, values):
write_result = super(stock_move, self).write(values)
write_result = super(StockMove, self).write(values)
if values.get('state') and values['state'] == 'done':
picking_ids = map(lambda p: p.id, self.mapped('picking_id'))
done_pickings = self.env['stock.picking'].search([
Expand Down
Loading

0 comments on commit 0b5a08d

Please sign in to comment.