diff --git a/purchase_isolated_rfq/README.rst b/purchase_isolated_rfq/README.rst new file mode 100644 index 00000000000..436816e4b5e --- /dev/null +++ b/purchase_isolated_rfq/README.rst @@ -0,0 +1,98 @@ +===================== +Purchase Isolated RFQ +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_isolated_rfq + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_isolated_rfq + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Note: This module is similar to sale_isolated_quotation, but for purchase/rfq + +In some countries/companies, It's already common to separate these two documents. +For filing purposes, the document sequence of Requests For Quotation (RFQ) and Purchases order +has to be separated. In practice, there could be multiple RFQ open +to a vendor, yet only one RFQ get converted to the Purchases order. + +This module separate RFQ and Purchases order by adding order_sequence flag in +purchase.order model. + +Each type of document will have separated sequence numbering. +RFQ will have only 2 state, Draft and Done. Purchases Order work as normal. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* Create RFQ as normal +* As user click "Convert to Order", the isolated purchases order will be created + +Bug Tracker +=========== + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* Rattapong Chokmasermkul + +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-kittiu| image:: https://github.com/kittiu.png?size=40px + :target: https://github.com/kittiu + :alt: kittiu + +Current `maintainer `__: + +|maintainer-kittiu| + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_isolated_rfq/__init__.py b/purchase_isolated_rfq/__init__.py new file mode 100644 index 00000000000..1b071293581 --- /dev/null +++ b/purchase_isolated_rfq/__init__.py @@ -0,0 +1,2 @@ +from .hooks import post_init_hook, uninstall_hook +from . import models diff --git a/purchase_isolated_rfq/__manifest__.py b/purchase_isolated_rfq/__manifest__.py new file mode 100644 index 00000000000..8314ca4f0bc --- /dev/null +++ b/purchase_isolated_rfq/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Ecosoft Co., Ltd (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +{ + "name": "Purchase Isolated RFQ", + "version": "15.0.1.0.1", + "author": "Ecosoft, Odoo Community Association (OCA)", + "category": "Purchases", + "website": "https://github.com/OCA/purchase-workflow", + "depends": ["purchase"], + "license": "AGPL-3", + "data": ["data/ir_sequence_data.xml", "views/purchase_views.xml"], + "maintainers": ["kittiu"], + "installable": True, + "uninstall_hook": "uninstall_hook", + "post_init_hook": "post_init_hook", +} diff --git a/purchase_isolated_rfq/data/ir_sequence_data.xml b/purchase_isolated_rfq/data/ir_sequence_data.xml new file mode 100644 index 00000000000..0c9279671f1 --- /dev/null +++ b/purchase_isolated_rfq/data/ir_sequence_data.xml @@ -0,0 +1,10 @@ + + + + Requests for Quotation + purchase.rfq + RFQ + 3 + + + diff --git a/purchase_isolated_rfq/hooks.py b/purchase_isolated_rfq/hooks.py new file mode 100644 index 00000000000..87a62481ede --- /dev/null +++ b/purchase_isolated_rfq/hooks.py @@ -0,0 +1,45 @@ +# Copyright 2020 Ecosoft Co., Ltd (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +import ast + +from odoo import SUPERUSER_ID, api + +ACTIONS = { + "purchase.purchase_rfq": {"dom": [], "ctx": {"quotation_only": True}}, + "purchase.purchase_form_action": { + "dom": [("state", "in", ("purchase", "done"))], + "ctx": {}, + }, +} + + +def post_init_hook(cr, registry): + """Set value for order_sequence on old records""" + cr.execute( + """ + update purchase_order + set order_sequence = true + where state not in ('draft', 'cancel') + """ + ) + + +def uninstall_hook(cr, registry): + """Restore purchase.order action's domain/context""" + env = api.Environment(cr, SUPERUSER_ID, {}) + for action_id in ACTIONS: + action = env.ref(action_id) + # Clean context + ctx = ast.literal_eval(action.context) + if "order_sequence" in ctx: + del ctx["order_sequence"] + if "default_order_sequence" in ctx: + del ctx["default_order_sequence"] + # Clean domain + dom = ast.literal_eval(action.domain or "[]") + dom = [x for x in dom if x[0] != "order_sequence"] + # Assign original domain / context + dom += ACTIONS[action_id]["dom"] + dom = list(set(dom)) + ctx.update(ACTIONS[action_id]["ctx"]) + action.write({"context": ctx, "domain": dom}) diff --git a/purchase_isolated_rfq/i18n/pt.po b/purchase_isolated_rfq/i18n/pt.po new file mode 100644 index 00000000000..4baab8a4f42 --- /dev/null +++ b/purchase_isolated_rfq/i18n/pt.po @@ -0,0 +1,94 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_isolated_rfq +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-07-26 13:06+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: purchase_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Cancel" +msgstr "Cancelar" + +#. module: purchase_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Convert to Order" +msgstr "Converter em Encomenda" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__display_name +msgid "Display Name" +msgstr "Nome a Apresentar" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "For Purchases Order, this field references to its RFQ" +msgstr "Em Encomendas de Compra, este campo referencia os seus PdO" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "For RFQ, this field references to its Purchases Order" +msgstr "Em PdO, este campo referencia as suas Encomendas de Compra" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__id +msgid "ID" +msgstr "ID" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "Última Modificação Em" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Only quotation can convert to order" +msgstr "Apenas cotações podem ser convertidas em encomendas" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "Only relative RFQ states" +msgstr "Apenas estados PdC relativos" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "Order" +msgstr "Encomenda" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__order_sequence +msgid "Order Sequence" +msgstr "Sequência de Ordenação" + +#. module: purchase_isolated_rfq +#: model:ir.model,name:purchase_isolated_rfq.model_purchase_order +msgid "Purchase Order" +msgstr "Encomenda de Compra" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Purchases Order" +msgstr "Encomenda de Compra" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "Quotation" +msgstr "Cotação" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "RFQ Status" +msgstr "Estado do PdC" diff --git a/purchase_isolated_rfq/i18n/purchase_isolated_rfq.pot b/purchase_isolated_rfq/i18n/purchase_isolated_rfq.pot new file mode 100644 index 00000000000..36f4b1b03ca --- /dev/null +++ b/purchase_isolated_rfq/i18n/purchase_isolated_rfq.pot @@ -0,0 +1,91 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_isolated_rfq +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Cancel" +msgstr "" + +#. module: purchase_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Convert to Order" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__display_name +msgid "Display Name" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "For Purchases Order, this field references to its RFQ" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "For RFQ, this field references to its Purchases Order" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__id +msgid "ID" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Only quotation can convert to order" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "Only relative RFQ states" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "Order" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__order_sequence +msgid "Order Sequence" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model,name:purchase_isolated_rfq.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Purchases Order" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "Quotation" +msgstr "" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "RFQ Status" +msgstr "" diff --git a/purchase_isolated_rfq/i18n/zh_CN.po b/purchase_isolated_rfq/i18n/zh_CN.po new file mode 100644 index 00000000000..52358ebba5d --- /dev/null +++ b/purchase_isolated_rfq/i18n/zh_CN.po @@ -0,0 +1,79 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_isolated_rfq +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-25 08:44+0000\n" +"Last-Translator: Dong \n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: purchase_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Cancel" +msgstr "取消" + +#. module: purchase_isolated_rfq +#: model_terms:ir.ui.view,arch_db:purchase_isolated_rfq.purchase_order_form +msgid "Convert to Order" +msgstr "转为采购订单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "For Purchases Order, this field references to its RFQ" +msgstr "对于采购订单,该字段引用自采购询价单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "For RFQ, this field references to its Purchases Order" +msgstr "对于采购询价单,该字段引用自采购订单" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Only quotation can convert to order" +msgstr "只有采购询价单可以转为采购订单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,help:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "Only relative RFQ states" +msgstr "采购询价单状态" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__purchase_order_id +msgid "Order" +msgstr "采购订单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__order_sequence +msgid "Order Sequence" +msgstr "订单编号" + +#. module: purchase_isolated_rfq +#: model:ir.model,name:purchase_isolated_rfq.model_purchase_order +msgid "Purchase Order" +msgstr "采购订单" + +#. module: purchase_isolated_rfq +#: code:addons/purchase_isolated_rfq/models/purchase_order.py:0 +#, python-format +msgid "Purchases Order" +msgstr "采购订单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__quote_id +msgid "Quotation" +msgstr "询价单" + +#. module: purchase_isolated_rfq +#: model:ir.model.fields,field_description:purchase_isolated_rfq.field_purchase_order__rfq_state +msgid "RFQ Status" +msgstr "询价单状态" diff --git a/purchase_isolated_rfq/models/__init__.py b/purchase_isolated_rfq/models/__init__.py new file mode 100644 index 00000000000..9f03530643d --- /dev/null +++ b/purchase_isolated_rfq/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_isolated_rfq/models/purchase_order.py b/purchase_isolated_rfq/models/purchase_order.py new file mode 100644 index 00000000000..4cb985901e2 --- /dev/null +++ b/purchase_isolated_rfq/models/purchase_order.py @@ -0,0 +1,76 @@ +# Copyright 2020 Ecosoft Co., Ltd (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + order_sequence = fields.Boolean(readonly=True, index=True) + quote_id = fields.Many2one( + comodel_name="purchase.order", + string="Quotation", + readonly=True, + ondelete="restrict", + copy=False, + help="For Purchases Order, this field references to its RFQ", + ) + purchase_order_id = fields.Many2one( + comodel_name="purchase.order", + string="Order", + readonly=True, + ondelete="restrict", + copy=False, + help="For RFQ, this field references to its Purchases Order", + ) + rfq_state = fields.Selection( + string="RFQ Status", + readonly=True, + related="state", + help="Only relative RFQ states", + ) + + @api.model + def create(self, vals): + order_sequence = vals.get("order_sequence") or self.env.context.get( + "order_sequence" + ) + if not order_sequence and vals.get("name", "/") == "/": + vals["name"] = self.env["ir.sequence"].next_by_code("purchase.rfq") or "/" + return super().create(vals) + + def _prepare_order_from_rfq(self): + return { + "name": self.env["ir.sequence"].next_by_code("purchase.order") or "/", + "order_sequence": True, + "quote_id": self.id, + "partner_ref": self.partner_ref, + } + + def action_convert_to_order(self): + self.ensure_one() + if self.order_sequence: + raise UserError(_("Only quotation can convert to order")) + purchase_order = self.copy(self._prepare_order_from_rfq()) + purchase_order.button_confirm() + # Reference from this RFQ to Purchase Order + self.purchase_order_id = purchase_order.id + if self.state == "draft": + self.button_done() + return self.open_duplicated_purchase_order() + + @api.model + def open_duplicated_purchase_order(self): + return { + "name": _("Purchases Order"), + "view_mode": "form", + "view_id": False, + "res_model": "purchase.order", + "context": {"default_order_sequence": True, "order_sequence": True}, + "type": "ir.actions.act_window", + "nodestroy": True, + "target": "current", + "domain": "[('order_sequence', '=', True)]", + "res_id": self.purchase_order_id and self.purchase_order_id.id or False, + } diff --git a/purchase_isolated_rfq/readme/CONTRIBUTORS.rst b/purchase_isolated_rfq/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..79207589486 --- /dev/null +++ b/purchase_isolated_rfq/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Rattapong Chokmasermkul diff --git a/purchase_isolated_rfq/readme/DESCRIPTION.rst b/purchase_isolated_rfq/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..7cd8fde472f --- /dev/null +++ b/purchase_isolated_rfq/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +Note: This module is similar to sale_isolated_quotation, but for purchase/rfq + +In some countries/companies, It's already common to separate these two documents. +For filing purposes, the document sequence of Requests For Quotation (RFQ) and Purchases order +has to be separated. In practice, there could be multiple RFQ open +to a vendor, yet only one RFQ get converted to the Purchases order. + +This module separate RFQ and Purchases order by adding order_sequence flag in +purchase.order model. + +Each type of document will have separated sequence numbering. +RFQ will have only 2 state, Draft and Done. Purchases Order work as normal. diff --git a/purchase_isolated_rfq/readme/USAGE.rst b/purchase_isolated_rfq/readme/USAGE.rst new file mode 100644 index 00000000000..f703e3ad408 --- /dev/null +++ b/purchase_isolated_rfq/readme/USAGE.rst @@ -0,0 +1,2 @@ +* Create RFQ as normal +* As user click "Convert to Order", the isolated purchases order will be created diff --git a/purchase_isolated_rfq/static/description/icon.png b/purchase_isolated_rfq/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_isolated_rfq/static/description/icon.png differ diff --git a/purchase_isolated_rfq/static/description/index.html b/purchase_isolated_rfq/static/description/index.html new file mode 100644 index 00000000000..c645ddd0587 --- /dev/null +++ b/purchase_isolated_rfq/static/description/index.html @@ -0,0 +1,437 @@ + + + + + + +Purchase Isolated RFQ + + + +
+

Purchase Isolated RFQ

+ + +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

Note: This module is similar to sale_isolated_quotation, but for purchase/rfq

+

In some countries/companies, It’s already common to separate these two documents. +For filing purposes, the document sequence of Requests For Quotation (RFQ) and Purchases order +has to be separated. In practice, there could be multiple RFQ open +to a vendor, yet only one RFQ get converted to the Purchases order.

+

This module separate RFQ and Purchases order by adding order_sequence flag in +purchase.order model.

+

Each type of document will have separated sequence numbering. +RFQ will have only 2 state, Draft and Done. Purchases Order work as normal.

+

Table of contents

+ +
+

Usage

+
    +
  • Create RFQ as normal
  • +
  • As user click “Convert to Order”, the isolated purchases order will be created
  • +
+
+
+

Bug Tracker

+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

kittiu

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_isolated_rfq/tests/__init__.py b/purchase_isolated_rfq/tests/__init__.py new file mode 100644 index 00000000000..1e240f8aa90 --- /dev/null +++ b/purchase_isolated_rfq/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_isolated_rfq diff --git a/purchase_isolated_rfq/tests/test_purchase_isolated_rfq.py b/purchase_isolated_rfq/tests/test_purchase_isolated_rfq.py new file mode 100644 index 00000000000..9dc5a23502b --- /dev/null +++ b/purchase_isolated_rfq/tests/test_purchase_isolated_rfq.py @@ -0,0 +1,63 @@ +# Copyright 2020 Ecosoft Co., Ltd (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from odoo.exceptions import UserError +from odoo.modules import registry +from odoo.tests.common import TransactionCase + +from ..hooks import ACTIONS, uninstall_hook + + +class TestPurchaseIsolatedRFQ(TransactionCase): + def setUp(self): + super().setUp() + self.partner = self.env.ref("base.res_partner_2") + vals = {"partner_id": self.partner.id, "order_sequence": False} + self.rfq = self.env["purchase.order"].create(vals) + + def test_quotation_convert_to_order(self): + """Expect. + - When quotation is converted to order + - Status chagned to 'done' + - New purchase.order of order_sequence = True created + - RFQ can reference to Order and Order can reference to RFQ too + """ + self.rfq.action_convert_to_order() + po = self.rfq.purchase_order_id + self.assertEqual(self.rfq.state, "done") + self.assertFalse(self.rfq.order_sequence) + self.assertTrue(po.order_sequence) + self.assertEqual(po.state, "purchase") + self.assertEqual(po.partner_id, self.partner) + self.assertEqual(po.quote_id, self.rfq) + # Exceptions Case + with self.assertRaises(UserError) as e: + po.action_convert_to_order() + error_message = "Only quotation can convert to order" + self.assertEqual(e.exception.args[0], error_message) + + def test_uninstall_hook(self): + """Test if related actions are reset to state + before this module was installed + """ + uninstall_hook(self.cr, registry) + for xml_action_id in ACTIONS: + action = self.env.ref(xml_action_id) + # check context + check_ctx = any( + [ + x in action.context + for x in ["order_sequence", "default_order_sequence"] + ] + ) + self.assertFalse( + check_ctx, + "context order_sequence/default_order_sequence" + + " should be removed from action (%s)" % (action.name), + ) + # check domain + check_dom = any([x in action.domain for x in ["order_sequence"]]) + self.assertFalse( + check_dom, + "domain order_sequence should be removed from action (%s)" + % (action.name), + ) diff --git a/purchase_isolated_rfq/views/purchase_views.xml b/purchase_isolated_rfq/views/purchase_views.xml new file mode 100644 index 00000000000..e6c2fbb35c8 --- /dev/null +++ b/purchase_isolated_rfq/views/purchase_views.xml @@ -0,0 +1,72 @@ + + + purchase.order.form + purchase.order + + + + not context.get('order_sequence', False) + + +
+
+
+ + + + + + + {'order_sequence': order_sequence} + + +
+ + + {'default_order_sequence': False, 'order_sequence': False} + [('order_sequence', '=', False)] + + + {'default_order_sequence': True, 'order_sequence': True} + [('order_sequence', '=', True)] + +
diff --git a/setup/purchase_isolated_rfq/odoo/addons/purchase_isolated_rfq b/setup/purchase_isolated_rfq/odoo/addons/purchase_isolated_rfq new file mode 120000 index 00000000000..659a7abf076 --- /dev/null +++ b/setup/purchase_isolated_rfq/odoo/addons/purchase_isolated_rfq @@ -0,0 +1 @@ +../../../../purchase_isolated_rfq \ No newline at end of file diff --git a/setup/purchase_isolated_rfq/setup.py b/setup/purchase_isolated_rfq/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_isolated_rfq/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)