-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[17.0] [ADD] sale_blanket_order_tier_validation #3277
Open
Nikul-OSI
wants to merge
1
commit into
OCA:17.0
Choose a base branch
from
ursais:17_add_sale_blanket_order_tier_validation
base: 17.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
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 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,112 @@ | ||
=================================== | ||
Sale Blanket Orders Tier Validation | ||
=================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:adb4549c4d5a6fc42fc865560f51f2d2ab705b8ac7a18c08cced1309637bf945 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fsale--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/sale-workflow/tree/17.0/sale_blanket_order_tier_validation | ||
:alt: OCA/sale-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_blanket_order_tier_validation | ||
: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/sale-workflow&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Extends the functionality of your Sale Blanket Orders to support a tier | ||
validation process | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
This module depends on ``base_tier_validation``. You can find it at | ||
`OCA/server-ux <https://github.com/OCA/server-ux>`__ | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
1. Go to *Settings > Technical > Tier Validations > Tier Definition*. | ||
2. Create as many tiers as you want for Purchase Order model. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
1. Create a Sale Blanket Orders triggering at least one "Tier | ||
Definition". | ||
2. Click on *Request Validation* button. | ||
3. Under the tab *Reviews* have a look to pending reviews and their | ||
statuses. | ||
4. Once all reviews are validated click on *Confirm Order*. | ||
|
||
Additional features: | ||
|
||
- You can filter the Blanket Orders requesting your review through the | ||
filter *Needs my Review*. | ||
- User with rights to confirm the Blanket Orders (validate all tiers | ||
that would be generated) can directly do the operation, this is, | ||
there is no need for her/him to request a validation. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_blanket_order_tier_validation%0Aversion:%2017.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 | ||
------- | ||
|
||
* Open Source Integrators | ||
|
||
Contributors | ||
------------ | ||
|
||
- Patrick Wilson <[email protected]> | ||
- Nikul Chaudhary <[email protected]> | ||
|
||
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/sale-workflow <https://github.com/OCA/sale-workflow/tree/17.0/sale_blanket_order_tier_validation>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains 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 @@ | ||
# Copyright 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from . import models |
This file contains 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,23 @@ | ||
# Copyright 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Sale Blanket Orders Tier Validation", | ||
"summary": """ | ||
Extends the functionality of your Sale Blanket Orders | ||
to support a tier validation process. | ||
""", | ||
"author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"license": "AGPL-3", | ||
"category": "Sales", | ||
"version": "17.0.1.0.0", | ||
"depends": [ | ||
"sale_blanket_order", | ||
"base_tier_validation", | ||
], | ||
"data": [ | ||
"views/sale_blanket_order_views.xml", | ||
], | ||
"application": False, | ||
"installable": True, | ||
} |
This file contains 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 @@ | ||
# Copyright 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from . import sale_blanket_order | ||
from . import tier_definition |
56 changes: 56 additions & 0 deletions
56
sale_blanket_order_tier_validation/models/sale_blanket_order.py
This file contains 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,56 @@ | ||
# Copyright 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
from odoo.tools import float_is_zero | ||
|
||
|
||
class SaleBlanketOrder(models.Model): | ||
""" | ||
Adding tier validation functionality to Blanket Orders. | ||
""" | ||
|
||
_name = "sale.blanket.order" | ||
_inherit = ["sale.blanket.order", "tier.validation"] | ||
_state_from = ["draft"] | ||
_state_to = ["open", "done", "expired"] | ||
|
||
_tier_validation_manual_config = False | ||
|
||
@api.depends( | ||
"line_ids.remaining_uom_qty", | ||
"validity_date", | ||
"confirmed", | ||
) | ||
def _compute_state(self): | ||
"""Complete override of Blanket Order Compute State Method: | ||
The OCA Blanket Order module sets state via compute method which messes | ||
with tier validation checks so we are going to instead set the state | ||
to 'Open' only when clicking confirmed. This also forces process as before | ||
just changing data would reset BO back to Open if expired.""" | ||
today = fields.Date.today() | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
for order in self: | ||
if not order.confirmed: | ||
order.state = "draft" | ||
elif order.validity_date <= today: | ||
order.state = "expired" | ||
elif float_is_zero( | ||
sum( | ||
order.line_ids.filtered(lambda line: not line.display_type).mapped( | ||
"remaining_uom_qty" | ||
) | ||
), | ||
precision_digits=precision, | ||
): | ||
order.state = "done" | ||
# Removing else statement from original method | ||
# else: | ||
# order.state = "open" | ||
|
||
def action_confirm(self): | ||
"""Set the state to 'Open' when clicking confirmed instead of during compute.""" | ||
for rec in self: | ||
rec.write({"state": "open"}) | ||
return super().action_confirm() |
18 changes: 18 additions & 0 deletions
18
sale_blanket_order_tier_validation/models/tier_definition.py
This file contains 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,18 @@ | ||
# Copyright 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, models | ||
|
||
|
||
class TierDefinition(models.Model): | ||
""" | ||
Add Sale Blanket Order model to tier definitions. | ||
""" | ||
|
||
_inherit = "tier.definition" | ||
|
||
@api.model | ||
def _get_tier_validation_model_names(self): | ||
"""This method adds the Sale Blanket Order model to tier definitions.""" | ||
res = super()._get_tier_validation_model_names() | ||
res.append("sale.blanket.order") | ||
return res |
This file contains 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 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,5 @@ | ||
To configure this module, you need to: | ||
|
||
1. Go to *Settings \> Technical \> Tier Validations \> Tier | ||
Definition*. | ||
2. Create as many tiers as you want for Purchase Order model. |
This file contains 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,2 @@ | ||
- Patrick Wilson \<<[email protected]>\> | ||
- Nikul Chaudhary \<<[email protected]>\> |
This file contains 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,2 @@ | ||
Extends the functionality of your Sale Blanket Orders | ||
to support a tier validation process |
This file contains 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,2 @@ | ||
This module depends on `base_tier_validation`. You can find it at | ||
[OCA/server-ux](https://github.com/OCA/server-ux) |
This file contains 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,15 @@ | ||
To use this module, you need to: | ||
|
||
1. Create a Sale Blanket Orders triggering at least one "Tier Definition". | ||
2. Click on *Request Validation* button. | ||
3. Under the tab *Reviews* have a look to pending reviews and their | ||
statuses. | ||
4. Once all reviews are validated click on *Confirm Order*. | ||
|
||
Additional features: | ||
|
||
- You can filter the Blanket Orders requesting your review through the filter | ||
*Needs my Review*. | ||
- User with rights to confirm the Blanket Orders (validate all tiers that would be | ||
generated) can directly do the operation, this is, there is no need | ||
for her/him to request a validation. |
Oops, something went wrong.
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.
FYI I did OCA/server-ux#939 so that tier validations can be applied to computed state fields as in this model.
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.
Would you consider reviewing that change and refactoring this module to work with it? You wouldn't have to jump through hoops like you do in the code above.
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 did the refactoring in ursais#14. What do you think?