Browse Source

[ADD] Initial Commit

pull/29/head
SHEREEF PT 8 years ago
parent
commit
0cf815383f
  1. 13
      bom_components_image/README.rst
  2. 25
      bom_components_image/__init__.py
  3. 47
      bom_components_image/__manifest__.py
  4. 25
      bom_components_image/models/__init__.py
  5. 94
      bom_components_image/models/bom_product.py
  6. 26
      bom_components_image/report/__init__.py
  7. 70
      bom_components_image/report/mrp_bom_cost_report.py
  8. 75
      bom_components_image/report/mrp_bom_structure_report.py
  9. BIN
      bom_components_image/static/description/banner.jpg
  10. BIN
      bom_components_image/static/description/bom3.png
  11. BIN
      bom_components_image/static/description/bom55.png
  12. BIN
      bom_components_image/static/description/bom6.png
  13. BIN
      bom_components_image/static/description/bom7.png
  14. BIN
      bom_components_image/static/description/bom8.png
  15. BIN
      bom_components_image/static/description/icon.png
  16. 134
      bom_components_image/static/description/index.html
  17. 47
      bom_components_image/static/src/js/binary_image.js
  18. 7
      bom_components_image/static/src/xml/binary.xml
  19. 10
      bom_components_image/views/binary_image.xml
  20. 65
      bom_components_image/views/mrp_bom_cost_report_templates.xml
  21. 61
      bom_components_image/views/mrp_bom_structure_report_templates.xml
  22. 138
      bom_components_image/views/mrp_production_templates.xml
  23. 44
      bom_components_image/views/product_bom_view.xml

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

25
bom_components_image/__init__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import models
import report

47
bom_components_image/__manifest__.py

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}

25
bom_components_image/models/__init__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import bom_product

94
bom_components_image/models/bom_product.py

@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
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)

26
bom_components_image/report/__init__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
import mrp_bom_cost_report
import mrp_bom_structure_report

70
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(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
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})

75
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(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# 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 <https://www.gnu.org/licenses/>.
#
##############################################################################
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)

BIN
bom_components_image/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
bom_components_image/static/description/bom3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
bom_components_image/static/description/bom55.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
bom_components_image/static/description/bom6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
bom_components_image/static/description/bom7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
bom_components_image/static/description/bom8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
bom_components_image/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

134
bom_components_image/static/description/index.html

@ -0,0 +1,134 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">BOM Product Image</h2>
<h3 class="oe_slogan">Includes Bill Of Material Component's Image to MRP module</h3>
<h4 class="oe_slogan">Author : Cybrosys Techno Solutions , www.cybrosys.com</h4>
<div>
<h4><p>Features:</p></h4>
<ul>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Smart button to show whether the current product is a component of BOM </li>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Edit or delete product image in BOM </li>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Get BOM product images into manufacturing Orders by default.</li>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Includes BOM images to reports such as Production Order, BOM Cost and BOM Structure.</li>
</ul>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
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.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Used In BOM Components</h3>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="bom55.png">
</div>
</div>
<div class="oe_span12">
<p class="oe_mt32">
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.
</p>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Component's Image In BOM </h3>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="bom3.png">
</div>
</div>
<div class="oe_span12">
<p class="oe_mt32">
<p>Manufacturing ---> Bill Of Material ---> Components</p>
<p>Here we can edit or delete new images to BOM components. Otherwise default image of the
corresponding product is selected.</p>
</p>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">BOM Product Image In Manufacturing Orders</h3>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="bom7.png">
</div>
</div>
</div>
<div class="oe_row oe_spaced">
<p>
Generate BOM product images automatically, when user creates a manufacturing order.
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">BOM Product Image In Reports</h3>
<div class="oe_row oe_spaced">
<div class="oe_span6">
<h3>Production Order</h3>
<p>Manufacturing --->Manufacturing Orders --->Print --->Production Order</p>
<img class="oe_picture oe_screenshot" src="bom8.png">
</div>
<div class="oe_span6 ">
<h3>BOM Cost</h3>
<p>Manufacturing --->Bill Of Material --->Print --->BOM Cost</p>
<img class="oe_picture oe_screenshot" src="bom6.png">
</div></div></div>
</section>
<section class="oe_container ">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

47
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);
});

7
bom_components_image/static/src/xml/binary.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="binary_image" xml:space="preserve">
<img t-name="ListView.row.imagen"
t-att-height="widget.height || 32"
t-att-src="src"
class="oe_image_tree"/>
</templates>

