Skip to content

Commit

Permalink
[MIG] base_delivery_carrier_files_document
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed May 13, 2019
1 parent 6bc7f90 commit 3369d0f
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 217 deletions.
21 changes: 21 additions & 0 deletions base_delivery_carrier_files_document/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

A good, one sentence summary in the manifest is also highly recommended.
24 changes: 4 additions & 20 deletions base_delivery_carrier_files_document/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Copyright 2012 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2012 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import carrier_file # noqa
from . import models
from . import tests
50 changes: 16 additions & 34 deletions base_delivery_carrier_files_document/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Guewen Baconnier
# Copyright 2012 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

# Copyright 2012 Camptocamp SA
# 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',
'version': '1.0.1',
'version': '8.0.1.0.1',
'category': 'Generic Modules/Warehouse',
'description': """
Allow to store the carrier files in a Document directory.
Auto-install when the module Document and
Base Delivery Carrier Files are installed.
""",
'author': "Camptocamp,Odoo Community Association (OCA)",
'author': 'Camptocamp,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'http://www.camptocamp.com',
'depends': ['base_delivery_carrier_files',
'document'],
'data': ['carrier_file_view.xml'],
'demo': ['carrier_file_demo.xml'],
'test': ['test/carrier_file.yml',
'test/carrier_file_manual.yml'],
'depends': [
'base_delivery_carrier_files',
'document'
],
'data': [
'views/carrier_file_view.xml'
],
'demo': [
'demo/carrier_file_demo.xml'
],
'images': [],
'installable': False,
'installable': True,
'auto_install': True,
}
72 changes: 0 additions & 72 deletions base_delivery_carrier_files_document/carrier_file.py

This file was deleted.

5 changes: 5 additions & 0 deletions base_delivery_carrier_files_document/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import delivery_carrier_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Camptocamp SA
# Author: Guewen Baconnier
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import base64

from openerp import api, models, fields


class DeliveryCarrierFile(models.Model):
_inherit = 'delivery.carrier.file'

@api.model
def get_write_mode_selection(self):
res = super(DeliveryCarrierFile, self).get_write_mode_selection()
if 'document' not in [a[0] for a in res]:
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
def _write_file(self, filename, file_content):
ret = True
for this in self:
if this.write_mode == 'document':
vals = self._prepare_attachment(
this, filename, file_content)
self.env['ir.attachment'].create(vals)
ret &= True
else:
ret &= super(DeliveryCarrierFile, this)._write_file(
filename, file_content)
return ret
2 changes: 2 additions & 0 deletions base_delivery_carrier_files_document/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Guewen Baconnier <[email protected]>
* Tom Blauwendraat <[email protected]>
3 changes: 3 additions & 0 deletions base_delivery_carrier_files_document/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Allows to store the delivery carrier files in a Document directory.
Auto-installs when the module Document and Base Delivery Carrier Files are installed.

40 changes: 0 additions & 40 deletions base_delivery_carrier_files_document/test/carrier_file.yml

This file was deleted.

51 changes: 0 additions & 51 deletions base_delivery_carrier_files_document/test/carrier_file_manual.yml

This file was deleted.

5 changes: 5 additions & 0 deletions base_delivery_carrier_files_document/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_base_delivery_carrier_files_document
Loading

0 comments on commit 3369d0f

Please sign in to comment.