mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP] wording of wizards and some cleanings (assert, context)
(lp:c2c-addons/6.1 rev 89.1.8)
This commit is contained in:
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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'}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form> <!-- editable="bottom" -->
|
||||
<separator string="This wizard will mark selected draft lines to the selected state. Done Lines will be ignored " colspan="4"/>
|
||||
<separator string="This wizard will change the state of the selected draft lines. Done Lines will be ignored " colspan="4"/>
|
||||
<newline/>
|
||||
<field name="name"/>
|
||||
<field name="mark_all"/>
|
||||
<newline/>
|
||||
<group colspan="4">
|
||||
<button name="mark_lines" string="Mark lines" type="object" icon="gtk-execute"/>
|
||||
<button name="mark_lines" string="Mark Lines" type="object" icon="gtk-execute"/>
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
</group>
|
||||
</form>
|
||||
@@ -30,14 +30,14 @@
|
||||
id="open_credit_line_marker_wizard_menu_action"/>
|
||||
|
||||
<record id="open_credit_line_marker_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Mark lines</field>
|
||||
<field name="name">Change Lines' State</field>
|
||||
<field name="res_model">credit.control.marker</field>
|
||||
<field name="src_model">credit.control.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="credit_line_marker_form"/>
|
||||
<field name="target">new</field>
|
||||
<field name="help">Mark all lines. You can the send marked lines</field>
|
||||
<field name="help">Change the state of the selected lines.</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form> <!-- editable="bottom" -->
|
||||
<separator colspan="4" string="This wizard will print all manual lines. Mark lines, lines will pass lines to state done. Lines with canal email will not be passed to state done"/>
|
||||
<separator colspan="4" string="This wizard will print the selected manual lines. Mark lines, lines will pass lines to state done. Lines with canal email will not be passed to state done"/>
|
||||
<newline/>
|
||||
<field name="mark_as_sent"/>
|
||||
<field name="print_all"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<field name="state" invisible="1" />
|
||||
<newline/>
|
||||
<group colspan="4">
|
||||
<button name="print_lines" string="Print lines" type="object" icon="gtk-execute"/>
|
||||
<button name="print_lines" string="Print Lines" type="object" icon="gtk-execute"/>
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
</group>
|
||||
</form>
|
||||
@@ -33,14 +33,14 @@
|
||||
id="open_credit_line_printer_wizard_menu_action"/>
|
||||
|
||||
<record id="open_credit_line_printer_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Print lines</field>
|
||||
<field name="name">Print Lines</field>
|
||||
<field name="res_model">credit.control.printer</field>
|
||||
<field name="src_model">credit.control.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="credit_line_printer_form"/>
|
||||
<field name="target">new</field>
|
||||
<field name="help">Print all lines</field>
|
||||
<field name="help">Print selected lines</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user