10
bom_components_image/views/binary_image.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="tree icon assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/bom_components_image/static/src/js/binary_image.js"></script>
</xpath>
</template>
</data>
</openerp>

65
bom_components_image/views/mrp_bom_cost_report_templates.xml

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="mrp_bom_cost_report1">
<t t-call="report.html_container">
<t t-foreach="lines" t-as="line">
<t t-call="report.internal_layout">
<div class="page">
<t t-set="currency" t-value="line['currency']"/>
<table class="table table-condensed">
<thead>
<tr>
<th colspan="6">
<h1><t t-esc="line['name']"/></h1><br/>
<b><t t-esc="line['product_uom_qty']"/> <t t-esc="line['product_uom'].name"/></b>
<table>
<tbody>
<tr t-foreach="line['attributes']" t-as="attrib">
<td><span t-esc="attrib[0]"/></td>
<td><span t-esc="attrib[1]"/></td>
</tr>
</tbody>
</table>
<h2>Cost Structure</h2>
</th>
</tr>
<tr>
<th colspan="3">Raw Materials</th>
<th>Image</th>
<th class="col-sm-2 text-right">Quantity</th>
<th class="col-sm-2 text-right">Unit Cost</th>
<th class="col-sm-2 text-right">Total Cost</th>
</tr>
</thead>
<tbody>
<tr t-foreach="line['lines']" t-as="bom_line">
<td colspan="3">
<span t-att-res-id="bom_line['product_id'].id" res-model="product.product" view-type="form" t-esc="bom_line['product_id'].name"/>
</td>
<td>
<img t-if="bom_line['image']" t-att-src="'data:image/png;base64,%s' % bom_line['image']" style="max-height: 40px;"/>
</td>
<td class="text-right">
<span t-esc="bom_line['product_uom_qty']"/> <span t-esc="bom_line['product_uom'].name" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-esc="bom_line['price_unit']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
<td class="text-right">
<span t-esc="bom_line['total_price']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</td>
</tr>
<tr>
<th colspan="5" class="text-right">Total Cost of Raw Materials</th>
<th class="text-right">
<span t-esc="line['total']" t-options='{"widget": "monetary", "display_currency": currency}'/>
</th>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</t>
</template>
</odoo>

61
bom_components_image/views/mrp_bom_structure_report_templates.xml

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="mrp_bom_structure_report1">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<div class="page">
<h2>BOM Structure</h2>
<table class="table table-condensed">
<thead>
<tr>
<th>BOM Name</th>
<th>Image</th>
<th>Quantity</th>
<th>BOM Ref</th>
</tr>
</thead>
<tbody>
<t t-foreach="docs" t-as="o">
<tr style="font-weight: bold;">
<td>
<span t-field="o.product_id.default_code"/>
<span t-field="o.display_name"/>
</td>
<td>
<img t-if="o.product_id.image_medium" t-att-src="'data:image/png;base64,%s' % o.image" style="max-height: 40px;"/>
</td>
<td>
<span t-field="o.product_qty"/>
<span groups="product.group_uom" t-field="o.product_uom_id.name"/>
</td>
<td>
<span t-field="o.code"/>
</td>
</tr>
<tr t-foreach="get_children(o.bom_line_ids)" t-as="l">
<td style="padding-left: 20px;">
<span style="color: white;" t-esc="'... '*(l['level'])"/>
<span t-esc="l['pname']"/>
</td>
<td>
<img t-if="l['image']" t-att-src="'data:image/png;base64,%s' % l['image']" style="max-height: 40px;"/>
</td>
<td>
<span t-esc="l['pqty']"/>
<span t-esc="l['uname']" groups="product.group_uom"/>
</td>
<td>
<span t-esc="l['code']"/>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</t>
</t>
</template>
</data>
</odoo>

