diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py
index 4d1cd131619..c601aaac13c 100644
--- a/addons/account_followup/report/account_followup_print.py
+++ b/addons/account_followup/report/account_followup_print.py
@@ -37,13 +37,12 @@ class report_rappel(report_sxw.rml_parse):
'get_text': self._get_text
})
- def _ids_to_objects(self, partners_ids):
+ def _ids_to_objects(self, partner_ids):
pool = pooler.get_pool(self.cr.dbname)
all_partners = []
- for partner in partners_ids:
- partners = pool.get('account_followup.stat').browse(self.cr, self.uid, [partner])
- for par in partners:
- all_partners.append(par.name)
+ for partner in pool.get('res.partner').browse(self.cr, self.uid, partner_ids):
+ if partner not in all_partners:
+ all_partners.append(partner)
return all_partners
def _adr_get(self, partner, type):
diff --git a/addons/account_followup/report/account_followup_report.py b/addons/account_followup/report/account_followup_report.py
index 00dfe3a9998..0cfc5cd4671 100644
--- a/addons/account_followup/report/account_followup_report.py
+++ b/addons/account_followup/report/account_followup_report.py
@@ -22,20 +22,13 @@
from osv import fields, osv
import tools
-def _code_get(self, cr, uid, context={}):
- acc_type_obj = self.pool.get('account.account.type')
- ids = acc_type_obj.search(cr, uid, [])
- res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context)
- return [(r['code'], r['name']) for r in res]
-
-
class account_followup_stat(osv.osv):
_name = "account_followup.stat"
_description = "Followup Statistics"
+ _rec_name = 'partner_id'
_auto = False
_columns = {
- 'name': fields.many2one('res.partner', 'Partner', readonly=True),
- 'account_type': fields.selection(_code_get, 'Account Type', readonly=True),
+ 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
'date_move':fields.date('First move', readonly=True),
'date_move_last':fields.date('Last move', readonly=True),
'date_followup':fields.date('Latest followup', readonly=True),
@@ -58,10 +51,7 @@ class account_followup_stat(osv.osv):
current_year = self.pool.get('account.fiscalyear').find(cr, uid)
ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
args.append(['period_id','in',ids])
- for a in [['period_id','in','current_year']]:
- temp_args = tuple(a)
- if temp_args in args:
- args.remove(temp_args)
+ args.remove(arg)
return super(account_followup_stat, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
context=context, count=count)
@@ -72,47 +62,37 @@ class account_followup_stat(osv.osv):
current_year = self.pool.get('account.fiscalyear').find(cr, uid)
ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
domain.append(['period_id','in',ids])
- todel.append(arg)
- for a in [['period_id','in','current_year']]:
- temp_args = tuple(a)
- if temp_args in domain:
- domain.remove(temp_args)
+ domain.remove(arg)
return super(account_followup_stat, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
def init(self, cr):
tools.drop_view_if_exists(cr, 'account_followup_stat')
cr.execute("""
create or replace view account_followup_stat as (
- select
- l.partner_id as id,
- l.partner_id as name,
- min(l.date) as date_move,
- max(l.date) as date_move_last,
- max(l.followup_date) as date_followup,
- max(l.followup_line_id) as followup_id,
- sum(l.debit) as debit,
- sum(l.credit) as credit,
- sum(l.debit - l.credit) as balance,
- a.type as account_type,
- l.company_id as company_id,
- l.blocked,
- am.period_id as period_id
- from
+ SELECT
+ l.id AS id,
+ l.partner_id AS partner_id,
+ min(l.date) AS date_move,
+ max(l.date) AS date_move_last,
+ max(l.followup_date) AS date_followup,
+ max(l.followup_line_id) AS followup_id,
+ sum(l.debit) AS debit,
+ sum(l.credit) AS credit,
+ sum(l.debit - l.credit) AS balance,
+ l.company_id AS company_id,
+ l.blocked as blocked,
+ l.period_id AS period_id
+ FROM
account_move_line l
- LEFT JOIN account_account a ON (l.account_id=a.id)
- LEFT JOIN res_company c ON (l.company_id=c.id)
- LEFT JOIN account_move am ON (am.id=l.move_id)
- LEFT JOIN account_period p ON (am.period_id=p.id)
- where
- l.reconcile_id is NULL and
- a.type = 'receivable'
- and a.active and
- l.partner_id is not NULL and
- l.company_id is not NULL and
- l.blocked is not NULL
- group by
- l.partner_id, a.type, l.company_id,l.blocked,am.period_id
+ LEFT JOIN account_account a ON (l.account_id = a.id)
+ WHERE
+ a.active AND
+ a.type = 'receivable' AND
+ l.reconcile_id is NULL AND
+ l.partner_id IS NOT NULL
+ GROUP BY
+ l.id, l.partner_id, l.company_id, l.blocked, l.period_id
)""")
account_followup_stat()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/report/account_followup_report.xml b/addons/account_followup/report/account_followup_report.xml
index 73b2740a43b..fdde1f9300f 100644
--- a/addons/account_followup/report/account_followup_report.xml
+++ b/addons/account_followup/report/account_followup_report.xml
@@ -8,15 +8,15 @@
tree
-
+
-
-
+
+
@@ -30,7 +30,7 @@
graph
-
+
@@ -51,18 +51,20 @@
domain="[('blocked','=', False)]"
help = "Including journal entries marked as a litigation"/>
-
+
-
-
+
+
+
+
@@ -76,9 +78,8 @@
{'search_default_followup_level':1,'search_default_fiscalyear':1}
-
-
+
diff --git a/addons/account_followup/security/ir.model.access.csv b/addons/account_followup/security/ir.model.access.csv
index 60d179d3cbe..7b7e2af7ba8 100644
--- a/addons/account_followup/security/ir.model.access.csv
+++ b/addons/account_followup/security/ir.model.access.csv
@@ -4,3 +4,4 @@
"access_account_followup_followup_line_manager","account_followup.followup.line.manager","model_account_followup_followup_line","account.group_account_manager",1,1,1,1
"access_account_followup_followup_accountant","account_followup.followup user","model_account_followup_followup","account.group_account_user",1,0,0,0
"access_account_followup_stat_invoice","account_followup.stat.invoice","model_account_followup_stat","account.group_account_invoice",1,1,1,1
+"access_account_followup_stat_by_partner_manager","account_followup.stat.by.partner","model_account_followup_stat_by_partner","account.group_account_manager",1,1,1,1
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index be353220e99..22f432f77f6 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -67,14 +67,55 @@ class account_followup_print(osv.osv_memory):
'date': time.strftime('%Y-%m-%d'),
'followup_id': _get_followup,
}
-
account_followup_print()
+class account_followup_stat_by_partner(osv.osv):
+ _name = "account_followup.stat.by.partner"
+ _description = "Followup Statistics by Partner"
+ _rec_name = 'partner_id'
+ _auto = False
+ _columns = {
+ 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
+ 'date_move':fields.date('First move', readonly=True),
+ 'date_move_last':fields.date('Last move', readonly=True),
+ 'date_followup':fields.date('Latest followup', readonly=True),
+ 'max_followup_id': fields.many2one('account_followup.followup.line',
+ 'Max Follow Up Level', readonly=True, ondelete="cascade"),
+ 'balance':fields.float('Balance', readonly=True),
+ 'company_id': fields.many2one('res.company', 'Company', readonly=True),
+ }
+
+ def init(self, cr):
+ tools.drop_view_if_exists(cr, 'account_followup_stat_by_partner')
+ cr.execute("""
+ create or replace view account_followup_stat_by_partner as (
+ SELECT
+ l.partner_id AS id,
+ l.partner_id AS partner_id,
+ min(l.date) AS date_move,
+ max(l.date) AS date_move_last,
+ max(l.followup_date) AS date_followup,
+ max(l.followup_line_id) AS max_followup_id,
+ sum(l.debit - l.credit) AS balance,
+ l.company_id company_id
+ FROM
+ account_move_line l
+ LEFT JOIN account_account a ON (l.account_id = a.id)
+ WHERE
+ a.active AND
+ a.type = 'receivable' AND
+ l.reconcile_id is NULL AND
+ l.partner_id IS NOT NULL
+ GROUP BY
+ l.partner_id, l.company_id
+ )""")
+account_followup_stat_by_partner()
+
class account_followup_print_all(osv.osv_memory):
_name = 'account.followup.print.all'
_description = 'Print Followup & Send Mail to Customers'
_columns = {
- 'partner_ids': fields.many2many('account_followup.stat', 'partner_stat_rel', 'followup_id', 'stat_id', 'Partners', required=True),
+ 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True, domain="[('account_id.type', '=', 'receivable'), ('account_id.reconcile', '=', True), ('reconcile_id','=', False), ('state', '!=', 'draft'), ('account_id.active', '=' True), ('debit', '>', 0)]"),
'email_conf': fields.boolean('Send email confirmation'),
'email_subject': fields.char('Email Subject', size=64),
'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
@@ -94,7 +135,7 @@ class account_followup_print_all(osv.osv_memory):
_defaults = {
'email_body': _get_msg,
- 'email_subject': 'Invoices Reminder',
+ 'email_subject': _('Invoices Reminder'),
'partner_lang': True,
'partner_ids': _get_partners,
'summary': _get_summary,
@@ -295,4 +336,4 @@ class account_followup_print_all(osv.osv_memory):
account_followup_print_all()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index d21a1162a41..f647c569358 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -36,8 +36,38 @@
parent="account.menu_finance_periodical_processing_billing"
sequence="10"/>
+
+ account_followup.stat.by.partner.search
+ account_followup.stat.by.partner
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+ account_followup.stat.by.partner.tree
+ account_followup.stat.by.partner
+ tree
+
+
+
+
+
+
+
+
+
+
+
account.followup.print.all.form
@@ -48,8 +78,8 @@
-
-
+
+
diff --git a/addons/crm/crm_opportunity_menu.xml b/addons/crm/crm_opportunity_menu.xml
index 9a065571324..6b2e2d0fc39 100644
--- a/addons/crm/crm_opportunity_menu.xml
+++ b/addons/crm/crm_opportunity_menu.xml
@@ -9,7 +9,7 @@
res_model="crm.phonecall"
src_model="crm.lead"
view_mode="tree,calendar,form"
- context="{'default_duration': 1.0 ,'default_opportunity_id': active_id}"
+ context="{'default_duration': 1.0 ,'default_opportunity_id': active_id,'default_partner_phone':phone}"
domain="[('opportunity_id', '=', active_id)]"
view_type="form"/>
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 85e36f068fd..03b56e6b40e 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -82,6 +82,7 @@
sale.order.tree
sale.order
tree
+ 2