Skip to content

Commit

Permalink
[MIG] purchase_request_department: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-adhoc committed Sep 16, 2024
1 parent 865e79f commit c2e43fb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion purchase_request_department/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Purchase Request Department",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"version": "16.0.1.0.0",
"version": "17.0.1.1.0",
"website": "https://github.com/OCA/purchase-workflow",
"category": "Purchase Management",
"post_init_hook": "post_init_hook",
Expand Down
18 changes: 7 additions & 11 deletions purchase_request_department/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


def post_init_hook(cr, registry):
def post_init_hook(env):
"""Loaded after installing the module."""
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
purchase_requests = env["purchase.request"].search([])
_logger.info(
"Adding the department to %d purchase requests", len(purchase_requests)
)
for purchase_request in purchase_requests:
purchase_request.onchange_requested_by()
purchase_requests = env["purchase.request"].search([])
_logger.info(
"Adding the department to %d purchase requests", len(purchase_requests)
)
for purchase_request in purchase_requests:
purchase_request.onchange_requested_by()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestPurchaseRequest(TransactionCase):
def setUp(self):
super(TestPurchaseRequest, self).setUp()
super().setUp()
self.pr_model = self.env["purchase.request"]
self.prl_model = self.env["purchase.request.line"]
self.usr_model = self.env["res.users"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
<field name="inherit_id" ref="purchase_request.view_purchase_request_form" />
<field name="arch" type="xml">
<field name="requested_by" position="after">
<field
name="department_id"
attrs="{'readonly': [('state', '!=', 'draft')]}"
/>
<field name="department_id" readonly="state != 'draft'" />
</field>
</field>
</record>
Expand Down Expand Up @@ -56,10 +53,7 @@
<field name="inherit_id" ref="purchase_request.purchase_request_line_form" />
<field name="arch" type="xml">
<field name="requested_by" position="after">
<field
name="department_id"
attrs="{'readonly': [('request_state', '!=', 'draft')]}"
/>
<field name="department_id" readonly="request_state != 'draft'" />
</field>
</field>
</record>
Expand Down

0 comments on commit c2e43fb

Please sign in to comment.