[MERGE]
bzr revid: qdp@cyan-20100601131650-nfdp1wo7te4b6btn
This commit is contained in:
@@ -530,9 +530,8 @@ class account_move_line(osv.osv):
|
||||
date = datetime.now().strftime('%Y-%m-%d')
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
|
||||
if part.property_payment_term and part.property_payment_term.line_ids:
|
||||
payterm = part.property_payment_term.line_ids[0]
|
||||
res = self.pool.get('account.payment.term').compute(cr, uid, payterm.id, 100, date)
|
||||
if part.property_payment_term:
|
||||
res = self.pool.get('account.payment.term').compute(cr, uid, part.property_payment_term.id, 100, date)
|
||||
if res:
|
||||
val['date_maturity'] = res[0][0]
|
||||
if not account_id:
|
||||
@@ -540,10 +539,10 @@ class account_move_line(osv.osv):
|
||||
id2 = part.property_account_receivable.id
|
||||
if journal:
|
||||
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
||||
if jt=='sale':
|
||||
if jt == 'sale':
|
||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
|
||||
|
||||
elif jt=='purchase':
|
||||
elif jt == 'purchase':
|
||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
|
||||
if val.get('account_id', False):
|
||||
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
||||
|
||||
@@ -35,7 +35,7 @@ class crm_lead_report(osv.osv):
|
||||
_name = "crm.lead.report"
|
||||
_auto = False
|
||||
_description = "CRM Lead Report"
|
||||
|
||||
|
||||
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
|
||||
|
||||
""" @param cr: the current row, from the database cursor,
|
||||
@@ -89,7 +89,10 @@ class crm_lead_report(osv.osv):
|
||||
('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'create_date': fields.datetime('Create Date', readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'email': fields.integer('# of Emails', size=128, readonly=True),
|
||||
'expected_closing_days': fields.integer('# of Expected Closing Days', size=128, readonly=True),
|
||||
'delay_open': fields.float('Delay to open',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"),
|
||||
'delay_close': fields.float('Delay to close',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
|
||||
'categ_id': fields.many2one('crm.case.categ', 'Category',\
|
||||
domain="[('section_id','=',section_id),\
|
||||
@@ -98,11 +101,10 @@ class crm_lead_report(osv.osv):
|
||||
domain="[('section_id','=',section_id),\
|
||||
('object_id.model', '=', 'crm.lead')]", readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||
'type':fields.selection([
|
||||
('lead','Lead'),
|
||||
('opportunity','Opportunity'),
|
||||
|
||||
],'Type', help="Type is used to separate Leads and Opportunities"),
|
||||
}
|
||||
def init(self, cr):
|
||||
@@ -132,13 +134,28 @@ class crm_lead_report(osv.osv):
|
||||
0 as avg_answers,
|
||||
0.0 as perc_done,
|
||||
0.0 as perc_cancel,
|
||||
(select count(id) from mailgate_message where thread_id=c.id) as email,
|
||||
date_trunc('day',c.create_date) as create_date,
|
||||
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close
|
||||
sum(cast(to_char(date_trunc('day',c.date_open) - date_trunc('day',c.date_deadline),'DD') as int)) as expected_closing_days,
|
||||
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close,
|
||||
avg(extract('epoch' from (c.date_open-c.create_date)))/(3600*24) as delay_open
|
||||
from
|
||||
crm_lead c
|
||||
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),\
|
||||
c.state, c.user_id,c.section_id,c.stage_id,categ_id,c.partner_id,c.company_id, c.type
|
||||
,c.create_date,to_char(c.create_date, 'YYYY-MM-DD')
|
||||
group by
|
||||
to_char(c.create_date, 'YYYY'),
|
||||
to_char(c.create_date, 'MM'),
|
||||
c.state,
|
||||
c.user_id,
|
||||
c.id,
|
||||
c.section_id,
|
||||
c.stage_id,
|
||||
categ_id,
|
||||
c.partner_id,
|
||||
c.company_id,
|
||||
c.type,
|
||||
c.create_date,
|
||||
to_char(c.create_date, 'YYYY-MM-DD')
|
||||
|
||||
)""")
|
||||
|
||||
crm_lead_report()
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<field name="model">crm.lead.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Opportunities">
|
||||
<tree string="Opportunities Analysis">
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="section_id" invisible="1" groups="base.group_extended"/>
|
||||
@@ -153,7 +153,10 @@
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="nbr" string="#Opportunities" sum="#Opportunities"/>
|
||||
<field name="delay_close" sum='Avg Closing Delay'/>
|
||||
<field name="email" sum="# of Emails"/>
|
||||
<field name="expected_closing_days" sum='# of Expected Closing Days'/>
|
||||
<field name="delay_open" sum='Delay to open'/>
|
||||
<field name="delay_close" sum='Delay to close'/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="stage_id" invisible="1"/>
|
||||
<field name="categ_id" invisible="1"/>
|
||||
@@ -188,8 +191,8 @@
|
||||
<field name="act_window_id" ref="action_report_crm_lead"/>
|
||||
</record>
|
||||
|
||||
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
|
||||
<field name="name">Opportunities</field>
|
||||
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
|
||||
<field name="name">Opportunities Analysis</field>
|
||||
<field name="res_model">crm.lead.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{"search_default_User":1,"search_default_This Month":1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
@@ -216,7 +219,7 @@
|
||||
groups="base.group_extended"
|
||||
parent="base.next_id_64" action="action_report_crm_lead" />
|
||||
|
||||
<menuitem name="Opportunities" id="menu_report_crm_opportunities_tree"
|
||||
<menuitem name="Opportunities Analysis" id="menu_report_crm_opportunities_tree"
|
||||
groups="base.group_extended"
|
||||
parent="base.next_id_64" action="action_report_crm_opportunity" />
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,62 +15,32 @@
|
||||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class invoice_directly(wizard.interface):
|
||||
def _test_action(obj, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
pick = pool.get('stock.picking').browse(cr, uid, data['id'], context=context)
|
||||
if not pick.invoice_state == '2binvoiced':
|
||||
return 'end_final'
|
||||
return 'invoice'
|
||||
class invoice_directly(osv.osv_memory):
|
||||
_inherit = 'stock.partial.picking'
|
||||
|
||||
def _open_action(obj, cr, uid, data, context):
|
||||
res = {
|
||||
'name': 'stock.invoice_onshipping',
|
||||
'type': 'ir.actions.wizard',
|
||||
'wiz_name': 'stock.invoice_onshipping'
|
||||
}
|
||||
if data['form'].get('new_picking', False):
|
||||
res['context'] = "{'new_picking':%d}" % (data['form']['new_picking'],)
|
||||
return res
|
||||
def do_partial(self, cr, uid, ids, context):
|
||||
result = super(invoice_directly, self).do_partial(cr, uid, ids, context)
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
picking_ids = context.get('active_ids', False)
|
||||
pick = pick_obj.browse(cr, uid, picking_ids, context)[0]
|
||||
if pick.invoice_state=='2binvoiced':
|
||||
return {
|
||||
'name': 'Create Invoice',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'stock.invoice.onshipping',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
return {}
|
||||
|
||||
end_final = {
|
||||
'actions':[],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state': 'end',
|
||||
}
|
||||
}
|
||||
|
||||
choice = {
|
||||
'actions':[],
|
||||
'result': {
|
||||
'type': 'choice',
|
||||
'next_state': _test_action,
|
||||
}
|
||||
}
|
||||
|
||||
call_invoice = {
|
||||
'actions':[],
|
||||
'result': {
|
||||
'type': 'action',
|
||||
'action': _open_action,
|
||||
'state': 'end'
|
||||
}
|
||||
}
|
||||
def __init__(self, *args):
|
||||
service = netsvc.LocalService("wizard.stock.partial_picking")
|
||||
service._service.states['split']['result']['state'] = 'test_choice'
|
||||
service._service.states['invoice'] = self.call_invoice
|
||||
service._service.states['test_choice'] = self.choice
|
||||
service._service.states['end_final'] = self.end_final
|
||||
invoice_directly('stock.picking.invoice.directly')
|
||||
invoice_directly()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user