diff --git a/mrp_production_request/README.rst b/mrp_production_request/README.rst index 10d3b2a66..fc20ab0c2 100644 --- a/mrp_production_request/README.rst +++ b/mrp_production_request/README.rst @@ -14,13 +14,13 @@ MRP Production Request :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/11.0/mrp_production_request + :target: https://github.com/OCA/manufacture/tree/12.0/mrp_production_request :alt: OCA/manufacture .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/manufacture-11-0/manufacture-11-0-mrp_production_request + :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_production_request :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/11.0 + :target: https://runbot.odoo-community.org/runbot/129/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -94,6 +94,11 @@ Known issues / Roadmap Changelog ========= +12.0.1.0.0 (2019-09-13) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [MIG] Migration to v12. + 11.0.1.0.0 (2018-09-13) ~~~~~~~~~~~~~~~~~~~~~~~ @@ -105,7 +110,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -144,6 +149,6 @@ Current `maintainer `__: |maintainer-lreficent| -This module is part of the `OCA/manufacture `_ project on GitHub. +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_production_request/__manifest__.py b/mrp_production_request/__manifest__.py index 99b00750d..7f0753003 100644 --- a/mrp_production_request/__manifest__.py +++ b/mrp_production_request/__manifest__.py @@ -1,11 +1,11 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-19 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "MRP Production Request", "summary": "Allows you to use Manufacturing Request as a previous " "step to Manufacturing Orders for better manufacture " "planification.", - "version": "11.0.1.0.1", + "version": "12.0.1.0.0", "development_status": "Mature", "maintainers": ['lreficent'], "category": "Manufacturing", diff --git a/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis.txt b/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis.txt deleted file mode 100644 index 8bcf623ca..000000000 --- a/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis.txt +++ /dev/null @@ -1,5 +0,0 @@ ----Fields in module 'mrp_production_request'--- -mrp_production_request / mrp.production.request / picking_type_id (many2one) : NEW relation: stock.picking.type, required: required, req_default: function -mrp_production_request / mrp.production.request / product_uom (many2one) : DEL relation: product.uom -mrp_production_request / mrp.production.request / product_uom_id (many2one) : NEW relation: product.uom ----XML records in module 'mrp_production_request'--- diff --git a/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis_work.txt b/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis_work.txt deleted file mode 100644 index b8184ba3d..000000000 --- a/mrp_production_request/migrations/10.0.1.0.0/openupgrade_analysis_work.txt +++ /dev/null @@ -1,9 +0,0 @@ ----Fields in module 'mrp_production_request'--- -mrp_production_request / mrp.production.request / picking_type_id (many2one) : NEW relation: stock.picking.type, required: required, req_default: function -# NOTHING TO DO - -mrp_production_request / mrp.production.request / product_uom (many2one) : DEL relation: product.uom -mrp_production_request / mrp.production.request / product_uom_id (many2one) : NEW relation: product.uom -# Done. Renamed field: pre-migration script. - ----XML records in module 'mrp_production_request'--- diff --git a/mrp_production_request/migrations/10.0.1.0.0/pre-migration.py b/mrp_production_request/migrations/10.0.1.0.0/pre-migration.py deleted file mode 100644 index e2286cb3d..000000000 --- a/mrp_production_request/migrations/10.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - -field_renames = [ - ('mrp.production.request', 'mrp_production_request', 'product_uom', - 'product_uom_id'), -] - - -@openupgrade.migrate(use_env=True) -def migrate(env, version): - openupgrade.rename_fields(env, field_renames) diff --git a/mrp_production_request/migrations/10.0.1.1.0/pre-migration.py b/mrp_production_request/migrations/10.0.1.1.0/pre-migration.py deleted file mode 100644 index f5146c392..000000000 --- a/mrp_production_request/migrations/10.0.1.1.0/pre-migration.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Simone Rubino - Agile Business Group -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from openupgradelib import openupgrade - -field_renames = [ - ('mrp.production.request', 'mrp_production_request', 'date_planned', - 'date_planned_start') -] - - -@openupgrade.migrate(use_env=True) -def migrate(env, version): - openupgrade.rename_fields(env, field_renames) diff --git a/mrp_production_request/migrations/11.0.1.0.0/post-migration.py b/mrp_production_request/migrations/11.0.1.0.0/post-migration.py deleted file mode 100644 index 83a115078..000000000 --- a/mrp_production_request/migrations/11.0.1.0.0/post-migration.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2018 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). - - -def migrate(cr, version): - """Copy `move_dest_id` from the old procurement orders to the new field - `move_dest_ids` in the Manufacturing Request.""" - cr.execute(""" - SELECT move_dest_id, mrp_production_request_id - FROM procurement_order - WHERE mrp_production_request_id is not null;""") - for move_dest, mrp_request in cr.fetchall(): - if move_dest: - cr.execute(""" - UPDATE stock_move - SET created_mrp_production_request_id = %s - WHERE id = %s - """, (mrp_request, move_dest,)) diff --git a/mrp_production_request/models/__init__.py b/mrp_production_request/models/__init__.py index d450fbd94..f46a57206 100644 --- a/mrp_production_request/models/__init__.py +++ b/mrp_production_request/models/__init__.py @@ -1,6 +1,6 @@ from . import mrp_production_request from . import mrp_production -from . import procurement_rule +from . import stock_rule from . import product from . import stock_move from . import stock_warehouse_orderpoint diff --git a/mrp_production_request/models/mrp_production.py b/mrp_production_request/models/mrp_production.py index 99048b638..18331ac24 100644 --- a/mrp_production_request/models/mrp_production.py +++ b/mrp_production_request/models/mrp_production.py @@ -18,7 +18,7 @@ class MrpProduction(models.Model): Storing them on the MR and writing them on the finished moves as it would happen if they were present in the MO, is the best workaround without changing the standard data model.""" - move = super(MrpProduction, self)._generate_finished_moves() + move = super()._generate_finished_moves() request = self.mrp_production_request_id if request and request.move_dest_ids: move.write({ diff --git a/mrp_production_request/models/mrp_production_request.py b/mrp_production_request/models/mrp_production_request.py index 5f7a62cdd..5024a5106 100644 --- a/mrp_production_request/models/mrp_production_request.py +++ b/mrp_production_request/models/mrp_production_request.py @@ -1,4 +1,4 @@ -# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-19 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models, _ @@ -14,7 +14,7 @@ class MrpProductionRequest(models.Model): @api.model def _company_get(self): - company_id = self.env['res.company']._company_default_get(self._name) + company_id = self.env['res.company']._company_default_get() return self.env['res.company'].browse(company_id.id) @api.model @@ -29,7 +29,7 @@ class MrpProductionRequest(models.Model): readonly=True, states={'draft': [('readonly', False)]}) requested_by = fields.Many2one( comodel_name='res.users', string='Requested by', - default=_get_default_requested_by, + default=lambda self: self._get_default_requested_by(), required=True, track_visibility='onchange', readonly=True, states={'draft': [('readonly', False)]}) assigned_to = fields.Many2one( @@ -50,7 +50,7 @@ class MrpProductionRequest(models.Model): states={'confirmed': [('readonly', False)]}) company_id = fields.Many2one( comodel_name='res.company', string='Company', - required=True, default=_company_get) + required=True, default=lambda self: self._company_get()) mrp_production_ids = fields.One2many( comodel_name="mrp.production", string="Manufacturing Orders", inverse_name="mrp_production_request_id", readonly=True) @@ -88,7 +88,7 @@ class MrpProductionRequest(models.Model): digits=dp.get_precision('Product Unit of Measure'), default=1.0, readonly=True, states={'draft': [('readonly', False)]}) product_uom_id = fields.Many2one( - comodel_name='product.uom', string='Unit of Measure', + comodel_name='uom.uom', string='Unit of Measure', readonly=True, states={'draft': [('readonly', False)]}, domain="[('category_id', '=', category_uom_id)]") category_uom_id = fields.Many2one(related="product_uom_id.category_id") @@ -180,7 +180,8 @@ class MrpProductionRequest(models.Model): def _subscribe_assigned_user(self, vals): self.ensure_one() if vals.get('assigned_to'): - self.message_subscribe_users(user_ids=[self.assigned_to.id]) + self.message_subscribe( + partner_ids=self.assigned_to.mapped('partner_id').ids) @api.model def _create_sequence(self, vals): @@ -194,13 +195,13 @@ class MrpProductionRequest(models.Model): """Add sequence if name is not defined and subscribe to the thread the user assigned to the request.""" vals = self._create_sequence(vals) - res = super(MrpProductionRequest, self).create(vals) + res = super().create(vals) res._subscribe_assigned_user(vals) return res @api.multi def write(self, vals): - res = super(MrpProductionRequest, self).write(vals) + res = super().write(vals) for request in self: request._subscribe_assigned_user(vals) return res diff --git a/mrp_production_request/models/product.py b/mrp_production_request/models/product.py index 047899362..82bc7edec 100644 --- a/mrp_production_request/models/product.py +++ b/mrp_production_request/models/product.py @@ -8,6 +8,7 @@ class ProductTemplate(models.Model): _inherit = "product.template" mrp_production_request = fields.Boolean( - string='Manufacturing Request', help="Check this box to generate " - "manufacturing request instead of generating manufacturing orders " - "from procurement.", default=False) + string='Manufacturing Request', + help="Check this box to generate manufacturing request instead of " + "generating manufacturing orders from procurement.", + ) diff --git a/mrp_production_request/models/stock_move.py b/mrp_production_request/models/stock_move.py index 56315628f..591322f94 100644 --- a/mrp_production_request/models/stock_move.py +++ b/mrp_production_request/models/stock_move.py @@ -19,4 +19,4 @@ class StockMove(models.Model): vals['production_id']) if production.mrp_production_request_id: vals['propagate'] = False - return super(StockMove, self).create(vals) + return super().create(vals) diff --git a/mrp_production_request/models/procurement_rule.py b/mrp_production_request/models/stock_rule.py similarity index 92% rename from mrp_production_request/models/procurement_rule.py rename to mrp_production_request/models/stock_rule.py index a02d818c9..4b953d56d 100644 --- a/mrp_production_request/models/procurement_rule.py +++ b/mrp_production_request/models/stock_rule.py @@ -1,12 +1,12 @@ -# Copyright 2018 Eficent Business and IT Consulting Services S.L. +# Copyright 2018-19 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, models, _ from odoo.exceptions import UserError -class ProcurementOrder(models.Model): - _inherit = "procurement.rule" +class StockRule(models.Model): + _inherit = "stock.rule" @api.multi def _prepare_mrp_production_request( @@ -20,6 +20,9 @@ class ProcurementOrder(models.Model): orderpoint = values.get('orderpoint_id') if orderpoint: data['orderpoint_id'] = orderpoint.id + procurement_group = values.get('group_id') + if procurement_group: + data['procurement_group_id'] = procurement_group.id return data @api.multi diff --git a/mrp_production_request/models/stock_warehouse_orderpoint.py b/mrp_production_request/models/stock_warehouse_orderpoint.py index 4bc50cac2..b19e353c4 100644 --- a/mrp_production_request/models/stock_warehouse_orderpoint.py +++ b/mrp_production_request/models/stock_warehouse_orderpoint.py @@ -8,7 +8,7 @@ class Orderpoint(models.Model): _inherit = "stock.warehouse.orderpoint" def _quantity_in_progress(self): - res = super(Orderpoint, self)._quantity_in_progress() + res = super()._quantity_in_progress() mrp_requests = self.env['mrp.production.request'].search([ ('state', 'not in', ('done', 'cancel')), ('orderpoint_id', 'in', self.ids), diff --git a/mrp_production_request/readme/HISTORY.rst b/mrp_production_request/readme/HISTORY.rst index 04b41e032..24a1c66f2 100644 --- a/mrp_production_request/readme/HISTORY.rst +++ b/mrp_production_request/readme/HISTORY.rst @@ -1,3 +1,8 @@ +12.0.1.0.0 (2019-09-13) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [MIG] Migration to v12. + 11.0.1.0.0 (2018-09-13) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/mrp_production_request/security/mrp_production_request_security.xml b/mrp_production_request/security/mrp_production_request_security.xml index d8ad2c29c..c2d7c5368 100644 --- a/mrp_production_request/security/mrp_production_request_security.xml +++ b/mrp_production_request/security/mrp_production_request_security.xml @@ -21,7 +21,7 @@ Manager - + diff --git a/mrp_production_request/static/description/index.html b/mrp_production_request/static/description/index.html index 41d2f760c..1cecceaea 100644 --- a/mrp_production_request/static/description/index.html +++ b/mrp_production_request/static/description/index.html @@ -3,7 +3,7 @@ - + MRP Production Request