Merge pull request #460 from expsa/dev_odex25_transactions

Dev odex25 transactions
This commit is contained in:
zainab2097 2024-08-01 11:18:18 +03:00 committed by GitHub
commit 9ee1160cec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 47 additions and 37 deletions

View File

@ -43,13 +43,6 @@ class Transaction(models.Model):
img = Image.new("RGBA", (500, 420), "white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(font_path, font_size)
transaction_text = " رقم المعاملة : " + (self.name or '')
subject_text = " موضوع : " + (self.subject or '')
h_date =" تاريخ المعاملة الهجري : " +(str(self.transaction_date) if self.transaction_date else '')
datem = " تاريخ المعاملة الميلادي : "+ (str(self.transaction_date) if self.transaction_date else '')
rank = " رتبة المعاملة : "+(str(self.attachment_num) if self.attachment_num else '0')
full_text = transaction_text + "\n" + subject_text.center(100)+"\n"+h_date+'\n'+datem+'\n'+rank.center(60)
def draw_text(draw, text, position, font, alignment="left"):
text_size = draw.textsize(text, font=font)
@ -61,9 +54,10 @@ class Transaction(models.Model):
draw.text(position, text, "black", font=font)
draw_text(draw, full_text, (10, 20), font)
draw_text(draw, " رقم المعاملة : " + (self.name or ''), (10, 20), font)
draw_text(draw, " تاريخ المعاملة الهجري : " + (self.transaction_date_hijri or '').replace('-', '/'), (10, 60), font)
draw_text(draw, " تاريخ المعاملة الميلادي : " + (str(self.transaction_date) if self.transaction_date else '').replace('-', '/'), (10, 100), font)
draw_text(draw, " الموضوع : " + (str(self.subject) if self.subject else ''), (120, 140), font)
# Generate barcode

View File

@ -96,7 +96,17 @@ class AttachmentRule(models.Model):
if record.file_save:
file_size = len(base64.b64decode(record.file_save))
if file_size > max_size:
raise ValidationError(_('Attachment %s exceeds the maximum allowed size of 10 MB.') % record.attachment_filename)
raise ValidationError(_('Attachment %s exceeds the maximum allowed size of 4 MB.') % record.attachment_filename)
@api.onchange('file_save')
def _onchange_file_save(self):
max_size = 4 * 1024 * 1024 # 4 MB
for record in self:
if record.file_save:
file_size = len(base64.b64decode(record.file_save))
if file_size > max_size:
record.file_save = False
raise UserError(_('Attachment %s exceeds the maximum allowed size of 4 MB.') % record.attachment_filename)
class TransactionTrace(models.Model):
_name = 'cm.transaction.trace'

View File

@ -16,8 +16,7 @@ class Entity(models.Model):
_description = 'Transactions Contacts'
_order = 'name'
employee_id = fields.Char(string='Delivery Employee')
company_name = fields.Char('Delivery Company')
def _normalize_arabic_text(self, text):
translation_map = str.maketrans({
# Define a dictionary to replace different forms of characters

View File

@ -59,7 +59,7 @@ class InternalTransaction(models.Model):
def unlink(self):
for record in self:
if record.state == 'send':
if record.state != 'draft':
raise ValidationError(_('Cannot delete a sent transaction!'))
return super(InternalTransaction, self).unlink()
@ -239,7 +239,7 @@ class InternalTransaction(models.Model):
return super(InternalTransaction, self).create(vals)
#
# def unlink(self):
# def (self):
# if self.env.uid != 1:
# raise ValidationError(_("You can not delete transaction....."))
# return super(InternalTransaction, self).unlink()

View File

@ -17,6 +17,8 @@ class OutgoingTransaction(models.Model):
incoming_transaction_id = fields.Many2one('incoming.transaction', string='Related Incoming')
to_ids = fields.Many2many(comodel_name='cm.entity', relation='outgoing_entity_rel', column1='outgoing_id'
, column2='entity_id', string='Send To')
company_name = fields.Many2one('res.partner',string='Delivery Company')
tran_tag = fields.Many2many(comodel_name='transaction.tag', string='Tags')
tran_tag_unit = fields.Many2many(comodel_name='transaction.tag', string='Business unit',
relation='outgoing_tag_rel',
@ -94,7 +96,7 @@ class OutgoingTransaction(models.Model):
#
def unlink(self):
for record in self:
if record.state == 'send':
if record.state != 'draft':
raise ValidationError(_('Cannot delete a sent transaction!'))
return super(InternalTransaction, self).unlink()

View File

@ -172,20 +172,22 @@
paperformat="paperformat_transaction_receive_report"
menu="True"/>
<!-- add new report -->
<!-- <record id="paperformat_internal_transaction_card" model="report.paperformat">-->
<!-- <field name="name">Internal Transaction Card</field>-->
<!-- <field name="default" eval="True"/>-->
<!-- <field name="format">A4</field>-->
<!--&lt;!&ndash; <field name="page_height">140</field> &lt;!&ndash; Custom height &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <field name="page_width">210</field> &lt;!&ndash; A4 width &ndash;&gt;&ndash;&gt;-->
<!-- <field name="dpi">90</field>-->
<!-- <field name="margin_top">10</field>-->
<!-- <field name="margin_bottom">10</field>-->
<!-- <field name="margin_left">10</field>-->
<!-- <field name="margin_right">10</field>-->
<!-- </record>-->
<!-- Used to change the format of pdf. -->
<record id="paperformat_card" model="report.paperformat">
<field name="name">Custom Paper</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">95</field>
<field name="page_width">60</field>
<field name="orientation">Landscape</field>
<field name="margin_top">5.00</field>
<field name="margin_bottom">5.00</field>
<field name="margin_left">5.0</field>
<field name="margin_right">5.0</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">35</field>
<field name="dpi">125</field>
</record>
<report
id="action_report_internal_transaction"
model="internal.transaction"
@ -193,17 +195,22 @@
report_type="qweb-pdf"
name="exp_transaction_documents.report_internal_transaction"
file="exp_transaction_documents.report_internal_transaction"
paperformat="paperformat_card"
menu="True"/>
<template id="report_internal_transaction">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.basic_layout">
<div dir="rtl" class="page text-center">
<div dir="rtl" style="border: 2px solid black; padding: 20px; margin-bottom: 50px; height: 90%;"
<h2>تفاصيل المعاملة</h2>
<p> رقم المعاملة: <t t-esc="doc.name"/></p>
<p>الموضوع: <t t-esc="doc.subject"/></p>
<p>التاريخ: <t t-esc="doc.transaction_date"/></p>
<p>
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 600, 100)"
style="width:250px;height:40px;margin-top:5px;"/>
</p>
<!-- Add more details as needed -->
</div>
</t>

View File

@ -49,11 +49,7 @@
<field name="email"
attrs="{'invisible': [('type','not in',['external'])]}"/>
<field name="employee_id"
attrs="{'invisible': [('type','not in',['external'])]}"/>
<field name="company_name"
attrs="{'invisible': [('type','not in',['external'])]}"/>
<field name="sketch_attachment_id" widget="many2one_binary"
attrs="{'invisible': [('type', 'not in', ['unit'])]}"/>

View File

@ -9,6 +9,7 @@
<search string="outgoing transaction">
<field name="subject"/>
<field name="to_ids"/>
<field name="company_name"/>
<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"/>
@ -43,6 +44,7 @@
<field name="subject"/>
<field name="subject_type_id"/>
<field name="to_ids" widget="many2many_tags"/>
<field name="company_name"/>
<field name="is_reade" optional="hide"/>
<field name="due_date" optional="show"/>
<field name="send_date" optional="show"/>

View File

@ -51,7 +51,7 @@
attrs="{'required':True,'readonly':[('state','not in', ['draft'])]}"
options="{'no_create':True}"/>
<field name="current_is_receive_manger" invisible="1"/>
<field name="add_rank" attrs="{'readonly': [('current_is_receive_manger','!=',True)]}"/>
<field name="add_rank" invisible='1'/>
<field name="due_date"/>
<field name="signature" widget="image"/>
</group>