Skip to content

Commit

Permalink
[ADD]sale_blanket_order_tier_validation: Added in v17
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikul-OSI committed Aug 20, 2024
1 parent cd9213c commit 4903a4b
Show file tree
Hide file tree
Showing 17 changed files with 878 additions and 0 deletions.
112 changes: 112 additions & 0 deletions sale_blanket_order_tier_validation/README.rst
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 <pwilson@opensourceintegrators.com>
- Nikul Chaudhary <nchaudhary@opensourceintegrators.com>

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.
3 changes: 3 additions & 0 deletions sale_blanket_order_tier_validation/__init__.py
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
23 changes: 23 additions & 0 deletions sale_blanket_order_tier_validation/__manifest__.py
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,
}
4 changes: 4 additions & 0 deletions sale_blanket_order_tier_validation/models/__init__.py
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 sale_blanket_order_tier_validation/models/sale_blanket_order.py
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 sale_blanket_order_tier_validation/models/tier_definition.py
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
3 changes: 3 additions & 0 deletions sale_blanket_order_tier_validation/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions sale_blanket_order_tier_validation/readme/CONFIGURE.md
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.
2 changes: 2 additions & 0 deletions sale_blanket_order_tier_validation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Patrick Wilson \<<pwilson@opensourceintegrators.com>\>
- Nikul Chaudhary \<<nchaudhary@opensourceintegrators.com>\>
2 changes: 2 additions & 0 deletions sale_blanket_order_tier_validation/readme/DESCRIPTION.md
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
2 changes: 2 additions & 0 deletions sale_blanket_order_tier_validation/readme/INSTALL.md
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)
15 changes: 15 additions & 0 deletions sale_blanket_order_tier_validation/readme/USAGE.md
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4903a4b

Please sign in to comment.