Merge pull request #432 from expsa/dev_odex25_transactions
Dev odex25 transactions
This commit is contained in:
commit
0d975f6846
|
|
@ -35,7 +35,7 @@ class Transaction(models.Model):
|
|||
|
||||
binary_barcode = fields.Binary(string='Barcode', attachment=True)
|
||||
|
||||
@api.constrains('ean13', 'name', 'transaction_date', 'type')
|
||||
@api.constrains('ean13', 'name', 'transaction_date', 'type','subject')
|
||||
def binary_compute_constraint(self):
|
||||
font_path = os.path.join(os.path.dirname(__file__), 'img', 'amiri-regular.ttf')
|
||||
font_size = 22
|
||||
|
|
@ -43,6 +43,13 @@ 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)
|
||||
|
|
@ -54,16 +61,10 @@ class Transaction(models.Model):
|
|||
|
||||
draw.text(position, text, "black", font=font)
|
||||
|
||||
# Draw text elements
|
||||
# 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.attachment_num) if self.attachment_num else '0')+ "رتبة المعاملة: " , (10, 140), 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.attachment_num) if self.attachment_num else '0'), (120, 140), font)
|
||||
|
||||
draw_text(draw, full_text, (10, 20), font)
|
||||
|
||||
|
||||
|
||||
# Generate barcode
|
||||
barcode = self.env['ir.actions.report'].barcode('Code11', self.name, width=250, height=100, humanreadable=0)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Odex - Communications Management System
|
|||
Managing Communications Transcations flows
|
||||
""",
|
||||
'website': 'http://www.exp-sa.com',
|
||||
'depends': ['base', 'base_odex', 'mail', 'html_text', 'odex_sms'],
|
||||
'depends': ['base', 'base_odex', 'mail','attachment_indexation', 'html_text', 'odex_sms'],
|
||||
'data': [
|
||||
'security/groups.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, api, fields, _
|
||||
|
||||
import base64
|
||||
from odoo.exceptions import ValidationError
|
||||
TRACE_ACTIONS = [
|
||||
('forward', _('Forwarded')),
|
||||
('receive', _('Received')),
|
||||
|
|
@ -80,6 +81,7 @@ class AttachmentRule(models.Model):
|
|||
entity_id = fields.Many2one(comodel_name='cm.entity', string='Unit Responsible', related='employee_id.parent_id',
|
||||
store=True)
|
||||
file_save = fields.Binary('Save File')
|
||||
external_drive_link = fields.Char('External Drive Link')
|
||||
attachment_filename = fields.Char(string="Attachment Filename")
|
||||
incoming_transaction_id = fields.Many2one(comodel_name='incoming.transaction', string='Incoming Transaction')
|
||||
internal_transaction_id = fields.Many2one(comodel_name='internal.transaction', string='Internal Transaction')
|
||||
|
|
@ -87,6 +89,14 @@ class AttachmentRule(models.Model):
|
|||
date = fields.Datetime(string='Date', default=fields.Datetime.now)
|
||||
description = fields.Char(string='Description')
|
||||
|
||||
@api.constrains('file_save')
|
||||
def _check_attachment_size(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:
|
||||
raise ValidationError(_('Attachment %s exceeds the maximum allowed size of 10 MB.') % record.attachment_filename)
|
||||
|
||||
class TransactionTrace(models.Model):
|
||||
_name = 'cm.transaction.trace'
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ 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
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from datetime import datetime
|
||||
from odoo import models, api, fields, _
|
||||
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
class InternalTransaction(models.Model):
|
||||
_name = 'internal.transaction'
|
||||
_inherit = ['transaction.transaction', 'mail.thread']
|
||||
|
|
@ -58,6 +57,12 @@ class InternalTransaction(models.Model):
|
|||
new_args.append(arg)
|
||||
return super(InternalTransaction, self).search(new_args, offset=offset, limit=limit, order=order, count=count)
|
||||
|
||||
def unlink(self):
|
||||
for record in self:
|
||||
if record.state == 'send':
|
||||
raise ValidationError(_('Cannot delete a sent transaction!'))
|
||||
return super(InternalTransaction, self).unlink()
|
||||
|
||||
@api.model
|
||||
def get_url(self):
|
||||
url = u''
|
||||
|
|
|
|||
|
|
@ -92,6 +92,12 @@ class OutgoingTransaction(models.Model):
|
|||
####################################################
|
||||
#
|
||||
#
|
||||
def unlink(self):
|
||||
for record in self:
|
||||
if record.state == 'send':
|
||||
raise ValidationError(_('Cannot delete a sent transaction!'))
|
||||
return super(InternalTransaction, self).unlink()
|
||||
|
||||
def action_draft(self):
|
||||
for record in self:
|
||||
"""her i need to review code for to_ids"""
|
||||
|
|
|
|||
|
|
@ -171,5 +171,46 @@
|
|||
name="exp_transaction_documents.transaction_outgoing_receive_report"
|
||||
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>-->
|
||||
<!--<!– <field name="page_height">140</field> <!– Custom height –>–>-->
|
||||
<!--<!– <field name="page_width">210</field> <!– A4 width –>–>-->
|
||||
<!-- <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>-->
|
||||
<report
|
||||
id="action_report_internal_transaction"
|
||||
model="internal.transaction"
|
||||
string="Print Transaction"
|
||||
report_type="qweb-pdf"
|
||||
name="exp_transaction_documents.report_internal_transaction"
|
||||
file="exp_transaction_documents.report_internal_transaction"
|
||||
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">
|
||||
<h2>تفاصيل المعاملة</h2>
|
||||
<p> رقم المعاملة: <t t-esc="doc.name"/></p>
|
||||
<p>الموضوع: <t t-esc="doc.subject"/></p>
|
||||
<p>التاريخ: <t t-esc="doc.transaction_date"/></p>
|
||||
<!-- Add more details as needed -->
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<!-- end -->
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@
|
|||
<field name="unit_location" attrs="{'invisible': [('type', 'not in', ['unit'])]}"/>
|
||||
<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'])]}"/>
|
||||
<field name="person_id" attrs="{'invisible':[('type','not in',['employee'])]}"/>
|
||||
|
|
|
|||
|
|
@ -124,7 +124,8 @@
|
|||
<field name="entity_id" readonly="True"/>
|
||||
<field name="date" readonly="True"/>
|
||||
<field name="description" required="False"/>
|
||||
<field name="file_save" filename="attachment_filename"/>
|
||||
<field name="file_save" filename="attachment_filename"/>
|
||||
<field name="external_drive_link" widget="url"/>
|
||||
<field name="attachment_filename" invisible="True"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
|
|||
|
|
@ -7,9 +7,31 @@
|
|||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
<field name="model_id" ref="model_employee_leave" />
|
||||
<field name="model_id" ref="model_employee_leave"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.action_expired()</field>
|
||||
</record>
|
||||
<record id="email_template_delegation_accepted" model="mail.template">
|
||||
<field name="name">Delegation Accepted Notification</field>
|
||||
<field name="model_id" ref="model_employee_leave"/>
|
||||
<field name="subject">Delegation Accepted</field>
|
||||
<field name="email_from">${(user.email or user.company_id.email) | safe}</field>
|
||||
<field name="email_to">${object.employee_id.email}</field>
|
||||
<field name="body_html">
|
||||
<![CDATA[
|
||||
<p>Hello ${object.employee_id.name},</p>
|
||||
<p>Your delegation ${object.name} has been accepted.</p>
|
||||
<p>Thank you.</p>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="email_template_delegation_notification2" model="mail.template">
|
||||
<field name="name">Delegation Users Notification</field>
|
||||
<field name="model_id" ref="model_employee_leave"/>
|
||||
<field name="subject">Delegation Notification</field>
|
||||
<field name="email_from">${(user.email or user.company_id.email) | safe}</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
|
|||
|
|
@ -48,16 +48,46 @@ class Leave(models.Model):
|
|||
# Business methods
|
||||
####################################################
|
||||
def action_request(self):
|
||||
template_id = self.env.ref('exp_transaction_leave.email_template_delegation_notification2',False)
|
||||
|
||||
for rec in self:
|
||||
rec.state = 'request'
|
||||
rec.state = 'request'
|
||||
if rec.alternative_employee_ids:
|
||||
for lin in rec.alternative_employee_ids:
|
||||
emails = lin.employee_id.email
|
||||
if emails:
|
||||
body_html = f"""
|
||||
<p>Hello {lin.employee_id.name},</p>
|
||||
<p>You have been delegated a task.</p>
|
||||
<p>Thank you.</p>
|
||||
"""
|
||||
email_template = template_id.write(
|
||||
{'email_to': emails,'body_html': body_html,})
|
||||
template_id.with_context(lang=self.env.user.lang).send_mail(rec.id, force_send=True, raise_exception=False)
|
||||
if rec.alternative_manager_ids:
|
||||
for lin in rec.alternative_employee_ids:
|
||||
emails = lin.employee_id.email
|
||||
if emails:
|
||||
body_html = f"""
|
||||
<p>Hello {lin.employee_id.name},</p>
|
||||
<p>You have been delegated a task.</p>
|
||||
<p>Thank you.</p>
|
||||
"""
|
||||
email_template = template_id.write(
|
||||
{'email_to': emails,'body_html': body_html,})
|
||||
template_id.with_context(lang=self.env.user.lang).send_mail(rec.id, force_send=True, raise_exception=False)
|
||||
|
||||
|
||||
|
||||
def action_refuse(self):
|
||||
for rec in self:
|
||||
rec.state = 'refuse'
|
||||
|
||||
def action_approve(self):
|
||||
template_id = self.env.ref('exp_transaction_leave.email_template_delegation_accepted').id
|
||||
for rec in self:
|
||||
rec.state = 'approve'
|
||||
self.env['mail.template'].browse(template_id).send_mail(rec.id, force_send=True)
|
||||
|
||||
def action_expired(self):
|
||||
date_now = date.today()
|
||||
|
|
|
|||
Loading…
Reference in New Issue