[ADD] mrp_bom_equivalent

This commit is contained in:
Bhavesh Odedra
2018-02-02 12:58:45 +05:30
committed by Maxime Chambreuil
parent c55d3fe2cd
commit 1f3c4d4f99
9 changed files with 166 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
=====================
MRP BoM Equivalences
=====================
This module allows the user to specify non-equivalent products to a part on a BOM.
Other modules can assume that products in the same category are equivalent and can be used in a Manufacturing Order if the main part is not available. Those non-equivalent products can be excluded.
Usage
=====
* Go to Manufacturing > Master Data > Bill of Materials
* Create or update a BOM to check the box "Use Equivalences"
* Set the non-equivalent products among the products of the same category
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
------------
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
Funders
-------
The development of this module has been financially supported by:
* Open Source Integrators <http://www.opensourceintegrators.com>
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.

View File

@@ -0,0 +1,4 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -0,0 +1,17 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "MRP BoM Equivalences",
"summary": "Specify non-equivalent products to a part on a BOM",
"version": "11.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "MRP",
"website": "http://www.opensourceintegrators.com",
"depends": ["mrp", "product_priority"],
"data": [
"views/mrp_view.xml",
],
"installable": True,
}

View File

@@ -0,0 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mrp
from . import product

View File

@@ -0,0 +1,19 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class MRPBoMLine(models.Model):
_inherit = 'mrp.bom.line'
use_equivalences = fields.Boolean(
string='Use equivalences'
)
nonequivalent_product_ids = fields.Many2many(
"product.product",
"mrp_bom_line_product_rel",
"bom_line_id",
"product_id",
string="Non-Equivalent Products"
)

View File

@@ -0,0 +1,40 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
if 'nonequivalent_product_id' in self._context:
category_id = self.browse(
self._context.get('nonequivalent_product_id')).categ_id
recs = self.search(
[('categ_id', '=', category_id.id),
('id', '!=', self._context.get('nonequivalent_product_id')),
('name', operator, name)] + args, limit=limit)
if not recs:
recs = self.browse()
return recs.name_get()
return super(ProductProduct, self).name_search(name, args=args,
operator=operator,
limit=limit)
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None,
order=None):
if 'nonequivalent_product_id' in self._context:
category_id = self.browse(
self._context.get('nonequivalent_product_id')).categ_id
domain +=\
[('categ_id', '=', category_id.id),
('id', '!=', self._context.get('nonequivalent_product_id'))]
order = order or self.priority
return super(ProductProduct, self).search_read(domain=domain,
fields=fields,
offset=offset,
limit=limit,
order=order)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<odoo>
<!-- Bills of Materials form view -->
<record id="mrp_bom_equivalences_form_view" model="ir.ui.view">
<field name="name">mrp.bom.form</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='bom_line_ids']/tree/field[@name='operation_id']" position="after">
<field name="use_equivalences"/>
<field name="nonequivalent_product_ids" attrs="{'readonly': [('use_equivalences', '=', False)]}" context="{'nonequivalent_product_id': product_id}" widget="many2many_tags"/>
</xpath>
</data>
</field>
</record>
</odoo>

3
oca_dependencies.txt Normal file
View File

@@ -0,0 +1,3 @@
# List the OCA project dependencies, one per line
# Add a repository url and branch if you need a forked version
product-attribute