mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_credit_control: Migration to 7.0
This commit is contained in:
@@ -24,5 +24,5 @@ from . import account
|
||||
from . import partner
|
||||
from . import policy
|
||||
from . import company
|
||||
import wizard
|
||||
import report
|
||||
from . import wizard
|
||||
from . import report
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{'name' : 'Account Credit Control',
|
||||
'version' : '0.1',
|
||||
'author' : 'Camptocamp',
|
||||
{'name': 'Account Credit Control',
|
||||
'version': '0.1',
|
||||
'author': 'Camptocamp',
|
||||
'maintainer': 'Camptocamp',
|
||||
'category': 'Finance',
|
||||
'complexity': "normal",
|
||||
'depends' : ['base', 'account', 'email_template', 'report_webkit'],
|
||||
'depends': ['base', 'account',
|
||||
'email_template', 'report_webkit'],
|
||||
'description': """
|
||||
Credit Control
|
||||
==============
|
||||
@@ -57,8 +58,7 @@ On each generated line, you have many choices:
|
||||
* Change the state (so you can ignore or reopen lines)
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'init_xml': ["data.xml",
|
||||
],
|
||||
'init_xml': ["data.xml"],
|
||||
'update_xml': ["line_view.xml",
|
||||
"account_view.xml",
|
||||
"partner_view.xml",
|
||||
@@ -69,12 +69,10 @@ On each generated line, you have many choices:
|
||||
"wizard/credit_control_marker_view.xml",
|
||||
"wizard/credit_control_printer_view.xml",
|
||||
"report/report.xml",
|
||||
"security/ir.model.access.csv",
|
||||
],
|
||||
"security/ir.model.access.csv",],
|
||||
'demo_xml': ["credit_control_demo.xml"],
|
||||
'tests': [],
|
||||
'installable': True,
|
||||
'license': 'AGPL-3',
|
||||
'application': True
|
||||
}
|
||||
|
||||
|
||||
@@ -18,42 +18,39 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv.orm import Model, fields
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class AccountAccount(Model):
|
||||
class AccountAccount(orm.Model):
|
||||
"""Add a link to a credit control policy on account.account"""
|
||||
|
||||
_inherit = "account.account"
|
||||
|
||||
_columns = {
|
||||
'credit_control_line_ids': fields.one2many('credit.control.line',
|
||||
'account_id',
|
||||
string='Credit Lines',
|
||||
readonly=True)
|
||||
}
|
||||
_columns = {'credit_control_line_ids': fields.one2many('credit.control.line',
|
||||
'account_id',
|
||||
string='Credit Lines',
|
||||
readonly=True)
|
||||
}
|
||||
|
||||
|
||||
class AccountInvoice(Model):
|
||||
class AccountInvoice(orm.Model):
|
||||
"""Add a link to a credit control policy on account.account"""
|
||||
|
||||
_inherit = "account.invoice"
|
||||
_columns = {
|
||||
'credit_policy_id': fields.many2one('credit.control.policy',
|
||||
'Credit Control Policy',
|
||||
help=("The Credit Control Policy "
|
||||
"used for this invoice. "
|
||||
"If nothing is defined, "
|
||||
"it will use the account "
|
||||
"setting or the partner "
|
||||
"setting.")),
|
||||
_columns = {'credit_policy_id': fields.many2one('credit.control.policy',
|
||||
'Credit Control Policy',
|
||||
help=("The Credit Control Policy "
|
||||
"used for this invoice. "
|
||||
"If nothing is defined, "
|
||||
"it will use the account "
|
||||
"setting or the partner "
|
||||
"setting.")),
|
||||
|
||||
'credit_control_line_ids': fields.one2many('credit.control.line',
|
||||
'invoice_id',
|
||||
string='Credit Lines',
|
||||
readonly=True)
|
||||
}
|
||||
'credit_control_line_ids': fields.one2many('credit.control.line',
|
||||
'invoice_id',
|
||||
string='Credit Lines',
|
||||
readonly=True)
|
||||
}
|
||||
|
||||
def action_move_create(self, cr, uid, ids, context=None):
|
||||
""" Write the id of the invoice in the generated moves. """
|
||||
@@ -65,9 +62,8 @@ class AccountInvoice(Model):
|
||||
return res
|
||||
|
||||
|
||||
class AccountMoveLine(Model):
|
||||
class AccountMoveLine(orm.Model):
|
||||
|
||||
_inherit = "account.move.line"
|
||||
|
||||
_columns = {'invoice_id': fields.many2one('account.invoice', 'Invoice')}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Credit Control"
|
||||
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,group_account_credit_control_info">
|
||||
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info">
|
||||
<field name="credit_policy_id" widget="selection"/>
|
||||
<newline/>
|
||||
<field name="credit_control_line_ids" colspan="4" nolabel="1"/>
|
||||
|
||||
@@ -18,23 +18,21 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.osv.orm import Model, fields
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class ResCompany(Model):
|
||||
|
||||
class ResCompany(orm.Model):
|
||||
"""Add credit control parameters"""
|
||||
_inherit = 'res.company'
|
||||
|
||||
_columns = {
|
||||
'credit_control_tolerance': fields.float('Credit Control Tolerance'),
|
||||
# This is not a property on the partner because we cannot search
|
||||
# on fields.property (subclass fields.function).
|
||||
'credit_policy_id': fields.many2one(
|
||||
'credit.control.policy',
|
||||
'Credit Control Policy',
|
||||
help=("The Credit Control Policy used on partners by default. This "
|
||||
"setting can be overriden on partners or invoices.")),
|
||||
}
|
||||
_columns = {'credit_control_tolerance': fields.float('Credit Control Tolerance'),
|
||||
# This is not a property on the partner because we cannot search
|
||||
# on fields.property (subclass fields.function).
|
||||
'credit_policy_id': fields.many2one('credit.control.policy',
|
||||
'Credit Control Policy',
|
||||
help=("The Credit Control Policy used on partners"
|
||||
" by default. This setting can be overriden"
|
||||
" on partners or invoices.")),
|
||||
}
|
||||
|
||||
_defaults = {"credit_control_tolerance": 0.1}
|
||||
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
#
|
||||
##############################################################################
|
||||
import logging
|
||||
import pooler
|
||||
|
||||
from openerp.osv.orm import Model, fields
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.osv import osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
logger = logging.getLogger('credit.line.control')
|
||||
|
||||
|
||||
class CreditControlLine(Model):
|
||||
class CreditControlLine(orm.Model):
|
||||
"""A credit control line describes an amount due by a customer for a due date.
|
||||
|
||||
A line is created once the due date of the payment is exceeded.
|
||||
@@ -67,10 +66,10 @@ class CreditControlLine(Model):
|
||||
"generated again on the next run.")),
|
||||
|
||||
'channel': fields.selection([('letter', 'Letter'),
|
||||
('email', 'Email')],
|
||||
'Channel', required=True,
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
('email', 'Email')],
|
||||
'Channel', required=True,
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
|
||||
'invoice_id': fields.many2one('account.invoice', 'Invoice', readonly=True),
|
||||
'partner_id': fields.many2one('res.partner', "Partner", required=True),
|
||||
@@ -193,4 +192,3 @@ class CreditControlLine(Model):
|
||||
'is not in draft state.'))
|
||||
|
||||
return super(CreditControlLine, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
<record id="credit_control_line_search" model="ir.ui.view">
|
||||
<field name="name">Credit Control Lines</field>
|
||||
<field name="model">credit.control.lines</field>
|
||||
<field name="model">credit.control.line</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Control Credit Lines">
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.osv.orm import Model, fields
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class ResPartner(Model):
|
||||
class ResPartner(orm.Model):
|
||||
"""Add a settings on the credit control policy to use on the partners,
|
||||
and links to the credit control lines."""
|
||||
|
||||
@@ -30,15 +30,14 @@ class ResPartner(Model):
|
||||
_columns = {
|
||||
'credit_policy_id': fields.many2one('credit.control.policy',
|
||||
'Credit Control Policy',
|
||||
help=("The Credit Control Policy"
|
||||
"used for this partner. This "
|
||||
"setting can be forced on the "
|
||||
"invoice. If nothing is defined, "
|
||||
"it will use the company "
|
||||
"setting.")),
|
||||
help=("The Credit Control Policy"
|
||||
"used for this partner. This "
|
||||
"setting can be forced on the "
|
||||
"invoice. If nothing is defined, "
|
||||
"it will use the company "
|
||||
"setting.")),
|
||||
'credit_control_line_ids': fields.one2many('credit.control.line',
|
||||
'invoice_id',
|
||||
string='Credit Control Lines',
|
||||
readonly=True)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,21 +30,21 @@ class CreditControlPolicy(Model):
|
||||
_columns = {'name': fields.char('Name', required=True, size=128),
|
||||
|
||||
'level_ids': fields.one2many('credit.control.policy.level',
|
||||
'policy_id',
|
||||
'Policy Levels'),
|
||||
'policy_id',
|
||||
'Policy Levels'),
|
||||
|
||||
'do_nothing': fields.boolean('Do nothing',
|
||||
help=('For policies which should not '
|
||||
'generate lines or are obsolete')),
|
||||
help=('For policies which should not '
|
||||
'generate lines or are obsolete')),
|
||||
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
|
||||
'account_ids': fields.many2many(
|
||||
'account.account',
|
||||
string='Accounts',
|
||||
required=True,
|
||||
domain="[('reconcile', '=', True)]",
|
||||
help='This policy will be active only for the selected accounts'),
|
||||
'account_ids': fields.many2many('account.account',
|
||||
string='Accounts',
|
||||
required=True,
|
||||
domain="[('reconcile', '=', True)]",
|
||||
help="This policy will be active only"
|
||||
" for the selected accounts"),
|
||||
}
|
||||
|
||||
def _move_lines_domain(self, cr, uid, policy, controlling_date, context=None):
|
||||
@@ -71,13 +71,12 @@ class CreditControlPolicy(Model):
|
||||
if user.company_id.credit_policy_id.id != policy.id:
|
||||
return set()
|
||||
|
||||
return set(move_l_obj.search(
|
||||
cr, uid,
|
||||
self._move_lines_domain(cr, uid, policy, controlling_date, context=context),
|
||||
context=context))
|
||||
domain_line = self._move_lines_domain(cr, uid, policy,
|
||||
controlling_date, context=context)
|
||||
return set(move_l_obj.search(cr, uid, domain_line, context=context))
|
||||
|
||||
def _move_lines_subset(self, cr, uid, policy, controlling_date,
|
||||
model, move_relation_field, context=None):
|
||||
model, move_relation_field, context=None):
|
||||
""" Get the move lines related to one model for a policy.
|
||||
|
||||
Do not use direct SQL in order to respect security rules.
|
||||
@@ -139,9 +138,8 @@ class CreditControlPolicy(Model):
|
||||
:return: set of ids to add in the process, set of ids to remove from
|
||||
the process
|
||||
"""
|
||||
return self._move_lines_subset(
|
||||
cr, uid, policy, controlling_date,
|
||||
'res.partner', 'partner_id', context=context)
|
||||
return self._move_lines_subset(cr, uid, policy, controlling_date,
|
||||
'res.partner', 'partner_id', context=context)
|
||||
|
||||
def _get_invoice_related_lines(self, cr, uid, policy, controlling_date, context=None):
|
||||
""" Get the move lines for a policy related to an invoice.
|
||||
@@ -154,9 +152,8 @@ class CreditControlPolicy(Model):
|
||||
:return: set of ids to add in the process, set of ids to remove from
|
||||
the process
|
||||
"""
|
||||
return self._move_lines_subset(
|
||||
cr, uid, policy, controlling_date,
|
||||
'account.invoice', 'invoice', context=context)
|
||||
return self._move_lines_subset(cr, uid, policy, controlling_date,
|
||||
'account.invoice', 'invoice', context=context)
|
||||
|
||||
def _get_move_lines_to_process(self, cr, uid, policy_id, controlling_date, context=None):
|
||||
"""Build a list of move lines ids to include in a run for a policy at a given date.
|
||||
@@ -173,13 +170,14 @@ class CreditControlPolicy(Model):
|
||||
policy = self.browse(cr, uid, policy_id, context=context)
|
||||
# there is a priority between the lines, depicted by the calls below
|
||||
# warning, side effect method called on lines
|
||||
lines = self._due_move_lines(
|
||||
cr, uid, policy, controlling_date, context=context)
|
||||
add_ids, remove_ids = self._get_partner_related_lines(
|
||||
cr, uid, policy, controlling_date, context=context)
|
||||
lines = self._due_move_lines(cr, uid, policy, controlling_date, context=context)
|
||||
add_ids, remove_ids = self._get_partner_related_lines(cr, uid, policy,
|
||||
controlling_date,
|
||||
context=context)
|
||||
lines = lines.union(add_ids).difference(remove_ids)
|
||||
add_ids, remove_ids = self._get_invoice_related_lines(
|
||||
cr, uid, policy, controlling_date, context=context)
|
||||
add_ids, remove_ids = self._get_invoice_related_lines(cr, uid, policy,
|
||||
controlling_date,
|
||||
context=context)
|
||||
lines = lines.union(add_ids).difference(remove_ids)
|
||||
return lines
|
||||
|
||||
@@ -195,8 +193,8 @@ class CreditControlPolicy(Model):
|
||||
if isinstance(policy_id, list):
|
||||
policy_id = policy_id[0]
|
||||
cr.execute("SELECT move_line_id FROM credit_control_line"
|
||||
" WHERE policy_id != %s and move_line_id in %s",
|
||||
(policy_id, tuple(lines)))
|
||||
" WHERE policy_id != %s and move_line_id in %s",
|
||||
(policy_id, tuple(lines)))
|
||||
res = cr.fetchall()
|
||||
if res:
|
||||
different_lines.update([x[0] for x in res])
|
||||
@@ -224,10 +222,10 @@ class CreditControlPolicyLevel(Model):
|
||||
|
||||
'delay_days': fields.integer('Delay (in days)', required='True'),
|
||||
'email_template_id': fields.many2one('email.template', 'Email Template',
|
||||
required=True),
|
||||
required=True),
|
||||
'channel': fields.selection([('letter', 'Letter'),
|
||||
('email', 'Email')],
|
||||
'Channel', required=True),
|
||||
('email', 'Email')],
|
||||
'Channel', required=True),
|
||||
'custom_text': fields.text('Custom Message', required=True, translate=True),
|
||||
}
|
||||
|
||||
@@ -314,9 +312,11 @@ class CreditControlPolicyLevel(Model):
|
||||
# lines from a previous level with a draft or ignored state
|
||||
# have to be generated again for the previous level
|
||||
" AND state not in ('draft', 'ignored'))")
|
||||
sql += " AND" + self._get_sql_date_boundary_for_computation_mode(
|
||||
cr, uid, level, controlling_date, context)
|
||||
data_dict = {'controlling_date': controlling_date, 'line_ids': tuple(lines),
|
||||
sql += " AND"
|
||||
sql += self._get_sql_date_boundary_for_computation_mode(cr, uid, level,
|
||||
controlling_date, context)
|
||||
data_dict = {'controlling_date': controlling_date,
|
||||
'line_ids': tuple(lines),
|
||||
'delay': level.delay_days}
|
||||
|
||||
cr.execute(sql, data_dict)
|
||||
@@ -343,14 +343,15 @@ class CreditControlPolicyLevel(Model):
|
||||
# have to be generated again for the previous level
|
||||
" AND cr_line.state not in ('draft', 'ignored')\n"
|
||||
" AND mv_line.id in %(line_ids)s\n")
|
||||
sql += " AND " + self._get_sql_date_boundary_for_computation_mode(
|
||||
cr, uid, level, controlling_date, context)
|
||||
previous_level_id = self._previous_level(
|
||||
cr, uid, level, context=context)
|
||||
previous_level = self.browse(
|
||||
cr, uid, previous_level_id, context=context)
|
||||
data_dict = {'controlling_date': controlling_date, 'line_ids': tuple(lines),
|
||||
'delay': level.delay_days, 'previous_level': previous_level.level}
|
||||
sql += " AND "
|
||||
sql += self._get_sql_date_boundary_for_computation_mode(cr, uid, level,
|
||||
controlling_date, context)
|
||||
previous_level_id = self._previous_level(cr, uid, level, context=context)
|
||||
previous_level = self.browse(cr, uid, previous_level_id, context=context)
|
||||
data_dict = {'controlling_date': controlling_date,
|
||||
'line_ids': tuple(lines),
|
||||
'delay': level.delay_days,
|
||||
'previous_level': previous_level.level}
|
||||
|
||||
# print cr.mogrify(sql, data_dict)
|
||||
cr.execute(sql, data_dict)
|
||||
@@ -371,9 +372,7 @@ class CreditControlPolicyLevel(Model):
|
||||
method = self._get_first_level_move_line_ids
|
||||
else:
|
||||
method = self._get_other_level_move_line_ids
|
||||
|
||||
matching_lines.update(
|
||||
method(cr, uid, level, controlling_date, lines, context=context))
|
||||
|
||||
matching_lines.update(method(cr, uid, level,
|
||||
controlling_date, lines,
|
||||
context=context))
|
||||
return matching_lines
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<field name="model">credit.control.policy</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Credit control policy">
|
||||
<field name="name"/>
|
||||
<field name="do_nothing"/>
|
||||
<field name="company_id"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Policy Levels">
|
||||
<page string="Policy levels">
|
||||
<field name="level_ids" nolabel="1" colspan="4" >
|
||||
<tree>
|
||||
<tree string="Credit control policy Level">
|
||||
<field name="name"/>
|
||||
<field name="level"/>
|
||||
<field name="channel"/>
|
||||
@@ -21,7 +21,7 @@
|
||||
<field name="computation_mode"/>
|
||||
<field name="email_template_id"/>
|
||||
</tree>
|
||||
<form>
|
||||
<form string="Policy level">
|
||||
<field name="name"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Delay Setting">
|
||||
@@ -51,7 +51,7 @@
|
||||
<field name="model">credit.control.policy</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<tree string="Credit control policy">
|
||||
<field name="name"/>
|
||||
<field name="do_nothing"/>
|
||||
</tree>
|
||||
@@ -84,7 +84,7 @@
|
||||
<field name="model">credit.control.policy.level</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Policy level">
|
||||
<field name="name"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Delay Setting">
|
||||
@@ -107,7 +107,7 @@
|
||||
<field name="model">credit.control.policy.level</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<tree string="Credit control policy level">
|
||||
<field name="name"/>
|
||||
<field name="level"/>
|
||||
<field name="channel"/>
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
##############################################################################
|
||||
import logging
|
||||
|
||||
from openerp.osv.orm import Model, fields
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv.osv import except_osv
|
||||
|
||||
logger = logging.getLogger('credit.control.run')
|
||||
|
||||
|
||||
class CreditControlRun(Model):
|
||||
class CreditControlRun(orm.Model):
|
||||
"""Credit Control run generate all credit control lines and reject"""
|
||||
|
||||
_name = "credit.control.run"
|
||||
@@ -36,39 +36,34 @@ class CreditControlRun(Model):
|
||||
_columns = {
|
||||
'date': fields.date('Controlling Date', required=True),
|
||||
'policy_ids': fields.many2many('credit.control.policy',
|
||||
rel="credit_run_policy_rel",
|
||||
id1='run_id', id2='policy_id',
|
||||
string='Policies',
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
rel="credit_run_policy_rel",
|
||||
id1='run_id', id2='policy_id',
|
||||
string='Policies',
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
|
||||
'report': fields.text('Report', readonly=True),
|
||||
|
||||
'state': fields.selection([('draft', 'Draft'),
|
||||
('done', 'Done'),
|
||||
],
|
||||
string='State',
|
||||
required=True,
|
||||
readonly=True),
|
||||
('done', 'Done')],
|
||||
string='State',
|
||||
required=True,
|
||||
readonly=True),
|
||||
|
||||
'manual_ids': fields.many2many(
|
||||
'account.move.line',
|
||||
rel="credit_runreject_rel",
|
||||
string='Lines to handle manually',
|
||||
help=('If a credit control line has been generated on a policy '
|
||||
'and the policy has been changed meantime, '
|
||||
'it has to be handled manually'),
|
||||
readonly=True),
|
||||
'manual_ids': fields.many2many('account.move.line',
|
||||
rel="credit_runreject_rel",
|
||||
string='Lines to handle manually',
|
||||
help=('If a credit control line has been generated on a policy'
|
||||
' and the policy has been changed meantime,'
|
||||
' it has to be handled manually'),
|
||||
readonly=True),
|
||||
}
|
||||
|
||||
def _get_policies(self, cr, uid, context=None):
|
||||
return self.pool.get('credit.control.policy').\
|
||||
search(cr, uid, [], context=context)
|
||||
return self.pool['credit.control.policy'].search(cr, uid, [], context=context)
|
||||
|
||||
_defaults = {
|
||||
'state': 'draft',
|
||||
'policy_ids': _get_policies,
|
||||
}
|
||||
_defaults = {'state': 'draft',
|
||||
'policy_ids': _get_policies}
|
||||
|
||||
def _check_run_date(self, cr, uid, ids, controlling_date, context=None):
|
||||
"""Ensure that there is no credit line in the future using controlling_date"""
|
||||
@@ -86,7 +81,7 @@ class CreditControlRun(Model):
|
||||
""" Generate credit control lines. """
|
||||
cr_line_obj = self.pool.get('credit.control.line')
|
||||
assert not (isinstance(run_id, list) and len(run_id) > 1), \
|
||||
"run_id: only one id expected"
|
||||
"run_id: only one id expected"
|
||||
if isinstance(run_id, list):
|
||||
run_id = run_id[0]
|
||||
|
||||
@@ -140,14 +135,12 @@ class CreditControlRun(Model):
|
||||
"""
|
||||
try:
|
||||
cr.execute('SELECT id FROM credit_control_run'
|
||||
' LIMIT 1 FOR UPDATE NOWAIT' )
|
||||
except Exception, exc:
|
||||
' LIMIT 1 FOR UPDATE NOWAIT')
|
||||
except Exception as exc:
|
||||
# in case of exception openerp will do a rollback for us and free the lock
|
||||
raise except_osv(
|
||||
_('Error'),
|
||||
_('A credit control run is already running'
|
||||
' in background, please try later.'), str(exc))
|
||||
raise except_osv(_('Error'),
|
||||
_('A credit control run is already running'
|
||||
' in background, please try later.'), repr(exc))
|
||||
|
||||
self._generate_credit_lines(cr, uid, run_id, context)
|
||||
return True
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">credit.control.run</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree> <!-- editable="bottom" -->
|
||||
<tree string="Credit control run"> <!-- editable="bottom" -->
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
@@ -18,7 +18,7 @@
|
||||
<field name="model">credit.control.run</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Credit control run">
|
||||
<field name="date"/>
|
||||
<newline/>
|
||||
<notebook colspan="4">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">credit.control.emailer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Mailer">
|
||||
<separator string="Send emails for the selected lines" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="line_ids" colspan="4" nolabel="1" />
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">credit.control.marker</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Lines marker">
|
||||
<separator string="Change the state of the selected lines." colspan="4"/>
|
||||
<label string="Warning: you will maybe not be able to revert this operation." colspan="4"></label>
|
||||
<newline/>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">credit.control.printer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<form string="Lines report">
|
||||
<separator colspan="4" string="Print the selected lines"/>
|
||||
<newline/>
|
||||
<field name="mark_as_sent" colspan="4" attrs="{'invisible': [('state', '=', 'done')]}"/>
|
||||
|
||||
Reference in New Issue
Block a user