Ivan Yelizariev
10 years ago
commit
ade5442f0d
5 changed files with 272 additions and 0 deletions
-
1__init__.py
-
28__openerp__.py
-
210data.xml
-
13models.py
-
20views.xml
@ -0,0 +1 @@ |
|||||
|
import models |
@ -0,0 +1,28 @@ |
|||||
|
{ |
||||
|
'name' : 'Custom mail wall', |
||||
|
'version' : '1.0.0', |
||||
|
'author' : 'Ivan Yelizariev', |
||||
|
'category' : 'Custom', |
||||
|
'website' : 'https://it-projects.info', |
||||
|
'description': """ |
||||
|
|
||||
|
Tested on Odoo 8.0 ab7b5d7732a7c222a0aea45bd173742acd47242d |
||||
|
""", |
||||
|
'depends' : ['gamification', |
||||
|
'gamification_extra', |
||||
|
'hr', |
||||
|
'sale', |
||||
|
'sales_team', |
||||
|
'crm', |
||||
|
'calendar', |
||||
|
'project', |
||||
|
'mail_wall_widgets', |
||||
|
'sale_mediation_custom', |
||||
|
'access_custom', |
||||
|
], |
||||
|
'data':[ |
||||
|
'views.xml', |
||||
|
'data.xml', |
||||
|
], |
||||
|
'installable': True, |
||||
|
} |
@ -0,0 +1,210 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="goal_average_payment_time" model="gamification.goal.definition"> |
||||
|
<field name="name">Average payment time</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="False"/> |
||||
|
<field name="suffix">days</field> |
||||
|
<field name="computation_mode">avg</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="model_id" ref="sale.model_sale_order"/> |
||||
|
<field name="field_id" ref="sale_mediation_custom.field_sale_order_invoice_deal_time"/> |
||||
|
<field name="field_date_id" ref="sale.field_sale_order_date_order"/> |
||||
|
<field name="condition">lower</field> |
||||
|
<field name="domain">[('user_id','=', user.id),('state','in', ['done'])]</field> |
||||
|
</record> |
||||
|
<record id="goal_average_deal_time" model="gamification.goal.definition"> |
||||
|
<field name="name">Average deal time</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="False"/> |
||||
|
<field name="suffix">days</field> |
||||
|
<field name="computation_mode">avg</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="model_id" ref="crm.model_crm_lead"/> |
||||
|
<field name="field_id" ref="sale_mediation_custom.field_crm_lead_deal_time"/> |
||||
|
<field name="field_date_id" ref="crm.field_crm_lead_create_date"/> |
||||
|
<field name="condition">lower</field> |
||||
|
<field name="domain">[('user_id','=', user.id), ('sales_funnel_type', 'in', ['won']), ('date_closed', '!=', False)]</field> |
||||
|
</record> |
||||
|
<record id="goal_oldest_lead" model="gamification.goal.definition"> |
||||
|
<field name="name">Oldest lead</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="False"/> |
||||
|
<field name="suffix">days</field> |
||||
|
<field name="computation_mode">max</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="condition">lower</field> |
||||
|
<field name="domain">[('user_id','=', user.id), ('sales_funnel_type', '=', 'lead')]</field> |
||||
|
<field name="model_id" ref="crm.model_crm_lead"/> |
||||
|
<field name="field_id" ref="sale_mediation_custom.field_crm_lead_deal_time"/> |
||||
|
</record> |
||||
|
<record id="goal_oldest_opp" model="gamification.goal.definition"> |
||||
|
<field name="name">Oldest Opportunity</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="False"/> |
||||
|
<field name="suffix">days</field> |
||||
|
<field name="computation_mode">max</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="condition">lower</field> |
||||
|
<field name="domain">[('user_id','=', user.id), '|', ('sales_funnel_type', '=', 'quotation'),('sales_funnel_type', '=', 'negotiation')]</field> |
||||
|
<field name="model_id" ref="crm.model_crm_lead"/> |
||||
|
<field name="field_id" ref="sale_mediation_custom.field_crm_lead_deal_time"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="goal_personal_comission" model="gamification.goal.definition"> |
||||
|
<field name="name">Personal comission</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="True"/> |
||||
|
<field name="computation_mode">python</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="condition">higher</field> |
||||
|
<field name="domain">[('state','!=','cancel'),('user_id','=',user.id),('type','=','out_invoice')]</field><!-- duplicated at compute_code--> |
||||
|
<field name="model_id" ref="account.model_account_invoice_report"/> |
||||
|
<field name="field_id" ref="account.field_account_invoice_report_price_total"/> |
||||
|
<field name="field_date_id" eval="ref('account.field_account_invoice_report_date')" /> |
||||
|
<field name="compute_code"> |
||||
|
personal_comission = object.user_id.employee_ids and object.user_id.employee_ids[0].personal_comission or 0.0 |
||||
|
result = object.sum * personal_comission / 100.0 |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="goal_team_bonus" model="gamification.goal.definition"> |
||||
|
<field name="name">Team bonus</field> |
||||
|
<field name="description">Monthly team bonus</field> |
||||
|
<field name="monetary" eval="True"/> |
||||
|
<field name="computation_mode">python</field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="condition">higher</field> |
||||
|
<field name="domain">[('state','!=','cancel'),('section_id','=',user.default_section_id.id),('type','=','out_invoice')]</field><!-- duplicated at compute_code--> |
||||
|
<field name="model_id" ref="account.model_account_invoice_report"/> |
||||
|
<field name="field_id" ref="account.field_account_invoice_report_price_total"/> |
||||
|
<field name="field_date_id" eval="ref('account.field_account_invoice_report_date')" /> |
||||
|
<field name="compute_code"> |
||||
|
<![CDATA[ |
||||
|
minimum = object.user_id.default_section_id.invoiced_forecast |
||||
|
maximum = object.user_id.default_section_id.invoiced_target |
||||
|
current = object.sum |
||||
|
salary = 1000 # TODO |
||||
|
team_bonus = object.user_id.employee_ids and object.user_id.employee_ids[0].team_bonus or 0.0 |
||||
|
|
||||
|
if current < maximum: |
||||
|
current = maximum |
||||
|
if current < minimum or minimum == maximum: |
||||
|
result = 0.0 |
||||
|
else: |
||||
|
result = salary * (team_bonus / (12 * 100)) * (current - minimum) / (maximum - minimum) |
||||
|
result = int(result * 100) / 100.0 |
||||
|
]]> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record model="res.groups" id="group_dashboard_sales_person"> |
||||
|
<field name="name">dashboard_sales_person</field> |
||||
|
<field name="category_id" ref="access_custom.module_category_custom"/> |
||||
|
<field name="comment">Shows dashboard to salesperson</field> |
||||
|
</record> |
||||
|
<record model="res.groups" id="group_dashboard_management"> |
||||
|
<field name="name">dashboard_managment</field> |
||||
|
<field name="category_id" ref="access_custom.module_category_custom"/> |
||||
|
<field name="comment">Shows management dashboard</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_outstanding_invoices" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Outstanding sale orders</field> |
||||
|
<field name="model_id" ref="sale.model_sale_order"/> |
||||
|
<field name="domain">[('user_id', '=', user.id),('state', 'in', ['progress', 'manual'])]</field> |
||||
|
<field name="value_field_id" ref="sale.field_sale_order_amount_total"/> |
||||
|
<field name="content"><![CDATA[${record.name} - <b>${record.partner_id.name}</b>, ${record.date_order}]]></field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_sales_person'), 0)]"/> |
||||
|
<field name="type">list</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_sent_invoices" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Sent invoices</field> |
||||
|
<field name="model_id" ref="account.model_account_invoice"/> |
||||
|
<field name="domain">[('user_id', '=', user.id),('type', 'in', ['out_invoice']),('state','in',['open'])]</field> |
||||
|
<field name="value_field_id" ref="account.field_account_invoice_amount_total"/> |
||||
|
<field name="content"><![CDATA[${record.name} - <b>${record.partner_id.name}</b>, ${record.date_invoice}]]></field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_management'), 0)]"/> |
||||
|
<field name="type">list</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_received_invoices" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Received invoices</field> |
||||
|
<field name="model_id" ref="account.model_account_invoice"/> |
||||
|
<field name="domain">[('user_id', '=', user.id),('type', 'in', ['in_invoice']),('state','in',['open'])]</field> |
||||
|
<field name="value_field_id" ref="account.field_account_invoice_amount_total"/> |
||||
|
<field name="content"><![CDATA[${record.name} - <b>${record.partner_id.name}</b>, ${record.date_invoice}]]></field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_management'), 0)]"/> |
||||
|
<field name="type">list</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_calls" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Calls</field> |
||||
|
<field name="model_id" ref="crm.model_crm_phonecall"/> |
||||
|
<field name="domain">[('user_id', '=', user.id),('state', 'not in', ['cancel'])]</field> |
||||
|
<field name="content"><![CDATA[${record.name} - <b>${record.partner_id.name}</b>, ${record.date}]]></field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_sales_person'), 0)]"/> |
||||
|
<field name="type">list</field> |
||||
|
<field name="limit">10</field> |
||||
|
<field name="order">date DESC</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_meetings" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Mettings</field> |
||||
|
<field name="model_id" ref="calendar.model_calendar_event"/> |
||||
|
<field name="domain">[('partner_ids', 'in', [user.partner_id.id])]</field> |
||||
|
<field name="content"><![CDATA[${record.name} - ${record.start_datetime}]]></field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_sales_person'), 0)]"/> |
||||
|
<field name="type">list</field> |
||||
|
<field name="limit">10</field> |
||||
|
<field name="order">start_datetime DESC</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_sales_funnel" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Conversion Rate</field> |
||||
|
<field name="model_id" ref="crm.model_crm_lead"/> |
||||
|
<field name="domain">[('user_id','=', user.id), ('sales_funnel_type', 'in', ['won', 'lost'])]</field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_sales_person'), 0)]"/> |
||||
|
<field name="type">funnel</field> |
||||
|
<field name="value_field_id" ref="crm.field_crm_lead_planned_revenue"/> |
||||
|
<field name="stage_field_id" ref="sale_mediation_custom.field_crm_lead_stage_closed_id"/> |
||||
|
<field name="won_domain">[('sales_funnel_type', 'in', ['won'])]</field> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="widget_sales_contributed" model="mail.wall.widgets.widget"> |
||||
|
<field name="name">Sales contributed</field> |
||||
|
<field name="model_id" ref="sale.model_sale_order"/> |
||||
|
<field name="domain">[('state', 'in', ['done'])]</field> |
||||
|
<field name="won_domain">[('user_id','=', user.id), ('state', 'in', ['done'])]</field> |
||||
|
<field name="group_ids" eval="[(4, ref('mail_wall_custom.group_dashboard_sales_person'), 0)]"/> |
||||
|
<field name="type">slice</field> |
||||
|
<field name="value_field_id" ref="sale.field_sale_order_amount_total"/> |
||||
|
<field name="value_field_monetary" eval="True"/> |
||||
|
<field name="active" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
|
||||
|
<!-- |
||||
|
<record id="goal_average_deal_time" model="gamification.goal.definition"> |
||||
|
<field name="name">Average deal time</field> |
||||
|
<field name="description"></field> |
||||
|
<field name="monetary" eval="False"/> |
||||
|
<field name="suffix"></field> |
||||
|
<field name="computation_mode"></field> |
||||
|
<field name="display_mode">progress</field> |
||||
|
<field name="condition">higher</field> |
||||
|
<field name="domain"></field> |
||||
|
<field name="model_id" ref="crm.model_crm_lead"/> |
||||
|
<field name="field_id" ref="sale_mediation_custom.field_crm_lead_deal_time"/> |
||||
|
</record> |
||||
|
--> |
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,13 @@ |
|||||
|
from openerp import api,models,fields |
||||
|
from openerp.osv import fields as old_fields |
||||
|
|
||||
|
class hr_employee(models.Model): |
||||
|
_inherit = 'hr.employee' |
||||
|
|
||||
|
default_section_id = fields.Many2one('crm.case.section', 'Default Sales Team', related='user_id.default_section_id') |
||||
|
|
||||
|
personal_comission = fields.Float('Personal comission', help='Personal comission for sales. Value 1.0 is equal 1%') |
||||
|
|
||||
|
team_bonus = fields.Float('Team bonus', help='Maximum team bonus (per year). Value 1.0 is equal 1%') |
||||
|
|
||||
|
company_bonus = fields.Float('Company bonus', help='Maximum team bonus (per year). Value 1.0 is equal 1%') |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<record id="view_employee_form" model="ir.ui.view"> |
||||
|
<field name="name">hr.employee.form</field> |
||||
|
<field name="model">hr.employee</field> |
||||
|
<field name="inherit_id" ref="hr.view_employee_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//group[@name='active_group']" position="before"> |
||||
|
<group string="Bonuses"> |
||||
|
<field name="default_section_id"/> |
||||
|
<field name="personal_comission"/> |
||||
|
<field name="team_bonus"/> |
||||
|
<field name="company_bonus"/> |
||||
|
</group> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue