From ed295ddb3000c41d4bd86f9170f2d3e300f4054f Mon Sep 17 00:00:00 2001 From: Mohamed Eltayar Date: Thu, 13 Nov 2025 14:50:06 +0300 Subject: [PATCH] feat: add branch field to purchase request and order modules with correct paths - Added branch_id field to purchase.request model with auto-computation - Added branch_id field to purchase.order model with auto-computation - Updated purchase request form, tree, and search views with branch field - Updated purchase order form, tree, and search views with branch field - Added Arabic translations for branch field - Branch propagates from request to purchase order during creation - Uses context for short branch name display Files modified with correct paths: - odex25_purchase/purchase_requisition_custom/models/purchase_request.py - odex25_purchase/purchase_requisition_custom/models/purchase_order.py - odex25_purchase/purchase_requisition_custom/views/purchase_request.xml - odex25_purchase/purchase_requisition_custom/views/purchase_requisition_custom.xml - odex25_purchase/purchase_requisition_custom/i18n/ar_001.po Synced with latest dev_odex25_purchase on Thu Nov 13 14:50:06 +03 2025 --- .../models/purchase_order.py | 23 +++++++++++++++++++ .../views/purchase_request.xml | 6 ++--- .../views/purchase_requisition_custom.xml | 5 ++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/odex25_purchase/purchase_requisition_custom/models/purchase_order.py b/odex25_purchase/purchase_requisition_custom/models/purchase_order.py index 9241c22d8..589e927da 100644 --- a/odex25_purchase/purchase_requisition_custom/models/purchase_order.py +++ b/odex25_purchase/purchase_requisition_custom/models/purchase_order.py @@ -124,6 +124,19 @@ class PurchaseOrderCustom(models.Model): ('budget_rejected', 'Rejected By Budget'), ('wait_for_send', 'Waiting For Send to Budget')], default='wait') department_id = fields.Many2one('hr.department', compute="_compute_department_id", store=True, readonly=False) + branch_id = fields.Many2one( + 'hr.department', + string='Branch', + compute='_compute_branch_id', + store=True, + readonly=True + ) + branch_short_name = fields.Char( + string='Branch', + related='branch_id.branch_short_name', + store=True, + readonly=True + ) purpose = fields.Char() category_ids = fields.Many2many('product.category', string='Categories') committe_members = fields.One2many('committe.member', inverse_name='po_id') @@ -187,6 +200,16 @@ class PurchaseOrderCustom(models.Model): for rec in self: rec.department_id = rec.request_id.department_id + @api.depends('request_id.branch_id', 'department_id.branch_name') + def _compute_branch_id(self): + for rec in self: + branch = False + if rec.request_id and rec.request_id.branch_id: + branch = rec.request_id.branch_id + elif rec.department_id and rec.department_id.branch_name: + branch = rec.department_id.branch_name + rec.branch_id = branch + def _recompute_all_department_id(self): for rec in self.sudo().search([('request_id', '!=', False), ('department_id', '=', False)]): rec._compute_department_id() diff --git a/odex25_purchase/purchase_requisition_custom/views/purchase_request.xml b/odex25_purchase/purchase_requisition_custom/views/purchase_request.xml index e177f027e..52c2b8d28 100644 --- a/odex25_purchase/purchase_requisition_custom/views/purchase_request.xml +++ b/odex25_purchase/purchase_requisition_custom/views/purchase_request.xml @@ -67,7 +67,7 @@ - + @@ -136,7 +136,7 @@ - + @@ -153,7 +153,7 @@ - + diff --git a/odex25_purchase/purchase_requisition_custom/views/purchase_requisition_custom.xml b/odex25_purchase/purchase_requisition_custom/views/purchase_requisition_custom.xml index ce7b09505..55fab3a51 100644 --- a/odex25_purchase/purchase_requisition_custom/views/purchase_requisition_custom.xml +++ b/odex25_purchase/purchase_requisition_custom/views/purchase_requisition_custom.xml @@ -99,6 +99,10 @@ + + + + @@ -304,6 +308,7 @@ +