138
bom_components_image/views/mrp_production_templates.xml

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report
string="Production Order"
id="action_report_production_order"
model="mrp.production"
name="bom_components_image.report_mrporder"
file="bom_components_image.report.mrp_production_templates"
report_type="qweb-pdf"
/>
<template id="report_mrporder">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-7">
<h2>Production Order # : <span t-field="o.name"/></h2>
</div>
<div class="col-xs-5">
<span class="text-right">
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)" style="width:350px;height:60px"/>
</span>
</div>
</div>
<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Source Document:</strong><br/>
<span t-field="o.origin"/>
</div>
<div class="col-xs-3">
<strong>Product:</strong><br/>
<span t-field="o.product_id.code"/>
<span t-field="o.product_id.name"/>
</div>
<div class="col-xs-3">
<strong>Quantity:</strong><br/>
<span t-field="o.product_qty"/>
<span t-field="o.product_uom_id.name" groups="product.group_uom"/>
</div>
</div>
<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Scheduled Date:</strong><br/>
<span t-field="o.date_planned_start"/><span t-if="o.date_planned_finished"> - <span t-field="o.date_planned_finished"/></span>
</div>
<div class="col-xs-3">
<strong>Printing date:</strong><br/>
<span t-esc="time.strftime('%Y-%m-%d')"/>
</div>
<div class="col-xs-3" t-if="'sale_ref' in o">
<strong>Partner Ref:</strong><br/>
<span t-esc="'sale_ref' in o and o.sale_ref"/>
</div>
<div class="col-xs-3" t-if="'sale_name' in o">
<strong>SO Number:</strong><br/>
<span t-esc="'sale_name' in o and o.sale_name"/>
</div>
</div>
<div t-if="o.workorder_ids">
<strong>Work Orders</strong>
<table class="table table-condensed">
<tr>
<td class="text-center"><strong>Name</strong></td>
<td class="text-center"><strong>WorkCenter</strong></td>
<td class="text-center"><strong>No. Of Minutes</strong></td>
</tr>
<tr t-foreach="o.workorder_ids" t-as="line2">
<td class="text-center"><span t-field="line2.name"/></td>
<td class="text-center"><span t-field="line2.workcenter_id.name"/></td>
<td class="text-center"><span t-field="line2.duration_expected"/></td>
</tr>
</table>
</div>
<h3 t-if="o.move_raw_ids">Bill Of Material</h3>
<table class="table table-condensed" t-if="o.move_raw_ids">
<thead>
<tr>
<th> </th>
<th><strong>Product</strong></th>
<th class="text-right"><strong>Quantity</strong></th>
<th class="text-center" groups="stock.group_stock_multi_locations">
<strong>Source Location</strong>
</th>
<th class="text-center" groups="stock.group_stock_multi_locations">
<strong>Destination Location</strong>
</th>
<th class="text-center">
<strong>Barcode</strong>
</th>
</tr>
</thead>
<tbody>
<t t-if="o.move_raw_ids">
<tr>
<td colspan="4"><strong>Products to Consume</strong></td>
</tr>
<tr t-foreach="o.move_raw_ids" t-as="line">
<td>
<img t-if="line.image" t-att-src="'data:image/png;base64,%s' % line.image" style="max-height: 40px;"/>
</td>
<td>
<span t-field="line.product_id.code"/>
<span t-field="line.product_id.name"/>
</td>
<td class="text-right">
<span t-field="line.product_uom_qty"/>
<span t-field="line.product_uom.name" groups="product.group_uom"/>
</td>
<td class="text-center" groups="stock.group_stock_multi_locations">
<span t-field="line.location_id.name"/>
</td>
<td class="text-center" groups="stock.group_stock_multi_locations">
<span t-field="line.location_dest_id.name"/>
</td>
<td class="text-center">
<span t-if="line.product_id.barcode">
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', line.product_id.barcode, 600, 100)" style="width:300px;height:50px"/>
</span>
</td>
</tr>
</t>
</tbody>
</table>
<div class="oe_structure"/>
</div>
</t>
</t>
</t>
</template>
</odoo>

44
bom_components_image/views/product_bom_view.xml

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="bom_button_veiw" model="ir.ui.view">
<field name="name">bom.button</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//div" position="inside">
<div class="oe_right oe_button_box">
<button class="oe_stat_button"
icon="fa-gears"
name="%(mrp.mrp_bom_form_action)d"
type="action"
context="{'search_default_bom_line_ids': name}">
<field string="Used In BoM" name="used_bom_count" widget="statinfo"/>
</button>
</div>
</xpath>
</field>
</record>
<record id="mrp_bom_image_form_view" model="ir.ui.view">
<field name="name">mrp.bom.image.form</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='product_id']" position="after">
<field name="image" widget="image" class="oe_avatar" />
</xpath>
</field></record>
<record id="mo_line_bom_image_form_view" model="ir.ui.view">
<field name="name">mo_line.bom.image.form</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='product_id']" position="before">
<field name="image" widget="image" class="oe_avatar" />
</xpath>
</field></record>
</data>
</odoo>
Loading…
Cancel
Save