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
This commit is contained in:
parent
394b75da0b
commit
ed295ddb30
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
<field name="department_id" force_save="1"
|
||||
attrs="{'readonly' : ['|',('state' , '!=' , 'draft'),('by_purchase' , '!=' , True)] , 'required' : [('by_purchase' , '=' , True)]}"
|
||||
readonly="1"/>
|
||||
<field name="branch_id" readonly="1"/>
|
||||
<field name="branch_id" readonly="1" context="{'show_branch_short': True}"/>
|
||||
<field name="employee_id" attrs="{'readonly':[('by_purchase' , '=' , False)]}" required="1"
|
||||
options="{'no_create' : True , 'no_edit' : True ,'no_open' : True}"/>
|
||||
<field name="product_category_ids" widget="many2many_tags"/>
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
<field name="date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="branch_id" context="{'show_branch_short': True}"/>
|
||||
<field name="product_category_ids" widget="many2many_tags"/>
|
||||
<field name="state"/>
|
||||
<field name="purchase_state_summary" optional="show"/>
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
<field name="name" string="Request Number"/>
|
||||
<field name="employee_id" string="Employee"/>
|
||||
<field name="department_id" string="Department"/>
|
||||
<field name="branch_id" string="Branch"/>
|
||||
<field name="branch_id" string="Branch" context="{'show_branch_short': True}"/>
|
||||
<field name="purchase_purpose" string="Purpose"/>
|
||||
<field name="partner_id" string="Vendor"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,10 @@
|
|||
<field name="recommendation_order" string="Recommend Order"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='department_id']" position="after">
|
||||
<field name="branch_id" context="{'from_branch_field': True}"/>
|
||||
</xpath>
|
||||
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
|
@ -304,6 +308,7 @@
|
|||
<!--here -->
|
||||
<field name="purchase_cost" invisible="1"/>
|
||||
<field name="department_id" invisible="0"/>
|
||||
<field name="branch_id" readonly="1" context="{'show_branch_short': True}"/>
|
||||
<field name="purchase_request_employee_id"/>
|
||||
<field name="purpose" attrs="{'readonly': [('state','in',['done','cancel'])]}"/>
|
||||
</xpath>
|
||||
|
|
|
|||
Loading…
Reference in New Issue