From fef1ef9551ecce79d82b6ecf090ed4943f40f4c9 Mon Sep 17 00:00:00 2001 From: nicomacr Date: Tue, 12 Sep 2023 09:55:17 -0300 Subject: [PATCH] [MIG] stock_request: Migration to 16.0 --- setup/.setuptools-odoo-make-default-ignore | 2 + setup/README | 2 + stock_request/README.md | 14 +- stock_request/stock_request/README.rst | 14 +- stock_request/stock_request/__manifest__.py | 4 +- .../models/stock_location_route.py | 2 +- .../stock_request/models/stock_picking.py | 4 +- .../stock_request/models/stock_request.py | 68 +++-- .../models/stock_request_abstract.py | 4 +- .../static/description/index.html | 47 ++- .../stock_request/tests/test_stock_request.py | 267 +++++++----------- .../views/res_config_settings_views.xml | 7 +- .../views/stock_request_order_views.xml | 14 +- .../views/stock_request_views.xml | 9 +- 14 files changed, 205 insertions(+), 253 deletions(-) create mode 100644 setup/.setuptools-odoo-make-default-ignore create mode 100644 setup/README diff --git a/setup/.setuptools-odoo-make-default-ignore b/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 00000000..207e6153 --- /dev/null +++ b/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/setup/README b/setup/README new file mode 100644 index 00000000..a63d633e --- /dev/null +++ b/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/stock_request/README.md b/stock_request/README.md index e09bf13f..e7e0ca6e 100644 --- a/stock_request/README.md +++ b/stock_request/README.md @@ -1,4 +1,3 @@ - [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-request&target_branch=16.0) [![Pre-commit Status](https://github.com/OCA/stock-logistics-request/actions/workflows/pre-commit.yml/badge.svg?branch=16.0)](https://github.com/OCA/stock-logistics-request/actions/workflows/pre-commit.yml?query=branch%3A16.0) [![Build Status](https://github.com/OCA/stock-logistics-request/actions/workflows/test.yml/badge.svg?branch=16.0)](https://github.com/OCA/stock-logistics-request/actions/workflows/test.yml?query=branch%3A16.0) @@ -9,7 +8,9 @@ # Stock Logistics Request -This repository contains modules to provide another way of creating stock movements. Provided as a dedicated application, users will be able to create their stock needs by product and location. +This repository contains modules to provide another way of creating stock movements. +Provided as a dedicated application, users will be able to create their stock needs by +product and location. @@ -27,11 +28,12 @@ This part will be replaced when running the oca-gen-addons-table script from OCA This repository is licensed under [AGPL-3.0](LICENSE). -However, each module can have a totally different license, as long as they adhere to Odoo Community Association (OCA) -policy. Consult each module's `__manifest__.py` file, which contains a `license` key -that explains its license. +However, each module can have a totally different license, as long as they adhere to +Odoo Community Association (OCA) policy. Consult each module's `__manifest__.py` file, +which contains a `license` key that explains its license. + +--- ----- OCA, or the [Odoo Community Association](http://odoo-community.org/), is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. diff --git a/stock_request/stock_request/README.rst b/stock_request/stock_request/README.rst index 2637dea4..f54411c4 100644 --- a/stock_request/stock_request/README.rst +++ b/stock_request/stock_request/README.rst @@ -17,13 +17,13 @@ Stock Request :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github - :target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_request - :alt: OCA/stock-logistics-warehouse + :target: https://github.com/OCA/stock-logistics-request/tree/15.0/stock_request + :alt: OCA/stock-logistics-request .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_request + :target: https://translation.odoo-community.org/projects/stock-logistics-request-16-0/stock-logistics-request-16-0-stock_request :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/stock-logistics-warehouse&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-request&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -89,10 +89,10 @@ It is also required to manage active field logically from Orders to SRs. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -136,6 +136,6 @@ 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/stock-logistics-warehouse `_ project on GitHub. +This module is part of the `OCA/stock-logistics-request `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request/stock_request/__manifest__.py b/stock_request/stock_request/__manifest__.py index 2e263b63..cfa804b8 100644 --- a/stock_request/stock_request/__manifest__.py +++ b/stock_request/stock_request/__manifest__.py @@ -4,9 +4,9 @@ { "name": "Stock Request", "summary": "Internal request for stock", - "version": "15.0.1.6.3", + "version": "16.0.1.0.0", "license": "LGPL-3", - "website": "https://github.com/OCA/stock-logistics-warehouse", + "website": "https://github.com/OCA/stock-logistics-request", "author": "ForgeFlow, Odoo Community Association (OCA)", "category": "Warehouse Management", "depends": ["stock"], diff --git a/stock_request/stock_request/models/stock_location_route.py b/stock_request/stock_request/models/stock_location_route.py index 97063ab8..7e3d260f 100644 --- a/stock_request/stock_request/models/stock_location_route.py +++ b/stock_request/stock_request/models/stock_location_route.py @@ -6,7 +6,7 @@ class StockLocationRoute(models.Model): - _inherit = "stock.location.route" + _inherit = "stock.route" @api.constrains("company_id") def _check_company_stock_request(self): diff --git a/stock_request/stock_request/models/stock_picking.py b/stock_request/stock_request/models/stock_picking.py index 85ea9b09..e9f386b2 100644 --- a/stock_request/stock_request/models/stock_picking.py +++ b/stock_request/stock_request/models/stock_picking.py @@ -16,10 +16,10 @@ class StockPicking(models.Model): "Stock Request #", compute="_compute_stock_request_ids" ) - @api.depends("move_lines") + @api.depends("move_ids") def _compute_stock_request_ids(self): for rec in self: - rec.stock_request_ids = rec.move_lines.mapped("stock_request_ids") + rec.stock_request_ids = rec.move_ids.mapped("stock_request_ids") rec.stock_request_count = len(rec.stock_request_ids) def action_view_stock_request(self): diff --git a/stock_request/stock_request/models/stock_request.py b/stock_request/stock_request/models/stock_request.py index 87afe8ca..c1f5d5e1 100644 --- a/stock_request/stock_request/models/stock_request.py +++ b/stock_request/stock_request/models/stock_request.py @@ -180,41 +180,50 @@ def _compute_qty(self): @api.constrains("order_id", "requested_by") def check_order_requested_by(self): - if self.order_id and self.order_id.requested_by != self.requested_by: - raise ValidationError(_("Requested by must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.requested_by != rec.requested_by: + raise ValidationError(_("Requested by must be equal to the order")) @api.constrains("order_id", "warehouse_id") def check_order_warehouse_id(self): - if self.order_id and self.order_id.warehouse_id != self.warehouse_id: - raise ValidationError(_("Warehouse must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.warehouse_id != rec.warehouse_id: + raise ValidationError(_("Warehouse must be equal to the order")) @api.constrains("order_id", "location_id") def check_order_location(self): - if self.order_id and self.order_id.location_id != self.location_id: - raise ValidationError(_("Location must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.location_id != rec.location_id: + raise ValidationError(_("Location must be equal to the order")) @api.constrains("order_id", "procurement_group_id") def check_order_procurement_group(self): - if ( - self.order_id - and self.order_id.procurement_group_id != self.procurement_group_id - ): - raise ValidationError(_("Procurement group must be equal to the order")) + for rec in self: + if ( + rec.order_id + and rec.order_id.procurement_group_id != rec.procurement_group_id + ): + raise ValidationError(_("Procurement group must be equal to the order")) @api.constrains("order_id", "company_id") def check_order_company(self): - if self.order_id and self.order_id.company_id != self.company_id: - raise ValidationError(_("Company must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.company_id != rec.company_id: + raise ValidationError(_("Company must be equal to the order")) @api.constrains("order_id", "expected_date") def check_order_expected_date(self): - if self.order_id and self.order_id.expected_date != self.expected_date: - raise ValidationError(_("Expected date must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.expected_date != rec.expected_date: + raise ValidationError(_("Expected date must be equal to the order")) @api.constrains("order_id", "picking_policy") def check_order_picking_policy(self): - if self.order_id and self.order_id.picking_policy != self.picking_policy: - raise ValidationError(_("The picking policy must be equal to the order")) + for rec in self: + if rec.order_id and rec.order_id.picking_policy != rec.picking_policy: + raise ValidationError( + _("The picking policy must be equal to the order") + ) def _action_confirm(self): self._action_launch_procurement_rule() @@ -351,17 +360,20 @@ def action_view_transfer(self): action["res_id"] = pickings.id return action - @api.model - def create(self, vals): - upd_vals = vals.copy() - if upd_vals.get("name", "/") == "/": - upd_vals["name"] = self.env["ir.sequence"].next_by_code("stock.request") - if "order_id" in upd_vals: - order_id = self.env["stock.request.order"].browse(upd_vals["order_id"]) - upd_vals["expected_date"] = order_id.expected_date - else: - upd_vals["expected_date"] = self._get_expected_date() - return super().create(upd_vals) + @api.model_create_multi + def create(self, vals_list): + vals_list_upd = [] + for vals in vals_list: + upd_vals = vals.copy() + if upd_vals.get("name", "/") == "/": + upd_vals["name"] = self.env["ir.sequence"].next_by_code("stock.request") + if "order_id" in upd_vals: + order_id = self.env["stock.request.order"].browse(upd_vals["order_id"]) + upd_vals["expected_date"] = order_id.expected_date + else: + upd_vals["expected_date"] = self._get_expected_date() + vals_list_upd.append(upd_vals) + return super().create(vals_list_upd) def unlink(self): if self.filtered(lambda r: r.state != "draft"): diff --git a/stock_request/stock_request/models/stock_request_abstract.py b/stock_request/stock_request/models/stock_request_abstract.py index 32ef1687..afdf7f00 100644 --- a/stock_request/stock_request/models/stock_request_abstract.py +++ b/stock_request/stock_request/models/stock_request_abstract.py @@ -94,14 +94,14 @@ def _compute_product_qty(self): "res.company", "Company", required=True, default=lambda self: self.env.company ) route_id = fields.Many2one( - "stock.location.route", + "stock.route", string="Route", domain="[('id', 'in', route_ids)]", ondelete="restrict", ) route_ids = fields.Many2many( - "stock.location.route", + "stock.route", string="Routes", compute="_compute_route_ids", readonly=True, diff --git a/stock_request/stock_request/static/description/index.html b/stock_request/stock_request/static/description/index.html index 85a4d563..89b2dff2 100644 --- a/stock_request/stock_request/static/description/index.html +++ b/stock_request/stock_request/static/description/index.html @@ -1,20 +1,20 @@ - + - + Stock Request