[REMOVE]REMOVE pych

This commit is contained in:
zainab8585 2024-07-17 09:33:40 +02:00
commit 703b8e43ae
21 changed files with 271 additions and 19 deletions

View File

@ -0,0 +1,128 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/

View File

@ -7,3 +7,4 @@ from . import internal_transaction
from . import outgoing_transaction
from . import incoming_transaction
from . import tools
#

View File

@ -16,15 +16,36 @@ class Entity(models.Model):
_description = 'Transactions Contacts'
_order = 'name'
@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 _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)
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):
count = self.search_count([('code', '=', self.code), ('id', '!=', self.id)])

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'}"/>-->