feat: add branch field to purchase.request
- Add branch_id computed field to purchase.request model - Auto-populate branch from employee department - Add branch field to form view (readonly) - Add branch field to tree and search views - Add branch group by filter in search view - Add Arabic translation for branch field Synced with latest dev_odex25_purchase on Thu Nov 13 10:46:18 +03 2025
This commit is contained in:
parent
68a9c946da
commit
3e0d541ba4
|
|
@ -1946,6 +1946,11 @@ msgstr "أوامر الشراء المبدئية"
|
||||||
msgid "Request id"
|
msgid "Request id"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: purchase_requisition_custom
|
||||||
|
#: model:ir.model.fields,field_description:purchase_requisition_custom.field_purchase_request__branch_id
|
||||||
|
msgid "Branch"
|
||||||
|
msgstr "الفرع"
|
||||||
|
|
||||||
#. module: purchase_requisition_custom
|
#. module: purchase_requisition_custom
|
||||||
#: model:ir.model.fields,field_description:purchase_requisition_custom.field_purchase_request__by_purchase
|
#: model:ir.model.fields,field_description:purchase_requisition_custom.field_purchase_request__by_purchase
|
||||||
msgid "Requested by Purchase"
|
msgid "Requested by Purchase"
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ class PurchaseRequest(models.Model):
|
||||||
name = fields.Char(string='Name', copy=False, default=lambda self: '/')
|
name = fields.Char(string='Name', copy=False, default=lambda self: '/')
|
||||||
employee_id = fields.Many2one(comodel_name='hr.employee', string='Employee', default=lambda s: s._default_emp().id)
|
employee_id = fields.Many2one(comodel_name='hr.employee', string='Employee', default=lambda s: s._default_emp().id)
|
||||||
department_id = fields.Many2one('hr.department', 'Department')
|
department_id = fields.Many2one('hr.department', 'Department')
|
||||||
|
branch_id = fields.Many2one('hr.department', string='Branch', compute='_compute_branch_id', store=True, readonly=True)
|
||||||
line_ids = fields.One2many(comodel_name='purchase.request.line', inverse_name='request_id', copy=True)
|
line_ids = fields.One2many(comodel_name='purchase.request.line', inverse_name='request_id', copy=True)
|
||||||
date = fields.Date(string='Date', default=fields.Date.context_today, copy=False)
|
date = fields.Date(string='Date', default=fields.Date.context_today, copy=False)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
|
|
@ -91,6 +92,15 @@ class PurchaseRequest(models.Model):
|
||||||
)
|
)
|
||||||
has_approve_reject_permission = fields.Boolean(compute='_compute_permissions')
|
has_approve_reject_permission = fields.Boolean(compute='_compute_permissions')
|
||||||
|
|
||||||
|
@api.depends('employee_id.department_id.branch_name', 'department_id.branch_name')
|
||||||
|
def _compute_branch_id(self):
|
||||||
|
for rec in self:
|
||||||
|
branch = False
|
||||||
|
if rec.employee_id and rec.employee_id.department_id:
|
||||||
|
branch = rec.employee_id.department_id.branch_name
|
||||||
|
elif rec.department_id:
|
||||||
|
branch = rec.department_id.branch_name
|
||||||
|
rec.branch_id = branch
|
||||||
|
|
||||||
def _compute_permissions(self):
|
def _compute_permissions(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
@ -409,9 +419,3 @@ class Employee(models.Model):
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
return super(Employee, self).name_get()
|
return super(Employee, self).name_get()
|
||||||
|
|
||||||
|
|
||||||
class ProductTempInherit(models.Model):
|
|
||||||
_inherit = 'product.template'
|
|
||||||
|
|
||||||
asset_ok = fields.Boolean(string="Asset Expensed")
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
<field name="department_id" force_save="1"
|
<field name="department_id" force_save="1"
|
||||||
attrs="{'readonly' : ['|',('state' , '!=' , 'draft'),('by_purchase' , '!=' , True)] , 'required' : [('by_purchase' , '=' , True)]}"
|
attrs="{'readonly' : ['|',('state' , '!=' , 'draft'),('by_purchase' , '!=' , True)] , 'required' : [('by_purchase' , '=' , True)]}"
|
||||||
readonly="1"/>
|
readonly="1"/>
|
||||||
|
<field name="branch_id" readonly="1"/>
|
||||||
<field name="employee_id" attrs="{'readonly':[('by_purchase' , '=' , False)]}" required="1"
|
<field name="employee_id" attrs="{'readonly':[('by_purchase' , '=' , False)]}" required="1"
|
||||||
options="{'no_create' : True , 'no_edit' : True ,'no_open' : True}"/>
|
options="{'no_create' : True , 'no_edit' : True ,'no_open' : True}"/>
|
||||||
<field name="product_category_ids" widget="many2many_tags"/>
|
<field name="product_category_ids" widget="many2many_tags"/>
|
||||||
|
|
@ -95,7 +96,7 @@
|
||||||
<field name="line_ids" attrs="{'readonly':[('state' , '!=' , 'draft')]}">
|
<field name="line_ids" attrs="{'readonly':[('state' , '!=' , 'draft')]}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="product_id"
|
<field name="product_id"
|
||||||
domain="['|', ('purchase_ok', '=', True), ('asset_ok', '=', True)]"
|
domain="[('purchase_ok', '=', True)]"
|
||||||
options="{'no_create' : True , 'no_edit' : True ,'no_open' : True}"
|
options="{'no_create' : True , 'no_edit' : True ,'no_open' : True}"
|
||||||
optional="show"
|
optional="show"
|
||||||
required="1"/>
|
required="1"/>
|
||||||
|
|
@ -135,6 +136,7 @@
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="employee_id"/>
|
<field name="employee_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
|
<field name="branch_id"/>
|
||||||
<field name="product_category_ids" widget="many2many_tags"/>
|
<field name="product_category_ids" widget="many2many_tags"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="purchase_state_summary" optional="show"/>
|
<field name="purchase_state_summary" optional="show"/>
|
||||||
|
|
@ -148,27 +150,19 @@
|
||||||
<field name="model">purchase.request</field>
|
<field name="model">purchase.request</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Purchase Request">
|
<search string="Purchase Request">
|
||||||
<!-- حقول البحث الأساسية -->
|
|
||||||
<field name="name" string="Request Number"/>
|
<field name="name" string="Request Number"/>
|
||||||
<field name="employee_id" string="Employee"/>
|
<field name="employee_id" string="Employee"/>
|
||||||
<field name="department_id" string="Department"/>
|
<field name="department_id" string="Department"/>
|
||||||
|
<field name="branch_id" string="Branch"/>
|
||||||
<field name="purchase_purpose" string="Purpose"/>
|
<field name="purchase_purpose" string="Purpose"/>
|
||||||
<field name="partner_id" string="Vendor"/>
|
<field name="partner_id" string="Vendor"/>
|
||||||
|
|
||||||
<!-- البحث بالمنتجات - الهدف الأساسي -->
|
|
||||||
<field name="line_ids" string="Products"
|
<field name="line_ids" string="Products"
|
||||||
filter_domain="[('line_ids.product_id.name', 'ilike', self)]"/>
|
filter_domain="[('line_ids.product_id.name', 'ilike', self)]"/>
|
||||||
|
|
||||||
<!-- البحث بفئات المنتجات -->
|
|
||||||
<field name="product_category_ids" string="Product Categories"/>
|
<field name="product_category_ids" string="Product Categories"/>
|
||||||
|
|
||||||
<!-- البحث بالتاريخ -->
|
|
||||||
<field name="date" string="Request Date"/>
|
<field name="date" string="Request Date"/>
|
||||||
|
|
||||||
<!-- البحث بالملاحظات -->
|
|
||||||
<field name="note" string="Notes"/>
|
<field name="note" string="Notes"/>
|
||||||
|
|
||||||
<!-- فلاتر سريعة حسب الحالة -->
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<filter string="Draft" name="draft" domain="[('state','=','draft')]"/>
|
<filter string="Draft" name="draft" domain="[('state','=','draft')]"/>
|
||||||
<filter string="Direct Manager Approval" name="direct_manager" domain="[('state','=','direct_manager')]"/>
|
<filter string="Direct Manager Approval" name="direct_manager" domain="[('state','=','direct_manager')]"/>
|
||||||
|
|
@ -178,7 +172,6 @@
|
||||||
<filter string="Refused" name="refuse" domain="[('state','=','refuse')]"/>
|
<filter string="Refused" name="refuse" domain="[('state','=','refuse')]"/>
|
||||||
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<!-- فلاتر مفيدة للعمل -->
|
|
||||||
<filter string="My Requests" name="my_requests"
|
<filter string="My Requests" name="my_requests"
|
||||||
domain="[('employee_id.user_id','=',uid)]"/>
|
domain="[('employee_id.user_id','=',uid)]"/>
|
||||||
<filter string="My Department" name="my_department"
|
<filter string="My Department" name="my_department"
|
||||||
|
|
@ -189,40 +182,26 @@
|
||||||
domain="[('state','in',['waiting'])]"/>
|
domain="[('state','in',['waiting'])]"/>
|
||||||
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<!-- فلاتر حسب نوع الطلب -->
|
|
||||||
<filter string="Project Requests" name="project_type"
|
<filter string="Project Requests" name="project_type"
|
||||||
domain="[('type','=','project')]"/>
|
domain="[('type','=','project')]"/>
|
||||||
<filter string="Operational Requests" name="operational_type"
|
<filter string="Operational Requests" name="operational_type"
|
||||||
domain="[('type','=','operational')]"/>
|
domain="[('type','=','operational')]"/>
|
||||||
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<!-- فلاتر حسب وجود المورد -->
|
|
||||||
<filter string="With Vendor" name="with_vendor"
|
<filter string="With Vendor" name="with_vendor"
|
||||||
domain="[('partner_id','!=',False)]"/>
|
domain="[('partner_id','!=',False)]"/>
|
||||||
<filter string="Without Vendor" name="without_vendor"
|
<filter string="Without Vendor" name="without_vendor"
|
||||||
domain="[('partner_id','=',False)]"/>
|
domain="[('partner_id','=',False)]"/>
|
||||||
|
|
||||||
<separator/>
|
|
||||||
<!-- فلاتر زمنية -->
|
|
||||||
<filter string="Today" name="today"
|
|
||||||
domain="[('date','=',context_today())]"/>
|
|
||||||
<filter string="This Week" name="this_week"
|
|
||||||
domain="[('date','>=',context_today() - datetime.timedelta(days=7))]"/>
|
|
||||||
<filter string="This Month" name="this_month"
|
|
||||||
domain="[('date','>=',context_today() - datetime.timedelta(days=30))]"/>
|
|
||||||
|
|
||||||
<!-- تجميع منطقي -->
|
|
||||||
<group expand="0" string="Group By">
|
<group expand="0" string="Group By">
|
||||||
<filter string="State" name="group_state" context="{'group_by':'state'}"/>
|
<filter string="State" name="group_state" context="{'group_by':'state'}"/>
|
||||||
<filter string="Employee" name="group_employee" context="{'group_by':'employee_id'}"/>
|
<filter string="Employee" name="group_employee" context="{'group_by':'employee_id'}"/>
|
||||||
<filter string="Department" name="group_department" context="{'group_by':'department_id'}"/>
|
<filter string="Department" name="group_department" context="{'group_by':'department_id'}"/>
|
||||||
|
<filter string="Branch" name="group_branch" context="{'group_by':'branch_id'}"/>
|
||||||
<filter string="Vendor" name="group_vendor" context="{'group_by':'partner_id'}"/>
|
<filter string="Vendor" name="group_vendor" context="{'group_by':'partner_id'}"/>
|
||||||
<filter string="Request Type" name="group_type" context="{'group_by':'type'}"/>
|
<filter string="Request Type" name="group_type" context="{'group_by':'type'}"/>
|
||||||
<filter string="Product Categories" name="group_categories" context="{'group_by':'product_category_ids'}"/>
|
<filter string="Product Categories" name="group_categories" context="{'group_by':'product_category_ids'}"/>
|
||||||
<separator/>
|
|
||||||
<filter string="Request Date" name="group_date" context="{'group_by':'date'}"/>
|
|
||||||
<filter string="Month" name="group_month" context="{'group_by':'date:month'}"/>
|
|
||||||
<filter string="Year" name="group_year" context="{'group_by':'date:year'}"/>
|
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue