Skip to content

Commit

Permalink
[MIG] purchase_order_archive: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CLaurelB committed Sep 14, 2023
1 parent 6ae83e9 commit 8f1b67e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 28 deletions.
3 changes: 2 additions & 1 deletion purchase_order_archive/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Purchase Order Archive
======================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -81,6 +81,7 @@ Contributors
~~~~~~~~~~~~

* Andrea Stirpe <[email protected]>
* Christihan Laurel <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion purchase_order_archive/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Onestein, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
"category": "Purchases",
"version": "14.0.1.1.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"depends": ["purchase"],
"data": ["views/purchase_order.xml"],
Expand Down
1 change: 1 addition & 0 deletions purchase_order_archive/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Andrea Stirpe <[email protected]>
* Christihan Laurel <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../../../purchase_order_archive
6 changes: 6 additions & 0 deletions purchase_order_archive/setup/purchase_order_archive/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=["setuptools-odoo"],
odoo_addon=True,
)
3 changes: 3 additions & 0 deletions purchase_order_archive/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.html).

from . import test_purchase_order_archive
63 changes: 63 additions & 0 deletions purchase_order_archive/tests/test_purchase_order_archive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Luxim d.o.o.
# Copyright 2017 Matmoz d.o.o.
# Copyright 2017 Deneroteam.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# Copyright 2017 Tecnativa
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from datetime import datetime

from odoo.exceptions import UserError # ValidationError,
from odoo.tests.common import TransactionCase


class TestPurchaseOrderArchive(TransactionCase):
def setUp(self):
super().setUp()

self.purchase_order_obj = self.env["purchase.order"]
product_id = self.env.ref("product.product_product_9")
vals = {
"partner_id": self.env.ref("base.res_partner_1").id,
"order_line": [
(
0,
0,
{
"name": product_id.name,
"product_id": product_id.id,
"product_qty": 1.0,
"product_uom": self.env.ref("uom.product_uom_unit").id,
"price_unit": 121.0,
"date_planned": datetime.today(),
},
)
],
}
self.po_draft = self.env["purchase.order"].create(vals)
self.po_sent = self.env["purchase.order"].create(vals)
self.po_sent.write({"state": "sent"})
self.po_to_approve = self.env["purchase.order"].create(vals)
self.po_to_approve.write({"state": "to approve"})
self.po_purchase = self.env["purchase.order"].create(vals)
self.po_purchase.button_confirm()
self.po_done = self.env["purchase.order"].create(vals)
self.po_done.button_confirm()
self.po_done.button_done()
self.po_cancel = self.env["purchase.order"].create(vals)
self.po_cancel.button_cancel()

def test_archive(self):
with self.assertRaises(UserError):
self.po_draft.toggle_active()
with self.assertRaises(UserError):
self.po_sent.toggle_active()
with self.assertRaises(UserError):
self.po_to_approve.toggle_active()
with self.assertRaises(UserError):
self.po_purchase.toggle_active()
self.po_done.toggle_active()
self.assertEqual(self.po_done.active, False)
self.po_cancel.toggle_active()
self.assertEqual(self.po_cancel.active, False)
26 changes: 0 additions & 26 deletions purchase_order_archive/views/purchase_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,11 @@
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<separator />
<filter
string="Active"
name="active"
domain="[('active', '=', True)]"
/>
<filter
string="Archived"
name="inactive"
domain="[('active','=',False)]"
/>
<separator />
</xpath>
</field>
</record>
<record id="purchase_order_view_search" model="ir.ui.view">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_view_search" />
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<separator />
<filter
string="Active"
name="active"
domain="[('active', '=', True)]"
/>
<filter
string="Archived"
name="inactive"
domain="[('active','=',False)]"
/>
<separator />
</xpath>
</field>
</record>
Expand Down

0 comments on commit 8f1b67e

Please sign in to comment.