Skip to content

Commit

Permalink
Merge pull request #56 from ursais/12.0-mig-mrp_bom_structure_xlsx
Browse files Browse the repository at this point in the history
[12.0][MIG] mrp_bom_structure_xlsx: Migration to 12.0
  • Loading branch information
pedrobaeza authored May 28, 2019
2 parents 1e4879d + 813d13a commit 5ecbabb
Show file tree
Hide file tree
Showing 15 changed files with 822 additions and 0 deletions.
95 changes: 95 additions & 0 deletions mrp_bom_structure_xlsx/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
===================================
Export BOM Structure to Excel .XLSX
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture-reporting/tree/12.0/mrp_bom_structure_xlsx
:alt: OCA/manufacture-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-reporting-12-0/manufacture-reporting-12-0-mrp_bom_structure_xlsx
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/131/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of the MRP capabilities of Odoo,
and allow you to export the BOM structure to MS Excel .XLSX format.

**Table of contents**

.. contents::
:local:

Installation
============

To install this module, you need to:

#. Go to apps
#. Look for mrp_bom_structure_xlsx module
#. Click install

Usage
=====

To use this module, you need to:

Go to the Bill of Materials form or list views, press 'Print > Export BOM
Structure to Excel'.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture-reporting/issues/new?body=module:%20mrp_bom_structure_xlsx%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Eficent

Contributors
~~~~~~~~~~~~

* Jordi Ballester <[email protected]>
* Miquel Raïch <[email protected]>
* Lois Rilo Antelo <[email protected]>
* Aaron Henriquez <[email protected]>
* Bhavesh Odedra <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/manufacture-reporting <https://github.com/OCA/manufacture-reporting/tree/12.0/mrp_bom_structure_xlsx>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions mrp_bom_structure_xlsx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import report
18 changes: 18 additions & 0 deletions mrp_bom_structure_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
'name': "Export BOM Structure to Excel .XLSX",
'version': '12.0.1.0.0',
'category': 'Manufacturing',
'summary': 'Export Bill of Materials Structure',
'author': "Eficent, Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/manufacture-reporting',
'license': 'AGPL-3',
"depends": ['report_xlsx', 'mrp'],
"data": [
'report/bom_structure_xlsx.xml',
],
"installable": True
}
92 changes: 92 additions & 0 deletions mrp_bom_structure_xlsx/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_structure_xlsx
#
# Translators:
# OCA Transbot <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-25 03:44+0000\n"
"PO-Revision-Date: 2017-11-25 03:44+0000\n"
"Last-Translator: OCA Transbot <[email protected]>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:47
#, python-format
msgid "BOM Name"
msgstr "SL-Name"

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:35
#, python-format
msgid "BOM Structure"
msgstr "Struktur-SL"

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx_display_name
msgid "Display Name"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.actions.report,name:mrp_bom_structure_xlsx.bom_structure_xlsx
msgid "Export BOM Structure to Excel"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx_id
msgid "ID"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx___last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:48
#, python-format
msgid "Level"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:50
#, python-format
msgid "Product Name"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:49
#, python-format
msgid "Product Reference"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:51
#, python-format
msgid "Quantity"
msgstr "Menge"

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:53
#, python-format
msgid "Reference"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:52
#, python-format
msgid "Unit of Measure"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model,name:mrp_bom_structure_xlsx.model_report_mrp_bom_structure_xlsx_bom_structure_xlsx
msgid "report.mrp_bom_structure_xlsx.bom_structure_xlsx"
msgstr ""
88 changes: 88 additions & 0 deletions mrp_bom_structure_xlsx/i18n/mrp_bom_structure_xlsx.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_bom_structure_xlsx
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:47
#, python-format
msgid "BOM Name"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:35
#, python-format
msgid "BOM Structure"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx_display_name
msgid "Display Name"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.actions.report,name:mrp_bom_structure_xlsx.bom_structure_xlsx
msgid "Export BOM Structure to Excel"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx_id
msgid "ID"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model.fields,field_description:mrp_bom_structure_xlsx.field_report_mrp_bom_structure_xlsx_bom_structure_xlsx___last_update
msgid "Last Modified on"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:48
#, python-format
msgid "Level"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:50
#, python-format
msgid "Product Name"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:49
#, python-format
msgid "Product Reference"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:51
#, python-format
msgid "Quantity"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:53
#, python-format
msgid "Reference"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: code:addons/mrp_bom_structure_xlsx/report/bom_structure_xlsx.py:52
#, python-format
msgid "Unit of Measure"
msgstr ""

