Merge pull request #234 from expsa/zainab_dev_tran

[UPDATE]UPDATE search view
This commit is contained in:
zainab2097 2024-07-17 06:43:47 +03:00 committed by GitHub
commit 34984f9d8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 140 additions and 17 deletions

View File

@ -16,14 +16,35 @@ class Entity(models.Model):
_description = 'Transactions Contacts'
_order = 'name'
def _normalize_arabic_text(self, text):
translation_map = str.maketrans({
# Define a dictionary to replace different forms of characters
'ه': 'ة',
'إ': 'ا', # Replace Alef with Hamza Below with Alef
'أ': 'ا', # Replace Alef with Hamza Above with Alef
'آ': 'ا', # Replace Alef with Madda Above with Alef
'ى': 'ي', # Replace Alef Maqsura with Ya
'ئ': 'ي', # Replace Yeh with Hamza Above with Ya
'ؤ': 'و', # Replace Waw with Hamza Above with Waw
})
return text.translate(translation_map)
@api.model
def _name_search(self, name, args=None, operator='like', limit=100, name_get_uid=None):
args = args or []
domain = []
if name:
domain = ['|', ('name', operator, name), ('code', operator, name)]
print(domain)
return self._search(domain + args, limit=limit, access_rights_uid=name_get_uid)
def search(self, args, offset=0, limit=None, order=None, count=False):
# Normalize the search arguments for 'name' field
new_args = []
for arg in args:
if isinstance(arg, (list, tuple)) and arg[0] == 'name' and arg[1] == 'ilike':
normalized_value = self._normalize_arabic_text(arg[2])
new_args.append('|')
new_args.append(arg)
new_args.append(('name', 'ilike', normalized_value))
else:
new_args.append(arg)
return super(Entity, self).search(new_args, offset=offset, limit=limit, order=order, count=count)
@api.constrains('code')
def _check_code(self):

View File

@ -10,7 +10,37 @@ class IncomingTransaction(models.Model):
_inherit = ['transaction.transaction', 'mail.thread']
_description = 'incoming Transaction'
# due_date = fields.Date(string='Deadline', compute='compute_due_date')
def _normalize_arabic_text(self, text):
translation_map = str.maketrans({
# Define a dictionary to replace different forms of characters
'ه': 'ة',
'إ': 'ا', # Replace Alef with Hamza Below with Alef
'أ': 'ا', # Replace Alef with Hamza Above with Alef
'آ': 'ا', # Replace Alef with Madda Above with Alef
'ى': 'ي', # Replace Alef Maqsura with Ya
'ئ': 'ي',
'ؤ': 'و',
})
return text.translate(translation_map)
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
# Normalize the search arguments for 'name' field
new_args = []
for arg in args:
if isinstance(arg, (list, tuple)) and arg[1] == 'ilike' and arg[0] in ('name', 'subject'):
normalized_value = self._normalize_arabic_text(arg[2])
new_args.append('|')
new_args.append(arg)
new_args.append((arg[0], 'ilike', normalized_value))
else:
new_args.append(arg)
return super(IncomingTransaction, self).search(new_args, offset=offset, limit=limit, order=order, count=count)
# due_date = fields.Date(string='Deadline', compute='compute_due_date')
from_id = fields.Many2one(comodel_name='cm.entity', string='Incoming From (External)')
partner_id = fields.Many2one('res.partner')
outgoing_transaction_id = fields.Many2one('outgoing.transaction', string='Related Outgoing')

View File

@ -29,6 +29,34 @@ class InternalTransaction(models.Model):
project_domain = fields.Many2many('project.project', string='Project Domain')
processing_ids = fields.Many2many(comodel_name='internal.transaction', relation='transaction_internal_rel',
column1='transaction_id', column2='internal_id', string='Process Transactions')
def _normalize_arabic_text(self, text):
translation_map = str.maketrans({
# Define a dictionary to replace different forms of characters
'ه': 'ة',
'إ': 'ا', # Replace Alef with Hamza Below with Alef
'أ': 'ا', # Replace Alef with Hamza Above with Alef
'آ': 'ا', # Replace Alef with Madda Above with Alef
'ى': 'ي', # Replace Alef Maqsura with Ya
'ئ': 'ي',
'ؤ': 'و',
})
return text.translate(translation_map)
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
# Normalize the search arguments for 'name' field
new_args = []
for arg in args:
if isinstance(arg, (list, tuple)) and arg[1] == 'ilike' and arg[0] in ('name', 'subject'):
normalized_value = self._normalize_arabic_text(arg[2])
new_args.append('|')
new_args.append(arg)
new_args.append((arg[0], 'ilike', normalized_value))
else:
new_args.append(arg)
return super(InternalTransaction, self).search(new_args, offset=offset, limit=limit, order=order, count=count)
@api.model
def get_url(self):

View File

