diff --git a/account_credit_control/account.py b/account_credit_control/account.py index 5fc7a8418..3eaf23950 100644 --- a/account_credit_control/account.py +++ b/account_credit_control/account.py @@ -20,45 +20,53 @@ ############################################################################## from openerp.osv import orm, fields - 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(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.")), - - 'credit_control_line_ids': fields.one2many('credit.control.line', - 'invoice_id', - string='Credit Lines', - readonly=True) - } + _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), + } def action_move_create(self, cr, uid, ids, context=None): """ Write the id of the invoice in the generated moves. """ - res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=context) - for inv in self.browse(cr, uid, ids, context=context): + if context is None: + context = {} + # add from_parent_object to the conxtext to let the line.write + # call pass through account_constraints + ctxt = context.copy() + ctxt['from_parent_object'] = True + res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=ctxt) + for inv in self.browse(cr, uid, ids, context=ctxt): if inv.move_id: for line in inv.move_id.line_id: - line.write({'invoice_id': inv.id}) + line.write({'invoice_id': inv.id}, context=ctxt) return res diff --git a/account_credit_control/data.xml b/account_credit_control/data.xml index 8b3f1b772..9d284fa75 100644 --- a/account_credit_control/data.xml +++ b/account_credit_control/data.xml @@ -57,7 +57,7 @@
Thank you for choosing ${object.company_id.name}!
-- more info here -- -${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
+
${object.user_id.name} ${object.user_id.email and '<%s>'%(object.user_id.email) or ''}
${object.company_id.name}
% if object.company_id.street:
${object.company_id.street or ''}
diff --git a/account_credit_control/line.py b/account_credit_control/line.py
index 46ce0a35b..fb05ac295 100644
--- a/account_credit_control/line.py
+++ b/account_credit_control/line.py
@@ -186,7 +186,7 @@ class CreditControlLine(orm.Model):
def unlink(self, cr, uid, ids, context=None, check=True):
for line in self.browse(cr, uid, ids, context=context):
if line.state != 'draft':
- raise osv.except_osv(
+ raise orm.except_orm(
_('Error !'),
_('You are not allowed to delete a credit control line that '
'is not in draft state.'))
diff --git a/account_credit_control/partner.py b/account_credit_control/partner.py
index 8d66428b6..57e88561d 100644
--- a/account_credit_control/partner.py
+++ b/account_credit_control/partner.py
@@ -28,16 +28,16 @@ class ResPartner(orm.Model):
_inherit = "res.partner"
_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.")),
- 'credit_control_line_ids': fields.one2many('credit.control.line',
- 'invoice_id',
- string='Credit Control Lines',
- readonly=True)
+ '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.")),
+ 'credit_control_line_ids':
+ fields.one2many('credit.control.line',
+ 'invoice_id',
+ string='Credit Control Lines',
+ readonly=True)
}
diff --git a/account_credit_control/run.py b/account_credit_control/run.py
index 1f86447a4..656de6bd4 100644
--- a/account_credit_control/run.py
+++ b/account_credit_control/run.py
@@ -22,7 +22,6 @@ import logging
from openerp.osv import orm, fields
from openerp.tools.translate import _
-from openerp.osv.osv import except_osv
logger = logging.getLogger('credit.control.run')
@@ -35,12 +34,13 @@ class CreditControlRun(orm.Model):
_description = """Credit control line generator"""
_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)]}),
+ '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)]}),
'report': fields.text('Report', readonly=True),
@@ -50,14 +50,16 @@ class CreditControlRun(orm.Model):
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 '
+ 'in the meantime, it has to be handled '
+ 'manually'),
+ readonly=True),
+ }
def _get_policies(self, cr, uid, context=None):
return self.pool['credit.control.policy'].search(cr, uid, [], context=context)
@@ -72,9 +74,9 @@ class CreditControlRun(orm.Model):
order='date DESC', limit=1, context=context)
if lines:
line = line_obj.browse(cr, uid, lines[0], context=context)
- raise except_osv(
- _('Error'),
- _('A run has already been executed more recently than %s') % (line.date))
+ raise orm.except_orm(_('Error'),
+ _('A run has already been executed more '
+ 'recently than %s') % (line.date))
return True
def _generate_credit_lines(self, cr, uid, run_id, context=None):
@@ -92,9 +94,8 @@ class CreditControlRun(orm.Model):
policies = run.policy_ids
if not policies:
- raise except_osv(
- _('Error'),
- _('Please select a policy'))
+ raise orm.except_orm(_('Error'),
+ _('Please select a policy'))
report = ''
for policy in policies:
@@ -137,9 +138,9 @@ class CreditControlRun(orm.Model):
' 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.'), repr(exc))
+ raise orm.except_orm(_('Error'),
+ _('A credit control run is already running'
+ ' in background, please try later.'))
self._generate_credit_lines(cr, uid, run_id, context)
return True
diff --git a/account_credit_control/wizard/credit_control_emailer.py b/account_credit_control/wizard/credit_control_emailer.py
index c0ca50bf6..f0d3f7c6d 100644
--- a/account_credit_control/wizard/credit_control_emailer.py
+++ b/account_credit_control/wizard/credit_control_emailer.py
@@ -19,12 +19,11 @@
#
##############################################################################
-from openerp.osv.orm import TransientModel, fields
-from openerp.osv.osv import except_osv
+from openerp.osv import orm, fields
from openerp.tools.translate import _
-class CreditControlEmailer(TransientModel):
+class CreditControlEmailer(orm.TransientModel):
"""Send emails for each selected credit control lines."""
_name = "credit.control.emailer"
@@ -71,7 +70,7 @@ class CreditControlEmailer(TransientModel):
form = self.browse(cr, uid, wiz_id, context)
if not form.line_ids:
- raise except_osv(_('Error'), _('No credit control lines selected.'))
+ raise orm.except_orm(_('Error'), _('No credit control lines selected.'))
line_ids = [l.id for l in form.line_ids]
filtered_ids = self._filter_line_ids(
diff --git a/account_credit_control/wizard/credit_control_marker.py b/account_credit_control/wizard/credit_control_marker.py
index b79098f9e..a458ab394 100644
--- a/account_credit_control/wizard/credit_control_marker.py
+++ b/account_credit_control/wizard/credit_control_marker.py
@@ -18,12 +18,11 @@
# along with this program. If not, see