Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4240 module pabi email enhance edit form #1846

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pabi_email_enhance/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
22 changes: 22 additions & 0 deletions pabi_email_enhance/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
{
"name": "NSTDA :: PABI2 - Email Enhance",
"summary": "",
"version": "1.0",
"category": "Human Resources",
"description": """

""",
"website": "-----",
"author": "Pabi 2",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"pabi_hr_expense",
],
"data": [
"security/ir.model.access.csv",
"views/hr_expense_view.xml",
],
}
4 changes: 4 additions & 0 deletions pabi_email_enhance/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from . import hr_expense

63 changes: 63 additions & 0 deletions pabi_email_enhance/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openpyxl.worksheet import related


class HRExpense(models.Model):
_inherit = 'hr.expense.expense'

message_mail = fields.One2many(
'hr.email.enhance',
'expense_id',
string='Message',
readonly=True,
)

class PABIEmailEnhance(models.Model):
_name = 'hr.email.enhance'

expense_id = fields.Many2one(
'hr.expense.expense',
string='Document'
)
mail_id = fields.Many2one(
'mail.mail',
string='Email',
)
subject = fields.Char(
string='Subject',
related='mail_id.mail_message_id.subject'
)
body_html = fields.Text(
string='Body',
related='mail_id.body_html',
)
recipient_ids = fields.Many2many(
'res.partner',
string='To (Partners)',
related='mail_id.recipient_ids'
)
state = fields.Selection([
('outgoing', 'Outgoing'),
('sent', 'Sent'),
('received', 'Received'),
('exception', 'Delivery Failed'),
('cancel', 'Cancelled'),
], 'Status',
readonly=True,
copy=False,
related='mail_id.state',
)


class mail_mail(models.Model):
_inherit = 'mail.mail'

def create(self, cr, uid, values, context=None):
values['model'] = context.get('active_model')
values['res_id'] = context.get('active_id')
res = super(mail_mail, self).create(cr, uid, values, context=context)
self.pool.get('hr.email.enhance').create(cr, uid,{'mail_id': res , 'expense_id': context.get('active_id')})
return res


4 changes: 4 additions & 0 deletions pabi_email_enhance/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

access_hr_email_enhance_user,hr_email_enhance_user,model_hr_email_enhance,base.group_user,1,1,1,1

100 changes: 100 additions & 0 deletions pabi_email_enhance/views/hr_expense_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>

<openerp>
<data>

<record id="view_email_enhance_form" model="ir.ui.view">
<field name="name">view.email.enhance.form</field>
<field name="model">mail.mail</field>
<field name="arch" type="xml">
<form string="Email message">
<header>
<button name="send" string="Send Now" type="object" states='outgoing' class="oe_highlight" context="{'expense_id' : active_id}"/>
<button name="mark_outgoing" string="Retry" type="object" states='exception,cancel'/>
<button name="cancel" string="Cancel" type="object" states='outgoing'/>
<field name="state" widget="statusbar" statusbar_visible="outgoing,sent,received,exception,cancel"/>
</header>
<sheet>
<field name="mail_message_id" required="0" invisible="1"/>
<div style="vertical-align: top;">
by <field name="author_id" class="oe_inline" string="User" readonly="1"/> on <field name="date" readonly="1" class="oe_inline"/>
<button name="%(mail.action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
context="{'default_composition_mode':'reply', 'default_parent_id': mail_message_id}" states='received,sent,exception,cancel'/>
</div>
<group>
<field name="email_from" readonly='1'/>
<field name="recipient_ids" widget="many2many_kanban" string="To Employee" domain="[('employee','=',True)]"/>
<field name="email_to" string="To (External)"/>
<field name="email_cc"/>
</group>
<label for="subject" class="oe_edit_only"/>
<h2><field name="subject"/></h2>
<notebook>
<page string="Body">
<field name="body_html"/>
</page>
<page string="Attachments">
<field name="attachment_ids"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="action_view_mail_mail" model="ir.actions.act_window">
<field name="name">Email Enhance</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mail.mail</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_email_enhance_form"/>
</record>

<record id="view_email_enhance_line_form" model="ir.ui.view">
<field name="name">email.enhance.line.form</field>
<field name="model">hr.email.enhance</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form string="Email Enhance">
<group>
<group>
<field name="mail_id"/>
<field name="subject"/>
<field name="body_html"/>
<field name="expense_id"/>
</group>
<group>
<field name="state"/>
</group>
</group>
</form>
</field>
</record>

<record id="view_expenses_form" model="ir.ui.view">
<field name="name">hr.expense.form</field>
<field name="model">hr.expense.expense</field>
<field name="inherit_id" ref="hr_expense_advance_clearing.view_expenses_form_advance"/>
<field name="priority" eval="10"/>
<field name="arch" type="xml">
<xpath expr="//page[last()]" position="after">
<page name="messageing" string="Messaging">
<button name="%(pabi_email_enhance.action_view_mail_mail)d" string="Send Mail" type="action" class="oe_highlight"/>
<field name="message_mail">
<tree>
<field name="subject"/>
<field name="recipient_ids"/>
<field name="state"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

<!-- <menuitem name="Emails" id="menu_mail_mail" parent="pabi_apps_config.menu_pabi2_config_unused_menu" action="action_view_mail_mail" sequence="500" /> -->

</data>
</openerp>