[ADD]crm_case_section (view & py file) add in sale module, that file split from sale.py & sale_view.xml
This commit is contained in:
parent
10beeb53ed
commit
e511de45cb
|
@ -24,6 +24,7 @@
|
|||
#----------------------------------------------------------
|
||||
|
||||
import sale
|
||||
import crm_case_section
|
||||
import res_partner
|
||||
import wizard
|
||||
import report
|
||||
|
|
|
@ -71,6 +71,7 @@ The Dashboard for the Sales Manager will include
|
|||
'sale_report.xml',
|
||||
'sale_data.xml',
|
||||
'sale_view.xml',
|
||||
'crm_case_section_view.xml',
|
||||
'res_partner_view.xml',
|
||||
'report/sale_report_view.xml',
|
||||
'edi/sale_order_action_data.xml',
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import calendar
|
||||
from openerp import tools
|
||||
from datetime import date, datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from dateutil import relativedelta
|
||||
import time
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from openerp import workflow
|
||||
|
||||
|
||||
class crm_case_section(osv.osv):
|
||||
_inherit = 'crm.case.section'
|
||||
|
||||
def _get_sale_orders_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool.get('sale.order')
|
||||
res = dict.fromkeys(ids, False)
|
||||
month_begin = date.today().replace(day=1)
|
||||
date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
for id in ids:
|
||||
res[id] = dict()
|
||||
created_domain = [('section_id', '=', id), ('state', '=', ['draft']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_quoted'] = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
validated_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'sent', 'cancel']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_confirmed'] = self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
return res
|
||||
|
||||
def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool.get('account.invoice.report')
|
||||
res = dict.fromkeys(ids, False)
|
||||
month_begin = date.today().replace(day=1)
|
||||
date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
for id in ids:
|
||||
created_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', date_begin), ('date', '<=', date_end)]
|
||||
res[id] = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'invoiced_forecast': fields.integer(string='Invoice Forecast',
|
||||
help="Forecast of the invoice revenue for the current month. This is the amount the sales \n"
|
||||
"team should invoice this month. It is used to compute the progression ratio \n"
|
||||
" of the current and forecast revenue on the kanban view."),
|
||||
'invoiced_target': fields.integer(string='Invoice Target',
|
||||
help="Target of invoice revenue for the current month. This is the amount the sales \n"
|
||||
"team estimates to be able to invoice this month."),
|
||||
'monthly_quoted': fields.function(_get_sale_orders_data,
|
||||
type='string', readonly=True, multi='_get_sale_orders_data',
|
||||
string='Rate of created quotation per duration'),
|
||||
'monthly_confirmed': fields.function(_get_sale_orders_data,
|
||||
type='string', readonly=True, multi='_get_sale_orders_data',
|
||||
string='Rate of validate sales orders per duration'),
|
||||
'monthly_invoiced': fields.function(_get_invoices_data,
|
||||
type='string', readonly=True,
|
||||
string='Rate of sent invoices per duration'),
|
||||
}
|
||||
|
||||
def action_forecast(self, cr, uid, id, value, context=None):
|
||||
return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="crm_case_section_salesteams_view_form" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.form</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="inherit_id" ref="sale_team.crm_case_section_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='code']" position="after">
|
||||
<field name="invoiced_target"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_section_salesteams_view_kanban" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.kanban</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="inherit_id" ref="sale_team.crm_case_section_salesteams_view_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="monthly_quoted"/>
|
||||
<field name="monthly_confirmed"/>
|
||||
<field name="monthly_invoiced"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
<field name="invoiced_target"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="before">
|
||||
<div class="oe_items_list">
|
||||
<div class="oe_salesteams_quotations">
|
||||
<a name="%(action_quotations_salesteams)d" type="action" class="oe_sparkline_bar_link">Quotations</a>
|
||||
<a name="%(action_order_report_quotation_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_quoted" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of created quotations per month.<br/>Click to see a detailed analysis.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_salesteams_orders">
|
||||
<a name="%(action_orders_salesteams)d" type="action">Sales Orders</a>
|
||||
<a name="%(action_order_report_so_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_confirmed" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of confirmed sales orders per month.<br/>Click to acces the Sales Analysis.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_salesteams_invoices" groups="account.group_account_invoice">
|
||||
<a name="%(action_invoice_salesteams)d" type="action">Invoices</a>
|
||||
<a name="%(action_account_invoice_report_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_invoiced" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of sent invoices per month.<br/>Click to see a detailed analysis of invoices.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="after">
|
||||
<div class="oe_center" t-if="record.invoiced_target.raw_value">
|
||||
<field name="monthly_invoiced" widget="gauge" style="width:160px; height: 120px; cursor: pointer;"
|
||||
options="{'max_field': 'invoiced_target'}">Invoiced</field>
|
||||
<field name="invoiced_forecast" widget="gauge" style="width:160px; height: 120px; cursor: pointer;"
|
||||
options="{'max_field': 'invoiced_target', 'on_change': 'action_forecast'}">Forecast</field>
|
||||
</div>
|
||||
<div class="oe_center oe_salesteams_help" style="color:#bbbbbb;" t-if="!record.invoiced_target.raw_value">
|
||||
<br/>Define an invoicing target in the sales team settings to see the period's achievement and forecast at a glance.
|
||||
</div>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1042,56 +1042,6 @@ class account_invoice(osv.Model):
|
|||
_defaults = {
|
||||
'section_id': lambda self, cr, uid, c=None: self.pool.get('res.users').browse(cr, uid, uid, c).default_section_id.id or False,
|
||||
}
|
||||
|
||||
class crm_case_section(osv.osv):
|
||||
_inherit = 'crm.case.section'
|
||||
|
||||
def _get_sale_orders_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool.get('sale.order')
|
||||
res = dict.fromkeys(ids, False)
|
||||
month_begin = date.today().replace(day=1)
|
||||
date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
for id in ids:
|
||||
res[id] = dict()
|
||||
created_domain = [('section_id', '=', id), ('state', '=', ['draft']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_quoted'] = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
validated_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'sent', 'cancel']), ('date_order', '>=', date_begin), ('date_order', '<=', date_end)]
|
||||
res[id]['monthly_confirmed'] = self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context)
|
||||
return res
|
||||
|
||||
def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool.get('account.invoice.report')
|
||||
res = dict.fromkeys(ids, False)
|
||||
month_begin = date.today().replace(day=1)
|
||||
date_begin = (month_begin - relativedelta.relativedelta(months=self._period_number - 1)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1]).strftime(tools.DEFAULT_SERVER_DATE_FORMAT)
|
||||
for id in ids:
|
||||
created_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', date_begin), ('date', '<=', date_end)]
|
||||
res[id] = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'invoiced_forecast': fields.integer(string='Invoice Forecast',
|
||||
help="Forecast of the invoice revenue for the current month. This is the amount the sales \n"
|
||||
"team should invoice this month. It is used to compute the progression ratio \n"
|
||||
" of the current and forecast revenue on the kanban view."),
|
||||
'invoiced_target': fields.integer(string='Invoice Target',
|
||||
help="Target of invoice revenue for the current month. This is the amount the sales \n"
|
||||
"team estimates to be able to invoice this month."),
|
||||
'monthly_quoted': fields.function(_get_sale_orders_data,
|
||||
type='string', readonly=True, multi='_get_sale_orders_data',
|
||||
string='Rate of created quotation per duration'),
|
||||
'monthly_confirmed': fields.function(_get_sale_orders_data,
|
||||
type='string', readonly=True, multi='_get_sale_orders_data',
|
||||
string='Rate of validate sales orders per duration'),
|
||||
'monthly_invoiced': fields.function(_get_invoices_data,
|
||||
type='string', readonly=True,
|
||||
string='Rate of sent invoices per duration'),
|
||||
}
|
||||
|
||||
def action_forecast(self, cr, uid, id, value, context=None):
|
||||
return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context)
|
||||
|
||||
class product_product(osv.Model):
|
||||
_inherit = 'product.product'
|
||||
|
|
|
@ -682,75 +682,5 @@
|
|||
<field name="context">{'search_default_month':1}</field>
|
||||
<field name="help">From this report, you can have an overview of the amount invoiced to your customer. The tool search can also be used to personalise your Invoices reports and so, match this analysis to your needs.</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_section_salesteams_view_form" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.form</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="inherit_id" ref="sale_team.crm_case_section_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='code']" position="after">
|
||||
<field name="invoiced_target"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_case_section_salesteams_view_kanban" model="ir.ui.view">
|
||||
<field name="name">crm.case.section.kanban</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="inherit_id" ref="sale_team.crm_case_section_salesteams_view_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="monthly_quoted"/>
|
||||
<field name="monthly_confirmed"/>
|
||||
<field name="monthly_invoiced"/>
|
||||
<field name="invoiced_forecast"/>
|
||||
<field name="invoiced_target"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="before">
|
||||
<div class="oe_items_list">
|
||||
<div class="oe_salesteams_quotations">
|
||||
<a name="%(action_quotations_salesteams)d" type="action" class="oe_sparkline_bar_link">Quotations</a>
|
||||
<a name="%(action_order_report_quotation_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_quoted" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of created quotations per month.<br/>Click to see a detailed analysis.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_salesteams_orders">
|
||||
<a name="%(action_orders_salesteams)d" type="action">Sales Orders</a>
|
||||
<a name="%(action_order_report_so_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_confirmed" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of confirmed sales orders per month.<br/>Click to acces the Sales Analysis.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_salesteams_invoices" groups="account.group_account_invoice">
|
||||
<a name="%(action_invoice_salesteams)d" type="action">Invoices</a>
|
||||
<a name="%(action_account_invoice_report_salesteam)d" type="action" class="oe_sparkline_bar_link">
|
||||
<field name="monthly_invoiced" widget="sparkline_bar" options="{'delayIn': '3000'}">
|
||||
Revenue of sent invoices per month.<br/>Click to see a detailed analysis of invoices.
|
||||
</field>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_clear']" position="after">
|
||||
<div class="oe_center" t-if="record.invoiced_target.raw_value">
|
||||
<field name="monthly_invoiced" widget="gauge" style="width:160px; height: 120px; cursor: pointer;"
|
||||
options="{'max_field': 'invoiced_target'}">Invoiced</field>
|
||||
<field name="invoiced_forecast" widget="gauge" style="width:160px; height: 120px; cursor: pointer;"
|
||||
options="{'max_field': 'invoiced_target', 'on_change': 'action_forecast'}">Forecast</field>
|
||||
</div>
|
||||
<div class="oe_center oe_salesteams_help" style="color:#bbbbbb;" t-if="!record.invoiced_target.raw_value">
|
||||
<br/>Define an invoicing target in the sales team settings to see the period's achievement and forecast at a glance.
|
||||
</div>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -7,23 +7,22 @@
|
|||
<field name="inherit_id" ref="base_setup.view_sale_config_settings"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<div name="config_sale" position="before">
|
||||
<separator string="Sales Teams"/>
|
||||
<group>
|
||||
<label for="id" string="Manage Sales Teams"/>
|
||||
<div>
|
||||
<div>
|
||||
<field name="group_multi_salesteams" class="oe_inline"/>
|
||||
<label for="group_multi_salesteams"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
</div>
|
||||
<div name="config_sale" position="before">
|
||||
<separator string="Sales Teams"/>
|
||||
<group>
|
||||
<label for="id" string="Manage Sales Teams"/>
|
||||
<div>
|
||||
<div>
|
||||
<field name="group_multi_salesteams" class="oe_inline"/>
|
||||
<label for="group_multi_salesteams"/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
</div>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="base.menu_sale_config" name="Sales" parent="base.menu_config"
|
||||
<menuitem id="base.menu_sale_config" name="Sales" parent="base.menu_config"
|
||||
sequence="1" action="base_setup.action_sale_config"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<!-- Case Sections Salesteams kanban view -->
|
||||
|
||||
<record model="ir.ui.view" id="crm_case_section_salesteams_view_kanban">
|
||||
<record id="crm_case_section_salesteams_view_kanban" model="ir.ui.view" >
|
||||
<field name="name">crm.case.section.kanban</field>
|
||||
<field name="model">crm.case.section</field>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -197,4 +197,4 @@
|
|||
</record>
|
||||
<menuitem id="sale_team.menu_sale_team_act" action="crm_case_section_salesteams_act" sequence="1" parent="base.menu_sales"/>
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue