Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions purchase_stock_tier_validation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==============================
Purchase Stock Tier Validation
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:regenerate_with_oca_gen_addon_readme
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Ftier--validation-lightgray.png?logo=github
:target: https://github.com/OCA/tier-validation/tree/19.0/purchase_stock_tier_validation
:alt: OCA/tier-validation
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/tier-validation-19-0/tier-validation-19-0-purchase_stock_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/tier-validation&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module excludes RFQs pending to validate or validated when procuring a product.

If a RFQ, at some point, is requested to validate, it converts it immediately in something unmodifiable.
Then, taking this into account, if we procure a product with the same supplier as one open RFQ, it should
check if that is under validation or already validated and discard it on any of both cases.

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on ``purchase_tier_validation``. You can find it in
this same repository, `OCA/tier-validation <https://github.com/OCA/tier-validation>`__.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/tier-validation/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/tier-validation/issues/new?body=module:%20purchase_stock_tier_validation%0Aversion:%2019.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
-------

* ForgeFlow

Contributors
------------

- Bernat Puig Font <bernat.puig@forgeflow.com>
- Giordano Loiaconi <giordanoloiaconi95@gmail.com> (migrate to v19)

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/tier-validation <https://github.com/OCA/tier-validation/tree/19.0/purchase_stock_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 purchase_stock_tier_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
16 changes: 16 additions & 0 deletions purchase_stock_tier_validation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Purchase Stock Tier Validation",
"summary": "Exclude RFQs pending to validate when procuring",
"version": "19.0.1.0.0",
"category": "Purchase Management",
"website": "https://github.com/OCA/tier-validation",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"maintainers": ["bosd"],
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": ["purchase_stock", "purchase_tier_validation"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_stock_tier_validation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to update the version manually; it will be updated automatically by the OCA bot.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BhaveshHeliconia thanks. I wasn't sure what you meant here: this line is the Project-Id-Version header of the .pot, generated by Odoo's export, and I haven't changed the manifest version by hand beyond the 19.0.1.0.0 that a [MIG] commit sets. Did you mean the manifest version, or something else in this file?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yordyotl Yes, I meant the .pot file itself (purchase_stock_tier_validation/i18n/purchase_stock_tier_validation.pot).

In OCA, .pot files and their headers (Project-Id-Version) are generated and updated automatically by the oca-ci bot post-merge (via automated [UPD] Update <module>.pot commits).

To keep migration PRs minimal and avoid translation/Weblate conflicts, we usually don't include .pot file updates in migration commits. Could you please revert/discard the changes to the .pot file from this PR?

Other than that, the test updates look great! Thanks!

"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_tier_validation
#: model:ir.model,name:purchase_stock_tier_validation.model_stock_rule
msgid "Stock Rule"
msgstr ""
3 changes: 3 additions & 0 deletions purchase_stock_tier_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import stock_rule
15 changes: 15 additions & 0 deletions purchase_stock_tier_validation/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# Part of ForgeFlow. See LICENSE file for full copyright and licensing details.

from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _make_po_get_domain(self, company_id, values, partner):
domain = super()._make_po_get_domain(
company_id=company_id, values=values, partner=partner
)
domain += (("review_ids", "=", False),)
return domain
3 changes: 3 additions & 0 deletions purchase_stock_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"
2 changes: 2 additions & 0 deletions purchase_stock_tier_validation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Bernat Puig Font \<<bernat.puig@forgeflow.com>\>
- Giordano Loiaconi \<<giordanoloiaconi95@gmail.com>\> (migrate to v19)
5 changes: 5 additions & 0 deletions purchase_stock_tier_validation/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module excludes RFQs pending to validate or validated when procuring a product.

If a RFQ, at some point, is requested to validate, it converts it immediately in something unmodifiable.
Then, taking this into account, if we procure a product with the same supplier as one open RFQ, it should
check if that is under validation or already validated and discard it on any of both cases.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions purchase_stock_tier_validation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_purchase_stock_tier_validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright 2017-2020 ForgeFlow S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from odoo import Command, fields
from odoo.tests import new_test_user, tagged

from odoo.addons.base.tests.common import BaseCommon


@tagged("-at_install", "post_install")
class TestPurchaseStockTierValidation(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
# Get purchase order model
cls.po_model = cls.env.ref("purchase.model_purchase_order")

# Create users
cls.test_user_1 = new_test_user(
cls.env, name="John", login="test1", groups="base.group_system"
)

# Create tier definitions:
cls.tier_def_obj = cls.env["tier.definition"]
cls.tier_def_obj.create(
{
"model_id": cls.po_model.id,
"review_type": "individual",
"reviewer_id": cls.test_user_1.id,
}
)

# Common models
cls.stock_loc = cls.env.ref("stock.stock_location_stock")
cls.warehouse = cls.env.ref("stock.warehouse0")

# Create product
route_buy = cls.env.ref("purchase_stock.route_warehouse0_buy").id
cls.test_product = cls.env["product.product"].create(
{
"name": "Test Scrap Component 1",
"type": "consu",
"is_storable": True,
"route_ids": [Command.set([route_buy])],
"seller_ids": [
Command.create({"partner_id": cls.partner.id, "price": 20.0})
],
}
)

def test_procurement_in_new_rfq(self):
"""
Procure a product with the same supplier as one open RFQ under validation
and check if it includes the procurement in that RFQ or in a new one.
"""
po = self.env["purchase.order"].create(
{
"partner_id": self.partner.id,
"order_line": [
Command.create(
{
"name": "PO-Product",
"product_id": self.test_product.id,
"date_planned": fields.Datetime.now(),
"product_qty": 10,
"product_uom_id": self.test_product.uom_id.id,
"price_unit": 1000,
},
)
],
}
)
rfq_test_partner_before = self.env["purchase.order"].search(
[("partner_id", "=", self.partner.id)]
)
self.assertEqual(len(po.mapped("order_line")), 1)
po.request_validation()
po.with_user(self.test_user_1).validate_tier()
date_planned = fields.Datetime.now()
values = {
"company_id": self.warehouse.company_id,
"date_planned": date_planned,
"warehouse_id": self.warehouse,
}
procurements = [
self.env["stock.rule"].Procurement(
self.test_product,
1,
self.env.ref("uom.product_uom_unit"),
self.stock_loc,
"test",
"TEST",
self.warehouse.company_id,
values,
)
]
self.env["stock.rule"].run(procurements)
self.assertEqual(len(po.mapped("order_line")), 1)
rfq_test_partner_after = self.env["purchase.order"].search(
[("partner_id", "=", self.partner.id)]
)
self.assertEqual(len(rfq_test_partner_after), len(rfq_test_partner_before) + 1)
Loading