Metadata-Version: 2.1
Name: odoo-addon-mrp_bom_line_formula_quantity
Version: 18.0.1.0.0.2
Requires-Python: >=3.10
Requires-Dist: odoo==18.0.*
Summary: Compute the quantity of a Production Line using a formula in the BoM Line.
Home-page: https://github.com/OCA/manufacture/list/16.0/mrp_bom_line_formula_quantity
License: AGPL-3
Author: Aion Tech, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=================================
MRP BoM Line formula for quantity
=================================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:49750667878b688ae370c33a89a687b688d069350a266c4823b9cfbac8377568
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
    :target: https://github.com/OCA/manufacture/tree/18.0/mrp_bom_line_formula_quantity
    :alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/manufacture-18-0/manufacture-18-0-mrp_bom_line_formula_quantity
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=18.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Compute the quantity of a Production Line using a formula defined in the
BoM Line.

**Table of contents**

.. contents::
   :local:

Configuration
=============

In any BoM line, fill the Quantity Formula field.

The following values are available:

- \`bom_line\`: the current BoM line,
- \`production\`: the production order being created,
- \`product\`: the Product of current BoM line,
- \`product_uom_qty\`: the quantity of the production order line,
- \`product_uom\`: the UoM of the Product of current BoM line,
- \`operation\`: the operation where the components are consumed for
  current BoM line,

The computed quantity must be assigned to the quantity variable.

Usage
=====

This module can be used to customize the quantity of a component based
on a custom attribute value selected on the product. The following
configuration works when the website_sale module is installed.

In order to do that, configure as follows:

1. Create an attribute "Component quantity" with a custom value

   |image|

2. Create and publish a Product having the configured custom value, and
   the MTO route (archived by default)

   |image1|

3. Add a BoM to the product, where one Component has the following
   formula for the quantity:

   |image2|

   .. code:: python

      sale_lines = production.move_dest_ids.sale_line_id
      produced_template = production.product_tmpl_id
      produced_template_sale_line = sale_lines.filtered(lambda l: l.product_template_id == produced_template)
      custom_attributes_values = produced_template_sale_line.product_custom_attribute_value_ids.with_context(lang=None)
      component_quantity_attribute_value = custom_attributes_values.filtered(
          lambda av: av.custom_product_template_attribute_value_id.attribute_id.name == "Component quantity"
      )
      component_quantity = component_quantity_attribute_value.custom_value
      quantity = int(component_quantity)

4. In the e-commerce, select a quantity for the custom value and buy the
   product

   |image3|

5. Confirm the sale order

   |image4|

a Production order with the selected value of Component will be created

|image5|

.. |image| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/product_attribute.png
.. |image1| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/product_tab_attributes.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/bom.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/website_sale_product.png
.. |image4| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/sale_order.png
.. |image5| image:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_line_formula_quantity/static/description/images/production_order.png

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_bom_line_formula_quantity%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Aion Tech

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

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.

.. |maintainer-SirAionTech| image:: https://github.com/SirAionTech.png?size=40px
    :target: https://github.com/SirAionTech
    :alt: SirAionTech

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-SirAionTech| 

This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/18.0/mrp_bom_line_formula_quantity>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