#. module: mrp_bom_structure_xlsx
#: model:ir.model,name:mrp_bom_structure_xlsx.model_report_mrp_bom_structure_xlsx_bom_structure_xlsx
msgid "report.mrp_bom_structure_xlsx.bom_structure_xlsx"
msgstr ""

5 changes: 5 additions & 0 deletions mrp_bom_structure_xlsx/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Jordi Ballester <[email protected]>
* Miquel Raïch <[email protected]>
* Lois Rilo Antelo <[email protected]>
* Aaron Henriquez <[email protected]>
* Bhavesh Odedra <[email protected]>
2 changes: 2 additions & 0 deletions mrp_bom_structure_xlsx/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of the MRP capabilities of Odoo,
and allow you to export the BOM structure to MS Excel .XLSX format.
5 changes: 5 additions & 0 deletions mrp_bom_structure_xlsx/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To install this module, you need to:

#. Go to apps
#. Look for mrp_bom_structure_xlsx module
#. Click install
4 changes: 4 additions & 0 deletions mrp_bom_structure_xlsx/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To use this module, you need to:

Go to the Bill of Materials form or list views, press 'Print > Export BOM
Structure to Excel'.
2 changes: 2 additions & 0 deletions mrp_bom_structure_xlsx/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import bom_structure_xlsx
70 changes: 70 additions & 0 deletions mrp_bom_structure_xlsx/report/bom_structure_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

import logging
from odoo import models
from odoo.tools.translate import _

_logger = logging.getLogger(__name__)


class BomStructureXlsx(models.AbstractModel):
_name = 'report.mrp_bom_structure_xlsx.bom_structure_xlsx'
_inherit = 'report.report_xlsx.abstract'

def print_bom_children(self, ch, sheet, row, level):
i, j = row, level
j += 1
sheet.write(i, 1, '> '*j)
sheet.write(i, 2, ch.product_id.default_code or '')
sheet.write(i, 3, ch.product_id.display_name or '')
sheet.write(i, 4, ch.product_uom_id._compute_quantity(
ch.product_qty, ch.product_id.uom_id) or '')
sheet.write(i, 5, ch.product_id.uom_id.name or '')
sheet.write(i, 6, ch.bom_id.code or '')
i += 1
for child in ch.child_line_ids:
i = self.print_bom_children(child, sheet, i, j)
j -= 1
return i

def generate_xlsx_report(self, workbook, data, objects):
workbook.set_properties({
'comments': 'Created with Python and XlsxWriter from Odoo 11.0'})
sheet = workbook.add_worksheet(_('BOM Structure'))
sheet.set_landscape()
sheet.fit_to_pages(1, 0)
sheet.set_zoom(80)
sheet.set_column(0, 0, 40)
sheet.set_column(1, 2, 20)
sheet.set_column(3, 3, 40)
sheet.set_column(4, 6, 20)
bold = workbook.add_format({'bold': True})
title_style = workbook.add_format({'bold': True,
'bg_color': '#FFFFCC',
'bottom': 1})
sheet_title = [_('BOM Name'),
_('Level'),
_('Product Reference'),
_('Product Name'),
_('Quantity'),
_('Unit of Measure'),
_('Reference')
]
sheet.set_row(0, None, None, {'collapsed': 1})
sheet.write_row(1, 0, sheet_title, title_style)
sheet.freeze_panes(2, 0)
i = 2
for o in objects:
sheet.write(i, 0, o.product_tmpl_id.name or '', bold)
sheet.write(i, 1, '', bold)
sheet.write(i, 2, o.product_id.default_code or '', bold)
sheet.write(i, 3, o.product_id.name or '', bold)
sheet.write(i, 4, o.product_qty, bold)
sheet.write(i, 5, o.product_uom_id.name or '', bold)
sheet.write(i, 6, o.code or '', bold)
i += 1
j = 0
for ch in o.bom_line_ids:
i = self.print_bom_children(ch, sheet, i, j)
Loading

0 comments on commit 5ecbabb

Please sign in to comment.