[REM] mrp: remove old report for BoM structure/cost
The pupose is to add the new dynamic bom report Chekc the next commits in order to have more details
This commit is contained in:
committed by
Simon Lejeune
parent
5ba54aa43e
commit
7cb32d1f36
@@ -38,8 +38,6 @@
|
||||
'views/stock_scrap_views.xml',
|
||||
'report/mrp_report_views_main.xml',
|
||||
'report/mrp_production_templates.xml',
|
||||
'report/mrp_bom_structure_report_templates.xml',
|
||||
'report/mrp_bom_cost_report_templates.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/mrp_demo.xml',
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import mrp_bom_cost_report
|
||||
from . import mrp_bom_structure_report
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class MrpBomCost(models.AbstractModel):
|
||||
_name = 'report.mrp.mrp_bom_cost_report'
|
||||
|
||||
@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,
|
||||
'product_uom_qty': line_data['qty'], #line_data needed for phantom bom explosion
|
||||
'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 get_report_values(self, docids, data=None):
|
||||
boms = self.env['mrp.bom'].browse(docids)
|
||||
res = self.get_lines(boms)
|
||||
return {'lines': res}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="mrp_bom_cost_report">
|
||||
<t t-call="web.html_container">
|
||||
<t t-foreach="lines" t-as="line">
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<t t-set="currency" t-value="line['currency']"/>
|
||||
<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>
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Reference</th>
|
||||
<th colspan="3">Raw Materials</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>
|
||||
<span t-field="bom_line['product_id'].default_code"/>
|
||||
</td>
|
||||
<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 class="text-right">
|
||||
<span t-esc="bom_line['product_uom_qty']"/> <span t-esc="bom_line['product_uom'].name" groups="uom.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="6" class="text-right">Total Cost of Components</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>
|
||||
@@ -1,51 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class BomStructureReport(models.AbstractModel):
|
||||
_name = 'report.mrp.mrp_bom_structure_report'
|
||||
|
||||
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
|
||||
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 get_report_values(self, docids, data=None):
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'doc_model': 'mrp.bom',
|
||||
'docs': self.env['mrp.bom'].browse(docids),
|
||||
'get_children': self.get_children,
|
||||
'data': data,
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="mrp_bom_structure_report">
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h2>BOM Structure</h2>
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>BOM Name</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>
|
||||
<span t-field="o.product_qty"/>
|
||||
<span groups="uom.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>
|
||||
<span t-esc="l['pqty']"/>
|
||||
<span t-esc="l['uname']" groups="uom.group_uom"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="l['code']"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,16 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<report
|
||||
string="BOM Structure"
|
||||
id="action_report_bom_structure"
|
||||
model="mrp.bom"
|
||||
name="mrp.mrp_bom_structure_report"
|
||||
file="mrp.report.mrp_bom_templates"
|
||||
report_type="qweb-pdf"
|
||||
print_report_name="'BOM - %s' % (object.product_id.name or object.product_tmpl_id.name or '')"
|
||||
/>
|
||||
|
||||
<report
|
||||
string="Production Order"
|
||||
id="action_report_production_order"
|
||||
@@ -20,15 +10,6 @@
|
||||
report_type="qweb-pdf"
|
||||
print_report_name="'Production Order - %s' % object.name"
|
||||
/>
|
||||
|
||||
<report
|
||||
string="BOM Cost"
|
||||
id="action_report_bom_price"
|
||||
model="mrp.bom"
|
||||
name="mrp.mrp_bom_cost_report"
|
||||
file="mrp.mrp_bom_cost_report"
|
||||
report_type="qweb-html"
|
||||
print_report_name="'BOM Cost - %s' % (object.product_id.name or object.product_tmpl_id.name or '')"
|
||||
/>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -192,38 +192,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_bom_component_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.component.tree</field>
|
||||
<field name="model">mrp.bom.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Components" editable="top">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="bom_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id" options="{'no_open':True,'no_create':True}" groups="uom.group_uom"/>
|
||||
<field name="routing_id"/>
|
||||
<field name="attribute_value_ids" widget="many2many_tags" groups="product.group_product_variant"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_mrp_bom_line_filter" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.line.select</field>
|
||||
<field name="model">mrp.bom.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Bill Of Material Components">
|
||||
<field name="bom_id"/>
|
||||
<field name="product_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Bill Of Material" name="bill_of_material" domain="[]" context="{'group_by':'bom_id'}"/>
|
||||
<filter string="Product" name="product" domain="[]" context="{'group_by':'product_id'}"/>
|
||||
<filter string='Default Unit of Measure' name="default_unit_of_measure" domain="[]" context="{'group_by' : 'product_uom_id'}"/>
|
||||
<filter string="Routings" name="routings" domain="[]" context="{'group_by':'routing_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="template_open_bom" model="ir.actions.act_window">
|
||||
<field name="context">{'default_product_tmpl_id': active_id, 'search_default_product_tmpl_id': active_id}</field>
|
||||
<field name="name">Bill of Materials</field>
|
||||
|
||||
Reference in New Issue
Block a user