mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
Merge pull request #256 from Eficent/10.0-mig-mrp_bom_location
[10.0][MIG] mrp_bom_location
This commit is contained in:
65
mrp_bom_location/README.rst
Normal file
65
mrp_bom_location/README.rst
Normal file
@@ -0,0 +1,65 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: https://www.gnu.org/licenses/agpl
|
||||
:alt: License: AGPL-3
|
||||
|
||||
================
|
||||
MRP BOM Location
|
||||
================
|
||||
|
||||
This module adds the location field to the Bill of Materials and its
|
||||
components. This may be useful to distinguish between different BoMs for the
|
||||
same product or to highlight the preferred locations to fetch the
|
||||
components from.
|
||||
|
||||
The location appears in the BOM Structure Report.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to *Manufacturing > Master Data > Bill of Materials*.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/129/10.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/manufacture/issues>`_. In case of trouble, please
|
||||
check there if your issue has already been reported. If you spotted it first,
|
||||
help us smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
|
||||
Do not contact contributors directly about support or help with technical
|
||||
issues.
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
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.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
5
mrp_bom_location/__init__.py
Normal file
5
mrp_bom_location/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
from . import report
|
||||
21
mrp_bom_location/__manifest__.py
Normal file
21
mrp_bom_location/__manifest__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "MRP BOM Location",
|
||||
"summary": "Adds location field to Bill of Materials and its components.",
|
||||
"version": "10.0.1.0.0",
|
||||
"category": "Manufacture",
|
||||
"website": "https://odoo-community.org/",
|
||||
"author": "Eficent, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"mrp",
|
||||
],
|
||||
"data": [
|
||||
"views/mrp_view.xml",
|
||||
"views/report_mrpbomstructure.xml",
|
||||
],
|
||||
}
|
||||
4
mrp_bom_location/models/__init__.py
Normal file
4
mrp_bom_location/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import mrp_bom
|
||||
27
mrp_bom_location/models/mrp_bom.py
Normal file
27
mrp_bom_location/models/mrp_bom.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MrpBom(models.Model):
|
||||
_inherit = "mrp.bom"
|
||||
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location",
|
||||
string="Location",
|
||||
help="Set the preferred location for this BOM.",
|
||||
domain=[('usage', '=', 'internal')],
|
||||
)
|
||||
|
||||
|
||||
class MrpBomLine(models.Model):
|
||||
_inherit = "mrp.bom.line"
|
||||
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location",
|
||||
string="Location",
|
||||
help="Location which it is expected to get the products from.",
|
||||
domain=[('usage', '=', 'internal')],
|
||||
)
|
||||
4
mrp_bom_location/report/__init__.py
Normal file
4
mrp_bom_location/report/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import bom_structure
|
||||
47
mrp_bom_location/report/bom_structure.py
Normal file
47
mrp_bom_location/report/bom_structure.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 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).
|
||||
|
||||
from openerp import models
|
||||
|
||||
|
||||
class BomStructureReport(models.AbstractModel):
|
||||
_inherit = 'report.mrp.report_mrpbomstructure'
|
||||
|
||||
def get_children(self, record, level=0):
|
||||
result = []
|
||||
|
||||
def _get_rec(record, level, qty=1.0, uom=False):
|
||||
for l in record:
|
||||
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['location_name'] = l.location_id.complete_name or ''
|
||||
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 0 < level < 6:
|
||||
level -= 1
|
||||
return result
|
||||
|
||||
children = _get_rec(record, level)
|
||||
|
||||
return children
|
||||
BIN
mrp_bom_location/static/description/icon.png
Normal file
BIN
mrp_bom_location/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
81
mrp_bom_location/views/mrp_view.xml
Normal file
81
mrp_bom_location/views/mrp_view.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||
<odoo>
|
||||
|
||||
<record id="mrp_bom_form_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.form - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="routing_id" position="before">
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='product_qty']" position="after">
|
||||
<field name="location_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_bom_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.tree - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_mrp_bom_filter" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.select - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="inherit_id" ref="mrp.view_mrp_bom_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_tmpl_id" position="after">
|
||||
<field name="location_id" string="Location"/>
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Location" context="{'group_by':'location_id'}"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_bom_component_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.component.tree - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom.line</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_component_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="before">
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_bom_line_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.tree - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom.line</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_line_tree_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_mrp_bom_line_filter" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.line.select - mrp_bom_location</field>
|
||||
<field name="model">mrp.bom.line</field>
|
||||
<field name="inherit_id" ref="mrp.view_mrp_bom_line_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="location_id" string="Location"/>
|
||||
</field>
|
||||
<group expand="0" position="inside">
|
||||
<filter string="Location" context="{'group_by':'location_id'}"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
20
mrp_bom_location/views/report_mrpbomstructure.xml
Normal file
20
mrp_bom_location/views/report_mrpbomstructure.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="report_mrpbomstructure_location"
|
||||
inherit_id="mrp.mrp_bom_structure_report">
|
||||
<xpath expr="//thead/tr" position="inside">
|
||||
<th>Location</th>
|
||||
</xpath>
|
||||
<xpath expr="//tbody/t/tr[1]" position="inside">
|
||||
<td>
|
||||
<span t-field="o.location_id.complete_name"/>
|
||||
</td>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//tbody/t/tr[2]" position="inside">
|
||||
<td>
|
||||
<span t-esc="l['location_name']"/>
|
||||
</td>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
1
setup/mrp_bom_location/odoo/__init__.py
Normal file
1
setup/mrp_bom_location/odoo/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
1
setup/mrp_bom_location/odoo/addons/__init__.py
Normal file
1
setup/mrp_bom_location/odoo/addons/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
1
setup/mrp_bom_location/odoo/addons/mrp_bom_location
Symbolic link
1
setup/mrp_bom_location/odoo/addons/mrp_bom_location
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../mrp_bom_location
|
||||
6
setup/mrp_bom_location/setup.py
Normal file
6
setup/mrp_bom_location/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user