diff --git a/bom_components_image/README.rst b/bom_components_image/README.rst new file mode 100644 index 000000000..807b5871c --- /dev/null +++ b/bom_components_image/README.rst @@ -0,0 +1,13 @@ +BOM Product Image v10 +===================== +This app allows to view the image of bill of materials in odoo manufacturing software. BOM +images are automatically fetched into Manufacturing orders, when user creates it. Also adds the +BOM images to reports such as Production Order, BOM Cost and BOM Structure. + +Features +======== +* Smart button to show where the current product is a component of BOM. +* Edit or delete product image in BOM. +* Get BOM product images into manufacturing Orders by default. +* Includes BOM images to reports such as Production Order, BOM Cost and BOM Structure. + diff --git a/bom_components_image/__init__.py b/bom_components_image/__init__.py new file mode 100644 index 000000000..1a13a0b37 --- /dev/null +++ b/bom_components_image/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import models +import report diff --git a/bom_components_image/__manifest__.py b/bom_components_image/__manifest__.py new file mode 100644 index 000000000..73cb4f643 --- /dev/null +++ b/bom_components_image/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +{ + 'name': 'BoM Product Image', + 'version': '10.0.1.0.0', + 'summary': 'Allow To View BoM Images', + 'description': 'Includes Bill Of Material Component Image to MRP module', + 'category': 'Manufacturing', + 'author': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'company': 'Cybrosys Techno Solutions', + 'depends': ['base', 'product', 'mrp', ], + 'data': [ + 'views/product_bom_view.xml', + 'views/binary_image.xml', + 'views/mrp_bom_structure_report_templates.xml', + 'views/mrp_bom_cost_report_templates.xml', + 'views/mrp_production_templates.xml' + ], + 'qweb': ['static/src/xml/binary.xml', ], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/bom_components_image/models/__init__.py b/bom_components_image/models/__init__.py new file mode 100644 index 000000000..203122164 --- /dev/null +++ b/bom_components_image/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import bom_product diff --git a/bom_components_image/models/bom_product.py b/bom_components_image/models/bom_product.py new file mode 100644 index 000000000..790187abc --- /dev/null +++ b/bom_components_image/models/bom_product.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from odoo import models, fields, api + + +class UsedInBom(models.Model): + _inherit = 'product.template' + + used_bom_count = fields.Integer(compute='_bom_count', string='Count') + + def _bom_count(self): + bom = self.env['mrp.bom'].search([]) + for i in bom: + for j in i.bom_line_ids: + if j.product_id.name == self.name: + self.used_bom_count = self.used_bom_count +1 + + +class MoLineImage(models.Model): + _inherit = 'stock.move' + + image = fields.Binary() + + +class BomLineImage(models.Model): + _inherit = 'mrp.bom.line' + + image = fields.Binary(string="Image") + + @api.multi + @api.onchange('product_id') + def product_id_change(self): + self.image = self.product_id.image_medium + + +class GetMoLineImage(models.Model): + _inherit = 'mrp.production' + + def _generate_raw_move(self, bom_line, line_data): + quantity = line_data['qty'] + alt_op = line_data['parent_line'] and line_data['parent_line'].operation_id.id or False + if bom_line.child_bom_id and bom_line.child_bom_id.type == 'phantom': + return self.env['stock.move'] + if bom_line.product_id.type not in ['product', 'consu']: + return self.env['stock.move'] + if self.bom_id.routing_id and self.bom_id.routing_id.location_id: + source_location = self.bom_id.routing_id.location_id + else: + source_location = self.location_src_id + original_quantity = self.product_qty - self.qty_produced + data = { + 'name': self.name, + 'date': self.date_planned_start, + 'date_expected': self.date_planned_start, + 'bom_line_id': bom_line.id, + 'product_id': bom_line.product_id.id, + 'image': bom_line.image, + 'product_uom_qty': quantity, + 'product_uom': bom_line.product_uom_id.id, + 'location_id': source_location.id, + 'location_dest_id': self.product_id.property_stock_production.id, + 'raw_material_production_id': self.id, + 'company_id': self.company_id.id, + 'operation_id': bom_line.operation_id.id or alt_op, + 'price_unit': bom_line.product_id.standard_price, + 'procure_method': 'make_to_stock', + 'origin': self.name, + 'warehouse_id': source_location.get_warehouse().id, + 'group_id': self.procurement_group_id.id, + 'propagate': self.propagate, + 'unit_factor': quantity / original_quantity, + } + return self.env['stock.move'].create(data) diff --git a/bom_components_image/report/__init__.py b/bom_components_image/report/__init__.py new file mode 100644 index 000000000..134db4676 --- /dev/null +++ b/bom_components_image/report/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + +import mrp_bom_cost_report +import mrp_bom_structure_report diff --git a/bom_components_image/report/mrp_bom_cost_report.py b/bom_components_image/report/mrp_bom_cost_report.py new file mode 100644 index 000000000..c7d47ab68 --- /dev/null +++ b/bom_components_image/report/mrp_bom_cost_report.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + + +from odoo import api, models + + +class MrpBomCost(models.AbstractModel): + _name = 'report.mrp_bom_cost' + + @api.multi + def get_lines(self, boms): + product_lines = [] + for bom in boms: + products = bom.product_id + if not products: + products = bom.product_tmpl_id.product_variant_ids + for product in products: + attributes = [] + for value in product.attribute_value_ids: + attributes += [(value.attribute_id.name, value.name)] + result, result2 = bom.explode(product, 1) + product_line = {'bom': bom, 'name': product.name, 'lines': [], 'total': 0.0, + 'currency': self.env.user.company_id.currency_id, + 'product_uom_qty': bom.product_qty, + 'product_uom': bom.product_uom_id, + 'attributes': attributes} + total = 0.0 + for bom_line, line_data in result2: + price_uom = bom_line.product_id.uom_id._compute_price(bom_line.product_id.standard_price, bom_line.product_uom_id) + line = { + 'product_id': bom_line.product_id, + 'image': bom_line.image, + 'product_uom_qty': line_data['qty'], + 'product_uom': bom_line.product_uom_id, + 'price_unit': price_uom, + 'total_price': price_uom * line_data['qty'], + } + total += line['total_price'] + product_line['lines'] += [line] + product_line['total'] = total + product_lines += [product_line] + return product_lines + + @api.model + def render_html(self, docids, data=None): + boms = self.env['mrp.bom'].browse(docids) + res = self.get_lines(boms) + return self.env['report'].render('bom_components_image.mrp_bom_cost_report1', {'lines': res}) diff --git a/bom_components_image/report/mrp_bom_structure_report.py b/bom_components_image/report/mrp_bom_structure_report.py new file mode 100644 index 000000000..e7b1b4ddf --- /dev/null +++ b/bom_components_image/report/mrp_bom_structure_report.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Treesa Maria Jude() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## + + +from odoo import api, models + + +class BomStructureReport(models.AbstractModel): + _name = 'report.mrp.report_mrpbomstructure' + + def get_children(self, object, level=0): + result = [] + + def _get_rec(object, level, qty=1.0, uom=False): + for l in object: + res = {} + res['pname'] = l.product_id.name_get()[0][1] + res['pcode'] = l.product_id.default_code + qty_per_bom = l.bom_id.product_qty + if uom: + if uom != l.bom_id.product_uom_id: + qty = uom._compute_quantity(qty, l.bom_id.product_uom_id) + res['pqty'] = (l.product_qty *qty)/ qty_per_bom + else: + #for the first case, the ponderation is right + res['pqty'] = (l.product_qty *qty) + res['puom'] = l.product_uom_id + res['uname'] = l.product_uom_id.name + res['level'] = level + res['code'] = l.bom_id.code + res['image'] = l.image + result.append(res) + if l.child_line_ids: + if level < 6: + level += 1 + _get_rec(l.child_line_ids, level, qty=res['pqty'], uom=res['puom']) + if level > 0 and level < 6: + level -= 1 + return result + + children = _get_rec(object, level) + + return children + + @api.multi + def render_html(self, docids, data=None): + docargs = { + 'doc_ids': docids, + 'doc_model': 'mrp.bom', + 'docs': self.env['mrp.bom'].browse(docids), + 'get_children': self.get_children, + 'data': data, + } + return self.env['report'].render('bom_components_image.mrp_bom_structure_report1', docargs) diff --git a/bom_components_image/static/description/banner.jpg b/bom_components_image/static/description/banner.jpg new file mode 100644 index 000000000..64b70d1f2 Binary files /dev/null and b/bom_components_image/static/description/banner.jpg differ diff --git a/bom_components_image/static/description/bom3.png b/bom_components_image/static/description/bom3.png new file mode 100644 index 000000000..97a342f58 Binary files /dev/null and b/bom_components_image/static/description/bom3.png differ diff --git a/bom_components_image/static/description/bom55.png b/bom_components_image/static/description/bom55.png new file mode 100644 index 000000000..103fe03fa Binary files /dev/null and b/bom_components_image/static/description/bom55.png differ diff --git a/bom_components_image/static/description/bom6.png b/bom_components_image/static/description/bom6.png new file mode 100644 index 000000000..ad837ed18 Binary files /dev/null and b/bom_components_image/static/description/bom6.png differ diff --git a/bom_components_image/static/description/bom7.png b/bom_components_image/static/description/bom7.png new file mode 100644 index 000000000..308e8b963 Binary files /dev/null and b/bom_components_image/static/description/bom7.png differ diff --git a/bom_components_image/static/description/bom8.png b/bom_components_image/static/description/bom8.png new file mode 100644 index 000000000..04229acf1 Binary files /dev/null and b/bom_components_image/static/description/bom8.png differ diff --git a/bom_components_image/static/description/icon.png b/bom_components_image/static/description/icon.png new file mode 100644 index 000000000..71690f159 Binary files /dev/null and b/bom_components_image/static/description/icon.png differ diff --git a/bom_components_image/static/description/index.html b/bom_components_image/static/description/index.html new file mode 100644 index 000000000..dddb7ee69 --- /dev/null +++ b/bom_components_image/static/description/index.html @@ -0,0 +1,134 @@ +
+
+

BOM Product Image

+

Includes Bill Of Material Component's Image to MRP module

+

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+

Features:

+
    +
  •    Smart button to show whether the current product is a component of BOM
  • +
  •    Edit or delete product image in BOM
  • +
  •    Get BOM product images into manufacturing Orders by default.
  • +
  •    Includes BOM images to reports such as Production Order, BOM Cost and BOM Structure.
  • + +
+
+
+
+ +
+
+
+

Overview

+

+ This app allows to view the image of bill of materials in odoo manufacturing software. BOM images are automatically fetched into Manufacturing orders, when user creates it. Also adds the + BOM images to reports such as Production Order, BOM Cost and BOM Structure. +

+
+
+
+ + +
+
+

Used In BOM Components

+
+
+
+ +
+
+
+

+ This is to show whether the current product is a component of BOM also press + the button to open all related bill of material. The count is generated + in real time on the Smart button. +

+
+ +
+
+
+ +
+
+

Component's Image In BOM

+
+
+
+ +
+
+
+

+

Manufacturing ---> Bill Of Material ---> Components

+

Here we can edit or delete new images to BOM components. Otherwise default image of the + corresponding product is selected.

+

+
+ +
+
+
+ +
+
+

BOM Product Image In Manufacturing Orders

+
+
+
+ +
+
+
+
+

+ Generate BOM product images automatically, when user creates a manufacturing order. +

+
+
+
+ +
+
+

BOM Product Image In Reports

+
+
+

Production Order

+

Manufacturing --->Manufacturing Orders --->Print --->Production Order

+ +
+
+

BOM Cost

+

Manufacturing --->Bill Of Material --->Print --->BOM Cost

+ +
+ +
+ + +
+

Need Any Help?

+ +
diff --git a/bom_components_image/static/src/js/binary_image.js b/bom_components_image/static/src/js/binary_image.js new file mode 100644 index 000000000..e4124783e --- /dev/null +++ b/bom_components_image/static/src/js/binary_image.js @@ -0,0 +1,47 @@ +odoo.define('bom_components_image.binary_image', function (require) { +"use strict"; + + + var core = require('web.core'); + var session = require('web.session'); + var QWeb = core.qweb; + + + var AllBinaryImage = core.list_widget_registry.get('field').extend({ + + _format: function (row_image, options) { + this.session = session; + + if (!row_image[this.id] || !row_image[this.id].value) { + return ''; + } + var value = row_image[this.id].value, src; + if (this.type === 'binary') { + if (value && value.substr(0, 10).indexOf(' ') === -1) { + src = "data:image/png;base64," + value; + } else { + var imageArgs = { + model: options.model, + field: this.id, + id: options.id + } + if (this.resize) { + imageArgs.resize = this.resize; + } + src = session.url('/web/binary/image', imageArgs); + } + } else { + if (!/\//.test(row_image[this.id].value)) { + src = '/web/static/src/img/icons/' + row_image[this.id].value + '.png'; + } else { + src = row_image[this.id].value; + } + } + + return QWeb.render('ListView.row.imagen', {widget: this, src: src}); + } + }); + + core.list_widget_registry + .add('field.image', AllBinaryImage); +}); diff --git a/bom_components_image/static/src/xml/binary.xml b/bom_components_image/static/src/xml/binary.xml new file mode 100644 index 000000000..646c893ef --- /dev/null +++ b/bom_components_image/static/src/xml/binary.xml @@ -0,0 +1,7 @@ + + + + diff --git a/bom_components_image/views/binary_image.xml b/bom_components_image/views/binary_image.xml new file mode 100644 index 000000000..0c27542bb --- /dev/null +++ b/bom_components_image/views/binary_image.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/bom_components_image/views/mrp_bom_cost_report_templates.xml b/bom_components_image/views/mrp_bom_cost_report_templates.xml new file mode 100644 index 000000000..b95277c4f --- /dev/null +++ b/bom_components_image/views/mrp_bom_cost_report_templates.xml @@ -0,0 +1,65 @@ + + + + diff --git a/bom_components_image/views/mrp_bom_structure_report_templates.xml b/bom_components_image/views/mrp_bom_structure_report_templates.xml new file mode 100644 index 000000000..90a1b9830 --- /dev/null +++ b/bom_components_image/views/mrp_bom_structure_report_templates.xml @@ -0,0 +1,61 @@ + + + + + + diff --git a/bom_components_image/views/mrp_production_templates.xml b/bom_components_image/views/mrp_production_templates.xml new file mode 100644 index 000000000..bb4d11c6d --- /dev/null +++ b/bom_components_image/views/mrp_production_templates.xml @@ -0,0 +1,138 @@ + + + + + + diff --git a/bom_components_image/views/product_bom_view.xml b/bom_components_image/views/product_bom_view.xml new file mode 100644 index 000000000..fe1127640 --- /dev/null +++ b/bom_components_image/views/product_bom_view.xml @@ -0,0 +1,44 @@ + + + + + + bom.button + product.template + + + +
+ +
+
+
+
+ + mrp.bom.image.form + mrp.bom + + + + + + + + mo_line.bom.image.form + mrp.production + + + + + + + + +
+
\ No newline at end of file