diff --git a/account_credit_control/wizard/credit_control_mailer.py b/account_credit_control/wizard/credit_control_mailer.py
index d64197612..73751f615 100644
--- a/account_credit_control/wizard/credit_control_mailer.py
+++ b/account_credit_control/wizard/credit_control_mailer.py
@@ -22,14 +22,15 @@ from openerp.osv.orm import TransientModel, fields
from openerp.osv.osv import except_osv
from openerp.tools.translate import _
+
class CreditControlMailer(TransientModel):
- """Change the state of lines in mass"""
+ """Send emails for each selected credit control lines."""
_name = "credit.control.mailer"
_description = """Mass credit line mailer"""
_rec_name = 'id'
- _columns = {'mail_all': fields.boolean('Mail all ready lines')}
+ _columns = {'mail_all': fields.boolean('Send an email for all "To Send" lines.')}
def _get_lids(self, cursor, uid, mail_all, active_ids, context=None):
@@ -47,18 +48,26 @@ class CreditControlMailer(TransientModel):
def mail_lines(self, cursor, uid, wiz_id, context=None):
+ assert not (isinstance(run_id, list) and len(run_id) > 1), \
+ "run_id: only one id expected"
comm_obj = self.pool.get('credit.control.communication')
- context = context or {}
+ if context is None:
+ context = {}
+ assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
+ "wiz_id: only one id expected"
if isinstance(wiz_id, list):
wiz_id = wiz_id[0]
current = self.browse(cursor, uid, wiz_id, context)
lines_ids = context.get('active_ids')
if not lines_ids and not current.mail_all:
- raise except_osv(_('Not lines ids are selected'),
- _('You may check "Mail all ready lines"'))
+ raise except_osv(_('Error'),
+ _('No lines are selected. You may want to activate '
+ '"Send an email for all "To Send" lines."'))
+
filtered_ids = self._get_lids(cursor, uid, current.mail_all, lines_ids, context)
comms = comm_obj._generate_comm_from_credit_line_ids(cursor, uid, filtered_ids,
context=context)
comm_obj._generate_mails(cursor, uid, comms, context=context)
return {}
+
diff --git a/account_credit_control/wizard/credit_control_marker.py b/account_credit_control/wizard/credit_control_marker.py
index 8960852bd..7397a343b 100644
--- a/account_credit_control/wizard/credit_control_marker.py
+++ b/account_credit_control/wizard/credit_control_marker.py
@@ -27,11 +27,11 @@ class CreditControlMarker(TransientModel):
_name = "credit.control.marker"
_description = """Mass marker"""
- _columns = {'name': fields.selection([('to_be_sent', 'To be sent'),
+ _columns = {'name': fields.selection([('to_be_sent', 'To send'),
('sent', 'Done')],
'Mark as', required=True),
- 'mark_all': fields.boolean('Mark all draft lines')}
+ 'mark_all': fields.boolean('Change status of all draft lines')}
_defaults = {'name': 'to_be_sent'}
@@ -49,27 +49,29 @@ class CreditControlMarker(TransientModel):
line_obj = self.pool.get('credit.control.line')
if not state:
raise ValueError(_('state can not be empty'))
- line_obj.write(cursor, uid, filtered_ids, {'state': state})
+ line_obj.write(cursor, uid, filtered_ids, {'state': state}, context=context)
return filtered_ids
-
-
def mark_lines(self, cursor, uid, wiz_id, context=None):
"""Write state of selected credit lines to the one in entry
done credit line will be ignored"""
- context = context or {}
+ if context is None:
+ context = {}
+ assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
+ "wiz_id: only one id expected"
if isinstance(wiz_id, list):
wiz_id = wiz_id[0]
current = self.browse(cursor, uid, wiz_id, context)
lines_ids = context.get('active_ids')
if not lines_ids and not current.mark_all:
- raise except_osv(_('Not lines ids are selected'),
- _('You may check "Mark all draft lines"'))
+ raise except_osv(_('Error'),
+ _('No lines are selected. You may want to activate '
+ '"Change status of all draft lines"'))
filtered_ids = self._get_lids(cursor, uid, current.mark_all, lines_ids, context)
if not filtered_ids:
- raise except_osv(_('No lines will be changed'),
- _('All selected lines are allready done'))
+ raise except_osv(_('Information'),
+ _('No lines will be changed. All the selected lines are already done'))
# hook function a simple write should be enought
self._mark_lines(cursor, uid, filtered_ids, current.name, context)
@@ -81,3 +83,4 @@ class CreditControlMarker(TransientModel):
'view_id': False,
'res_model': 'credit.control.line',
'type': 'ir.actions.act_window'}
+
diff --git a/account_credit_control/wizard/credit_control_marker_view.xml b/account_credit_control/wizard/credit_control_marker_view.xml
index 6898c1ca1..9ba1c6ddd 100644
--- a/account_credit_control/wizard/credit_control_marker_view.xml
+++ b/account_credit_control/wizard/credit_control_marker_view.xml
@@ -7,13 +7,13 @@
form
@@ -30,14 +30,14 @@
id="open_credit_line_marker_wizard_menu_action"/>
- Mark lines
+ Change Lines' State
credit.control.marker
credit.control.line
form
form
new
- Mark all lines. You can the send marked lines
+ Change the state of the selected lines.
diff --git a/account_credit_control/wizard/credit_control_printer.py b/account_credit_control/wizard/credit_control_printer.py
index 55ff06590..b047363b7 100644
--- a/account_credit_control/wizard/credit_control_printer.py
+++ b/account_credit_control/wizard/credit_control_printer.py
@@ -30,12 +30,16 @@ class CreditControlPrinter(TransientModel):
_name = "credit.control.printer"
_rec_name = 'id'
_description = """Mass printer"""
- _columns = {'mark_as_sent': fields.boolean('Mark lines as send',
- help="Lines to emailed will be ignored"),
- 'print_all': fields.boolean('Print all ready lines'),
- 'report_file': fields.binary('Generated Report'),
+ _columns = {'mark_as_sent': fields.boolean('Mark lines as sent',
+ help="Only manual lines will be marked."),
+ 'print_all': fields.boolean('Print all "To send" lines'),
+ 'report_file': fields.binary('Generated Report', readonly=True),
'state': fields.char('state', size=32)}
+ _defaults = {
+ 'mark_as_sent': True,
+ }
+
def _get_lids(self, cursor, uid, print_all, active_ids, context=None):
"""get line to be marked filter done lines"""
# TODO Dry with mailer maybe in comm
@@ -52,14 +56,18 @@ class CreditControlPrinter(TransientModel):
def print_lines(self, cursor, uid, wiz_id, context=None):
comm_obj = self.pool.get('credit.control.communication')
- context = context or {}
+ if context is None:
+ context = {}
+ assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
+ "wiz_id: only one id expected"
if isinstance(wiz_id, list):
wiz_id = wiz_id[0]
current = self.browse(cursor, uid, wiz_id, context)
lines_ids = context.get('active_ids')
if not lines_ids and not current.print_all:
- raise except_osv(_('Not lines ids are selected'),
- _('You may check "Print all ready lines"'))
+ raise except_osv(_('Error'),
+ _('No lines are selected. You may want to activate'
+ ' "Print all "To send" lines."'))
if current.print_all:
filtered_ids = self._get_lids(cursor, uid, current.print_all, lines_ids, context)
else:
diff --git a/account_credit_control/wizard/credit_control_printer_view.xml b/account_credit_control/wizard/credit_control_printer_view.xml
index 4c1906c64..67176c0b9 100644
--- a/account_credit_control/wizard/credit_control_printer_view.xml
+++ b/account_credit_control/wizard/credit_control_printer_view.xml
@@ -7,7 +7,7 @@
form
@@ -33,14 +33,14 @@
id="open_credit_line_printer_wizard_menu_action"/>
- Print lines
+ Print Lines
credit.control.printer
credit.control.line
form
form
new
- Print all lines
+ Print selected lines