@ -38,6 +38,35 @@ class OutgoingTransaction(models.Model):
# processing_ids = fields.Many2many(comodel_name='transaction.transaction', relation='transaction_outgoing_rel',
# column1='transaction_id', column2='outgoing_id', string='Process Transactions')
def _normalize_arabic_text(self, text):
translation_map = str.maketrans({
# Define a dictionary to replace different forms of characters
'ه': 'ة',
'إ': 'ا', # Replace Alef with Hamza Below with Alef
'أ': 'ا', # Replace Alef with Hamza Above with Alef
'آ': 'ا', # Replace Alef with Madda Above with Alef
'ى': 'ي', # Replace Alef Maqsura with Ya
'ئ': 'ي',
'ؤ': 'و',
})
return text.translate(translation_map)
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
# Normalize the search arguments for 'name' field
new_args = []
for arg in args:
if isinstance(arg, (list, tuple)) and arg[1] == 'ilike' and arg[0] in ('name', 'subject'):
normalized_value = self._normalize_arabic_text(arg[2])
new_args.append('|')
new_args.append(arg)
new_args.append((arg[0], 'ilike', normalized_value))
else:
new_args.append(arg)
return super(OutgoingTransaction, self).search(new_args, offset=offset, limit=limit, order=order, count=count)
@api.depends('attachment_rule_ids')
def compute_attachment_num(self):
for r in self:

View File

@ -8,6 +8,8 @@
<field name="model">incoming.transaction</field>
<field name="arch" type="xml">
<search string="incoming transaction">
<field name="subject"/>
<field name="to_ids"/>
<field name="name" string="Transaction" filter_domain="[('name','ilike',self)]"/>
<field name="project_id" string="Project" filter_domain="[('project_id','ilike',self)]"/>
<field name="sale_order_id" string="Proposal" filter_domain="[('sale_order_id','ilike',self)]"/>
@ -15,12 +17,15 @@
filter_domain="[('incoming_number','ilike',self)]"/>
<field name="tran_tag" string="tag" filter_domain="[('tran_tag','ilike',self)]"/>
<field name="is_reade"/>
<field name="subject"/>
<field name="is_favorite"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','!=',False)]"/>
<filter string="State" name="state" domain="[('state', '!=',False)]"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','=',False)]"/>
<filter string="State" name="state" domain="[('state', 'in', ('complete','draft'))]"/>
<filter string="Unread Transaction" name="unread" domain="[('is_reade','=',False)]"/>
<filter string="Favorite" name="favorite" domain="[('is_favorite','=','1')]"/>
<group expand="1" string="Group By">
<filter string="State" name="group_by_state" context="{'group_by':'state'}"/>
<filter string="Subject Type" name="group_by_subject_type" context="{'group_by':'subject_type_id'}"/>
</group>
<!-- <group expand="0" string="Group By">-->
<!-- <filter name="group_manager" string="Manager" domain="[]" context="{'group_by':'parent_id'}"/>-->
<!-- <filter name="group_coach" string="Coach" domain="[]" context="{'group_by':'coach_id'}"/>-->

View File

@ -7,15 +7,20 @@
<field name="model">internal.transaction</field>
<field name="arch" type="xml">
<search string="internal transaction">
<field name="subject"/>
<field name="to_ids"/>
<field name="name" string="Transaction" filter_domain="[('name','ilike',self)]"/>
<field name="tran_tag" string="tag" filter_domain="[('tran_tag','ilike',self)]"/>
<field name="is_reade"/>
<field name="subject"/>
<field name="is_favorite"/>
<filter string="Unread Transaction" name="unread" domain="[('is_reade','=',False)]"/>
<filter string="Favorite" name="favorite" domain="[('is_favorite','=','1')]"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','!=',False)]"/>
<filter string="State" name="state" domain="[('state', '!=',False)]"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','=',False)]"/>
<filter string="State" name="state" domain="[('state', 'in', ('complete','draft'))]"/>
<group expand="1" string="Group By">
<filter string="State" name="group_by_state" context="{'group_by':'state'}"/>
<filter string="Subject Type" name="group_by_subject_type" context="{'group_by':'subject_type_id'}"/>
</group>
<!-- <group expand="0" string="Group By">-->

View File

@ -7,15 +7,20 @@
<field name="model">outgoing.transaction</field>
<field name="arch" type="xml">
<search string="outgoing transaction">
<field name="subject"/>
<field name="to_ids"/>
<field name="name" string="Transaction" filter_domain="[('name','ilike',self)]"/>
<field name="tran_tag" string="tag" filter_domain="[('tran_tag','ilike',self)]"/>
<field name="is_reade"/>
<field name="is_favorite"/>
<field name="subject"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','!=',False)]"/>
<filter string="State" name="state" domain="[('state', '!=',False)]"/>
<filter string="Subject Type" name="subject_type" domain="[('subject_type_id','=',False)]"/>
<filter string="State" name="state" domain="[('state', 'in',('complete','draft'))]"/>
<filter string="Unread Transaction" name="unread" domain="[('is_reade','=',False)]"/>
<filter string="Favorite" name="favorite" domain="[('is_favorite','=','1')]"/>
<group expand="1" string="Group By">
<filter string="State" name="group_by_state" context="{'group_by':'state'}"/>
<filter string="Subject Type" name="group_by_subject_type" context="{'group_by':'subject_type_id'}"/>
</group>
<!-- <group expand="0" string="Group By">-->
<!-- <filter name="group_manager" string="Manager" domain="[]" context="{'group_by':'parent_id'}"/>-->
<!-- <filter name="group_coach" string="Coach" domain="[]" context="{'group_by':'coach_id'}"/>-->