Skip to content
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

[16.0][[MIG] purchase_order_revision: Migration to 16.0 #2529

Open
wants to merge 4 commits into
base: 16.0
Choose a base branch
from
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
94 changes: 94 additions & 0 deletions purchase_order_revision/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
========================
Purchase order revisions
========================

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

.. |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/16.0/purchase_order_revision
: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-16-0/purchase-workflow-16-0-purchase_order_revision
: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/purchase-workflow&target_branch=16.0
:alt: Try me on Runboat

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

Inspired on OCA module sale_order_revision, this module was rebuilt to implement
purchase_order_revision.

On Cancelled or RFQ Sent requests for quotation/purchase orders, you can click on New Revision. This
will create a new revision of the RFQ, with the same base number and a
'-revno' suffix appended. A message is added in the chatter saying that a new
revision was created.

The old revisions of a purchase order are flagged as inactive, so they don't
clutter up searches.

**Table of contents**

.. contents::
:local:

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

Pre-Requirement

You need to install OCA's base_revision and purchase modules for this module to work.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-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/purchase-workflow/issues/new?body=module:%20purchase_order_revision%0Aversion:%2016.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
~~~~~~~~~~~~

* Diogo Cordeiro <[email protected]>
* Benedito Monteiro <[email protected]>
* Daniel Reis <[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/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_order_revision>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
10 changes: 10 additions & 0 deletions purchase_order_revision/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models


def populate_unrevisioned_name(cr, registry):
cr.execute(
"UPDATE purchase_order "
"SET unrevisioned_name = name "
"WHERE unrevisioned_name is NULL"
)
15 changes: 15 additions & 0 deletions purchase_order_revision/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Purchase order revisions",
"summary": "Keep track of revised quotations",
"version": "16.0.1.0.0",
"category": "Purchase",
"author": "Open Source Integrators," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
"license": "AGPL-3",
"depends": ["base_revision", "purchase"],
"data": ["view/purchase_order.xml"],
"installable": True,
"post_init_hook": "populate_unrevisioned_name",
}
69 changes: 69 additions & 0 deletions purchase_order_revision/i18n/purchase_order_revision.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_order_revision
#
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_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__active
msgid "Active"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__current_revision_id
msgid "Current revision"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__has_old_revisions
msgid "Has Old Revisions"
msgstr ""

#. module: purchase_order_revision
#: model_terms:ir.ui.view,arch_db:purchase_order_revision.view_purchase_order_form
msgid "New Revision"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__old_revision_ids
msgid "Old revisions"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.constraint,message:purchase_order_revision.constraint_purchase_order_revision_unique
msgid "Order Reference and revision must be unique per Company."
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__unrevisioned_name
msgid "Original Reference"
msgstr ""

#. module: purchase_order_revision
#: model_terms:ir.ui.view,arch_db:purchase_order_revision.view_purchase_order_form
msgid "Prev. revisions"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__revision_count
msgid "Previous versions count"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model,name:purchase_order_revision.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_order_revision
#: model:ir.model.fields,field_description:purchase_order_revision.field_purchase_order__revision_number
msgid "Revision"
msgstr ""
3 changes: 3 additions & 0 deletions purchase_order_revision/models/__init__.py
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.html).

from . import purchase_order
41 changes: 41 additions & 0 deletions purchase_order_revision/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class PurchaseOrder(models.Model):
_name = "purchase.order"
_inherit = ["purchase.order", "base.revision"]

current_revision_id = fields.Many2one(
comodel_name="purchase.order",
)
old_revision_ids = fields.One2many(
comodel_name="purchase.order",
)

# Overwrite as purchase.order can be multi-company
_sql_constraints = [
(
"revision_unique",
"unique(unrevisioned_name, revision_number, company_id)",
"Order Reference and revision must be unique per Company.",
)
]

def _prepare_revision_data(self, new_revision):
vals = super()._prepare_revision_data(new_revision)
vals.update({"state": "cancel"})
return vals

def action_view_revisions(self):
self.ensure_one()
action = self.env.ref("purchase.purchase_rfq")
result = action.read()[0]
result["domain"] = ["|", ("active", "=", False), ("active", "=", True)]
result["context"] = {

Check warning on line 36 in purchase_order_revision/models/purchase_order.py

View check run for this annotation

Codecov / codecov/patch

purchase_order_revision/models/purchase_order.py#L32-L36

Added lines #L32 - L36 were not covered by tests
"active_test": 0,
"search_default_current_revision_id": self.id,
"default_current_revision_id": self.id,
}
return result

Check warning on line 41 in purchase_order_revision/models/purchase_order.py

View check run for this annotation

Codecov / codecov/patch

purchase_order_revision/models/purchase_order.py#L41

Added line #L41 was not covered by tests
3 changes: 3 additions & 0 deletions purchase_order_revision/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Diogo Cordeiro <[email protected]>
* Benedito Monteiro <[email protected]>
* Daniel Reis <[email protected]>
10 changes: 10 additions & 0 deletions purchase_order_revision/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Inspired on OCA module sale_order_revision, this module was rebuilt to implement
purchase_order_revision.

On Cancelled or RFQ Sent requests for quotation/purchase orders, you can click on New Revision. This
will create a new revision of the RFQ, with the same base number and a
'-revno' suffix appended. A message is added in the chatter saying that a new
revision was created.

The old revisions of a purchase order are flagged as inactive, so they don't
clutter up searches.
3 changes: 3 additions & 0 deletions purchase_order_revision/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pre-Requirement

You need to install OCA's base_revision and purchase modules for this module to work.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading