diff --git a/mrp_bom_line_sequence/README.rst b/mrp_bom_line_sequence/README.rst new file mode 100644 index 000000000..bc9a7abaf --- /dev/null +++ b/mrp_bom_line_sequence/README.rst @@ -0,0 +1,79 @@ +============================== +BOM lines with sequence number +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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/10.0/mrp_bom_line_sequence + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-mrp_bom_line_sequence + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Provide a new field sequence on bom components, which allows to manage the +order of moves in a picking. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Add custom sequence if needed, if not just let the system to sort the lines. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Eficent + +Contributors +~~~~~~~~~~~~ + +* Eficent Business and IT Consulting Services S.L. + +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. + +This module is part of the `OCA/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_bom_line_sequence/__init__.py b/mrp_bom_line_sequence/__init__.py new file mode 100644 index 000000000..ffbe81dd7 --- /dev/null +++ b/mrp_bom_line_sequence/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/mrp_bom_line_sequence/__manifest__.py b/mrp_bom_line_sequence/__manifest__.py new file mode 100644 index 000000000..68c793e8c --- /dev/null +++ b/mrp_bom_line_sequence/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'BOM lines with sequence number', + 'summary': 'Manages the order of BOM lines by displaying its sequence', + 'version': '10.0.1.0.0', + 'category': 'Manufacturing Management', + 'author': "Eficent, " + "Odoo Community Association (OCA)", + 'website': 'https://github.com/OCA/manufacture', + 'depends': ['mrp'], + 'data': ['views/stock_view.xml'], + 'installable': True, + 'auto_install': False, + 'license': "AGPL-3", +} diff --git a/mrp_bom_line_sequence/models/__init__.py b/mrp_bom_line_sequence/models/__init__.py new file mode 100644 index 000000000..b02d6f4ff --- /dev/null +++ b/mrp_bom_line_sequence/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import mrp diff --git a/mrp_bom_line_sequence/models/mrp.py b/mrp_bom_line_sequence/models/mrp.py new file mode 100644 index 000000000..beecc44ab --- /dev/null +++ b/mrp_bom_line_sequence/models/mrp.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class MrpBomLine(models.Model): + _inherit = 'mrp.bom.line' + + # re-defines the field to change the default + sequence = fields.Integer(default=9999) + + # displays sequence on the stock moves + sequence2 = fields.Integer(help="Shows the sequence in the BOM line.", + related='sequence', readonly=False, store=True) + + @api.model + def create(self, values): + move = super(MrpBomLine, self).create(values) + # We do not reset the sequence if we are copying a complete bom + if not self.env.context.get('keep_line_sequence', False): + move.bom_id._reset_sequence() + return move + + +class MrpBom(models.Model): + _inherit = 'mrp.bom' + + @api.multi + @api.depends('bom_line_ids') + def _compute_max_line_sequence(self): + """Allow to know the highest sequence entered in move lines. + Then we add 1 to this value for the next sequence, this value is + passed to the context of the o2m field in the view. + So when we create new move line, the sequence is automatically + incremented by 1. (max_sequence + 1) + """ + for bom in self: + bom.max_line_sequence = ( + max(bom.mapped('bom_line_ids.sequence') or [0]) + 1 + ) + + max_line_sequence = fields.Integer(string='Max sequence in lines', + compute='_compute_max_line_sequence') + + @api.multi + def _reset_sequence(self): + for rec in self: + current_sequence = 1 + for line in rec.bom_line_ids: + line.sequence = current_sequence + current_sequence += 1 + + @api.multi + def copy(self, default=None): + return super(MrpBom, + self.with_context(keep_line_sequence=True)).copy(default) diff --git a/mrp_bom_line_sequence/readme/CONTRIBUTORS.rst b/mrp_bom_line_sequence/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..25ac7dbc3 --- /dev/null +++ b/mrp_bom_line_sequence/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Eficent Business and IT Consulting Services S.L. \ No newline at end of file diff --git a/mrp_bom_line_sequence/readme/DESCRIPTION.rst b/mrp_bom_line_sequence/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a1d133863 --- /dev/null +++ b/mrp_bom_line_sequence/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Provide a new field sequence on bom components, which allows to manage the +order of moves in a picking. diff --git a/mrp_bom_line_sequence/readme/USAGE.rst b/mrp_bom_line_sequence/readme/USAGE.rst new file mode 100644 index 000000000..2d1769bb7 --- /dev/null +++ b/mrp_bom_line_sequence/readme/USAGE.rst @@ -0,0 +1 @@ +Add custom sequence if needed, if not just let the system to sort the lines. diff --git a/mrp_bom_line_sequence/static/description/icon.png b/mrp_bom_line_sequence/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_bom_line_sequence/static/description/icon.png differ diff --git a/mrp_bom_line_sequence/static/description/index.html b/mrp_bom_line_sequence/static/description/index.html new file mode 100644 index 000000000..f76a1d93e --- /dev/null +++ b/mrp_bom_line_sequence/static/description/index.html @@ -0,0 +1,403 @@ + + + + + + +BOM lines with sequence number + + + +
+

BOM lines with sequence number

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

Provide a new field sequence on bom components, which allows to manage the +order of moves in a picking.

+

Table of contents

+ +
+

Usage

+

Add custom sequence if needed, if not just let the system to sort the lines.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/manufacture project on GitHub.

+

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

+
+
+
+ + diff --git a/mrp_bom_line_sequence/views/stock_view.xml b/mrp_bom_line_sequence/views/stock_view.xml new file mode 100644 index 000000000..f4af8d6ad --- /dev/null +++ b/mrp_bom_line_sequence/views/stock_view.xml @@ -0,0 +1,25 @@ + + + + + mrp.bom.form + mrp.bom + + + + "handle" + + + + + mrp.bom.form + mrp.bom + + + + + + + + +