-
-
Notifications
You must be signed in to change notification settings - Fork 266
[18.0][MIG] purchase_stock_operating_unit: Migration to 18. #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BhaveshHeliconia
wants to merge
6
commits into
OCA:18.0
Choose a base branch
from
HeliconiaIO:18.0-mig-purchase_stock_operating_unit
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ead403a
[15.0][ADD] purchase_stock_operating_unit
Saran440 8fdfe40
[UPD] Update purchase_stock_operating_unit.pot
0073c0c
[UPD] README.rst
OCA-git-bot c3d4ddd
[UPD] README.rst
OCA-git-bot 783a129
[IMP] purchase_stock_operating_unit: pre-commit auto fixes
BhaveshHeliconia 5585f0d
[MIG] purchase_stock_operating_unit: Migration to 18.0
BhaveshHeliconia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| ============================= | ||
| Purchase Stock Operating Unit | ||
| ============================= | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:37ed2cb55b6f6c3b29c608bde062bfa5016a03d7a144c5ffda51acc993a8c4a7 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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%2Foperating--unit-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/operating-unit/tree/18.0/purchase_stock_operating_unit | ||
| :alt: OCA/operating-unit | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-purchase_stock_operating_unit | ||
| :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/operating-unit&target_branch=18.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module is used to integrated between Purchase and Stock to send | ||
| Operating Unit in the warehouse that has been selected from Deliver To | ||
| to Stock Picking. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| To use this module, you need to: | ||
|
|
||
| 1. Create a purchase order | ||
| 2. Select Deliver To that have operating unit in warehouse | ||
| 3. Confirm purchase order | ||
| 4. you should have your operating unit on your stock picking | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20purchase_stock_operating_unit%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 | ||
| ------- | ||
|
|
||
| * Ecosoft | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - Saran Lim. <saranl@ecosoft.co.th> | ||
| - `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__ | ||
|
|
||
| - Bhavesh Heliconia | ||
|
|
||
| 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-Saran440| image:: https://github.com/Saran440.png?size=40px | ||
| :target: https://github.com/Saran440 | ||
| :alt: Saran440 | ||
|
|
||
| Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-Saran440| | ||
|
|
||
| This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/18.0/purchase_stock_operating_unit>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Purchase Stock Operating Unit", | ||
| "summary": "Copies the operating unit of purchase picking to the stock picking", | ||
| "version": "18.0.1.0.0", | ||
| "author": "Ecosoft, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/operating-unit", | ||
| "category": "Purchase Management", | ||
| "depends": ["purchase_operating_unit", "stock_operating_unit"], | ||
| "license": "AGPL-3", | ||
| "data": [], | ||
| "installable": True, | ||
| "maintainers": ["Saran440"], | ||
| } |
32 changes: 32 additions & 0 deletions
32
purchase_stock_operating_unit/i18n/purchase_stock_operating_unit.pot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * purchase_stock_operating_unit | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 15.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "Last-Translator: \n" | ||
| "Language-Team: \n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Plural-Forms: \n" | ||
|
|
||
| #. module: purchase_stock_operating_unit | ||
| #: code:addons/purchase_stock_operating_unit/models/purchase.py:0 | ||
| #, python-format | ||
| msgid "" | ||
| "Configuration error. The Operating Unit in the Purchase and Deliver To must " | ||
| "be the same." | ||
| msgstr "" | ||
|
|
||
| #. module: purchase_stock_operating_unit | ||
| #: model:ir.model,name:purchase_stock_operating_unit.model_purchase_order | ||
| msgid "Purchase Order" | ||
| msgstr "" | ||
|
|
||
| #. module: purchase_stock_operating_unit | ||
| #: model:ir.model,name:purchase_stock_operating_unit.model_purchase_order_line | ||
| msgid "Purchase Order Line" | ||
| msgstr "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import purchase | ||
| from . import stock_rule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class PurchaseOrder(models.Model): | ||
| _inherit = "purchase.order" | ||
|
|
||
| picking_type_id = fields.Many2one( | ||
| compute="_compute_picking_type_id", store=True, readonly=False | ||
| ) | ||
| operating_unit_id = fields.Many2one( | ||
| compute="_compute_operating_unit_id", | ||
| store=True, | ||
| readonly=False, | ||
| ) | ||
|
|
||
| @api.depends("operating_unit_id") | ||
| def _compute_picking_type_id(self): | ||
| for purchase in self: | ||
| if purchase.operating_unit_id: | ||
| purchase.picking_type_id = self.env["stock.picking.type"].search( | ||
| [ | ||
| ( | ||
| "warehouse_id.operating_unit_id", | ||
| "=", | ||
| purchase.operating_unit_id.id, | ||
| ), | ||
| ("code", "=", "incoming"), | ||
| ], | ||
| limit=1, | ||
| ) | ||
|
|
||
| @api.depends("picking_type_id") | ||
| def _compute_operating_unit_id(self): | ||
| for purchase in self: | ||
| if purchase.picking_type_id: | ||
| purchase.operating_unit_id = ( | ||
| purchase.picking_type_id.warehouse_id.operating_unit_id | ||
| ) | ||
|
|
||
| @api.constrains("operating_unit_id", "picking_type_id") | ||
| def _check_operating_unit_picking_type(self): | ||
| for rec in self: | ||
| if ( | ||
| rec.operating_unit_id | ||
| and rec.picking_type_id.warehouse_id.operating_unit_id | ||
| and rec.operating_unit_id | ||
| != rec.picking_type_id.warehouse_id.operating_unit_id | ||
| ): | ||
| raise UserError( | ||
| self.env._( | ||
| "Configuration error. The Operating Unit in " | ||
| "the Purchase and Deliver To must be the same." | ||
| ) | ||
| ) | ||
|
|
||
| def _prepare_picking(self): | ||
| vals = super()._prepare_picking() | ||
| vals["operating_unit_id"] = self.operating_unit_id.id | ||
| return vals | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import models | ||
|
|
||
|
|
||
| class StockRule(models.Model): | ||
| _inherit = "stock.rule" | ||
|
|
||
| def _prepare_purchase_order(self, company_id, origins, values): | ||
| res = super()._prepare_purchase_order(company_id, origins, values) | ||
| if self.operating_unit_id: | ||
| res["operating_unit_id"] = self.operating_unit_id.id | ||
| return res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - Saran Lim. \<<saranl@ecosoft.co.th>\> | ||
| - [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) | ||
| - Bhavesh Heliconia |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| This module is used to integrated between Purchase and Stock to send | ||
| Operating Unit in the warehouse that has been selected from Deliver To | ||
| to Stock Picking. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| To use this module, you need to: | ||
|
|
||
| 1. Create a purchase order | ||
| 2. Select Deliver To that have operating unit in warehouse | ||
| 3. Confirm purchase order | ||
| 4. you should have your operating unit on your stock picking |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional Test 👍
But I'm not sure. Should we use onchange instead compute with
picking_type_idandoperating_unit_id?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think onchange makes more sense. Maybe a constraint if there is inconsistency with the operating unit.