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.osv.osv import except_osv
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
|
|
||||||
class CreditControlMailer(TransientModel):
|
class CreditControlMailer(TransientModel):
|
||||||
"""Change the state of lines in mass"""
|
"""Send emails for each selected credit control lines."""
|
||||||
|
|
||||||
_name = "credit.control.mailer"
|
_name = "credit.control.mailer"
|
||||||
_description = """Mass credit line mailer"""
|
_description = """Mass credit line mailer"""
|
||||||
_rec_name = 'id'
|
_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):
|
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):
|
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')
|
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):
|
if isinstance(wiz_id, list):
|
||||||
wiz_id = wiz_id[0]
|
wiz_id = wiz_id[0]
|
||||||
current = self.browse(cursor, uid, wiz_id, context)
|
current = self.browse(cursor, uid, wiz_id, context)
|
||||||
lines_ids = context.get('active_ids')
|
lines_ids = context.get('active_ids')
|
||||||
|
|
||||||
if not lines_ids and not current.mail_all:
|
if not lines_ids and not current.mail_all:
|
||||||
raise except_osv(_('Not lines ids are selected'),
|
raise except_osv(_('Error'),
|
||||||
_('You may check "Mail all ready lines"'))
|
_('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)
|
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,
|
comms = comm_obj._generate_comm_from_credit_line_ids(cursor, uid, filtered_ids,
|
||||||
context=context)
|
context=context)
|
||||||
comm_obj._generate_mails(cursor, uid, comms, context=context)
|
comm_obj._generate_mails(cursor, uid, comms, context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ class CreditControlMarker(TransientModel):
|
|||||||
|
|
||||||
_name = "credit.control.marker"
|
_name = "credit.control.marker"
|
||||||
_description = """Mass 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')],
|
('sent', 'Done')],
|
||||||
'Mark as', required=True),
|
'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'}
|
_defaults = {'name': 'to_be_sent'}
|
||||||
|
|
||||||
@@ -49,27 +49,29 @@ class CreditControlMarker(TransientModel):
|
|||||||
line_obj = self.pool.get('credit.control.line')
|
line_obj = self.pool.get('credit.control.line')
|
||||||
if not state:
|
if not state:
|
||||||
raise ValueError(_('state can not be empty'))
|
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
|
return filtered_ids
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def mark_lines(self, cursor, uid, wiz_id, context=None):
|
def mark_lines(self, cursor, uid, wiz_id, context=None):
|
||||||
"""Write state of selected credit lines to the one in entry
|
"""Write state of selected credit lines to the one in entry
|
||||||
done credit line will be ignored"""
|
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):
|
if isinstance(wiz_id, list):
|
||||||
wiz_id = wiz_id[0]
|
wiz_id = wiz_id[0]
|
||||||
current = self.browse(cursor, uid, wiz_id, context)
|
current = self.browse(cursor, uid, wiz_id, context)
|
||||||
lines_ids = context.get('active_ids')
|
lines_ids = context.get('active_ids')
|
||||||
|
|
||||||
if not lines_ids and not current.mark_all:
|
if not lines_ids and not current.mark_all:
|
||||||
raise except_osv(_('Not lines ids are selected'),
|
raise except_osv(_('Error'),
|
||||||
_('You may check "Mark all draft lines"'))
|
_('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)
|
filtered_ids = self._get_lids(cursor, uid, current.mark_all, lines_ids, context)
|
||||||
if not filtered_ids:
|
if not filtered_ids:
|
||||||
raise except_osv(_('No lines will be changed'),
|
raise except_osv(_('Information'),
|
||||||
_('All selected lines are allready done'))
|
_('No lines will be changed. All the selected lines are already done'))
|
||||||
|
|
||||||
# hook function a simple write should be enought
|
# hook function a simple write should be enought
|
||||||
self._mark_lines(cursor, uid, filtered_ids, current.name, context)
|
self._mark_lines(cursor, uid, filtered_ids, current.name, context)
|
||||||
@@ -81,3 +83,4 @@ class CreditControlMarker(TransientModel):
|
|||||||
'view_id': False,
|
'view_id': False,
|
||||||
'res_model': 'credit.control.line',
|
'res_model': 'credit.control.line',
|
||||||
'type': 'ir.actions.act_window'}
|
'type': 'ir.actions.act_window'}
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form> <!-- editable="bottom" -->
|
<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/>
|
<newline/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="mark_all"/>
|
<field name="mark_all"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group colspan="4">
|
<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'/>
|
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
@@ -30,14 +30,14 @@
|
|||||||
id="open_credit_line_marker_wizard_menu_action"/>
|
id="open_credit_line_marker_wizard_menu_action"/>
|
||||||
|
|
||||||
<record id="open_credit_line_marker_wizard" model="ir.actions.act_window">
|
<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="res_model">credit.control.marker</field>
|
||||||
<field name="src_model">credit.control.line</field>
|
<field name="src_model">credit.control.line</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="view_id" ref="credit_line_marker_form"/>
|
<field name="view_id" ref="credit_line_marker_form"/>
|
||||||
<field name="target">new</field>
|
<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>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -30,12 +30,16 @@ class CreditControlPrinter(TransientModel):
|
|||||||
_name = "credit.control.printer"
|
_name = "credit.control.printer"
|
||||||
_rec_name = 'id'
|
_rec_name = 'id'
|
||||||
_description = """Mass printer"""
|
_description = """Mass printer"""
|
||||||
_columns = {'mark_as_sent': fields.boolean('Mark lines as send',
|
_columns = {'mark_as_sent': fields.boolean('Mark lines as sent',
|
||||||
help="Lines to emailed will be ignored"),
|
help="Only manual lines will be marked."),
|
||||||
'print_all': fields.boolean('Print all ready lines'),
|
'print_all': fields.boolean('Print all "To send" lines'),
|
||||||
'report_file': fields.binary('Generated Report'),
|
'report_file': fields.binary('Generated Report', readonly=True),
|
||||||
'state': fields.char('state', size=32)}
|
'state': fields.char('state', size=32)}
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'mark_as_sent': True,
|
||||||
|
}
|
||||||
|
|
||||||
def _get_lids(self, cursor, uid, print_all, active_ids, context=None):
|
def _get_lids(self, cursor, uid, print_all, active_ids, context=None):
|
||||||
"""get line to be marked filter done lines"""
|
"""get line to be marked filter done lines"""
|
||||||
# TODO Dry with mailer maybe in comm
|
# TODO Dry with mailer maybe in comm
|
||||||
@@ -52,14 +56,18 @@ class CreditControlPrinter(TransientModel):
|
|||||||
|
|
||||||
def print_lines(self, cursor, uid, wiz_id, context=None):
|
def print_lines(self, cursor, uid, wiz_id, context=None):
|
||||||
comm_obj = self.pool.get('credit.control.communication')
|
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):
|
if isinstance(wiz_id, list):
|
||||||
wiz_id = wiz_id[0]
|
wiz_id = wiz_id[0]
|
||||||
current = self.browse(cursor, uid, wiz_id, context)
|
current = self.browse(cursor, uid, wiz_id, context)
|
||||||
lines_ids = context.get('active_ids')
|
lines_ids = context.get('active_ids')
|
||||||
if not lines_ids and not current.print_all:
|
if not lines_ids and not current.print_all:
|
||||||
raise except_osv(_('Not lines ids are selected'),
|
raise except_osv(_('Error'),
|
||||||
_('You may check "Print all ready lines"'))
|
_('No lines are selected. You may want to activate'
|
||||||
|
' "Print all "To send" lines."'))
|
||||||
if current.print_all:
|
if current.print_all:
|
||||||
filtered_ids = self._get_lids(cursor, uid, current.print_all, lines_ids, context)
|
filtered_ids = self._get_lids(cursor, uid, current.print_all, lines_ids, context)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form> <!-- editable="bottom" -->
|
<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/>
|
<newline/>
|
||||||
<field name="mark_as_sent"/>
|
<field name="mark_as_sent"/>
|
||||||
<field name="print_all"/>
|
<field name="print_all"/>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<field name="state" invisible="1" />
|
<field name="state" invisible="1" />
|
||||||
<newline/>
|
<newline/>
|
||||||
<group colspan="4">
|
<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'/>
|
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
@@ -33,14 +33,14 @@
|
|||||||
id="open_credit_line_printer_wizard_menu_action"/>
|
id="open_credit_line_printer_wizard_menu_action"/>
|
||||||
|
|
||||||
<record id="open_credit_line_printer_wizard" model="ir.actions.act_window">
|
<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="res_model">credit.control.printer</field>
|
||||||
<field name="src_model">credit.control.line</field>
|
<field name="src_model">credit.control.line</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="view_id" ref="credit_line_printer_form"/>
|
<field name="view_id" ref="credit_line_printer_form"/>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="help">Print all lines</field>
|
<field name="help">Print selected lines</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user