mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] cut some long lines, remove trailing whitespaces, indentation
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
from openerp.osv import fields, orm, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class AccountMove(orm.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
@@ -46,9 +47,10 @@ class AccountMoveLine(orm.Model):
|
||||
def _check_invoice_related_move(self, cr, uid, ids, context=None):
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if line.invoice:
|
||||
err_msg = _('Invoice name (id): %s (%s)') % (line.invoice.name, str(line.invoice.id))
|
||||
err_msg = _('Invoice name (id): %s (%s)') %
|
||||
(line.invoice.name, str(line.invoice.id))
|
||||
raise osv.except_osv(
|
||||
_('Error'),
|
||||
_('Error'),
|
||||
_('You cannot do this on an entry generated by an invoice. You must '
|
||||
'change the related invoice directly.\n%s.') % err_msg)
|
||||
return True
|
||||
@@ -56,22 +58,25 @@ class AccountMoveLine(orm.Model):
|
||||
def _check_statement_related_move(self, cr, uid, ids, context=None):
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if line.statement_id:
|
||||
err_msg = _('Bank statement name (id): %s (%s)') % (line.statement_id.name, str(line.statement_id.id))
|
||||
err_msg = _('Bank statement name (id): %s (%s)') %
|
||||
(line.statement_id.name, str(line.statement_id.id))
|
||||
raise osv.except_osv(
|
||||
_('Error'),
|
||||
_('Error'),
|
||||
_('You cannot do this on an entry generated by a bank statement. '
|
||||
'You must change the related bank statement directly.\n%s.') % err_msg)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None, check=True):
|
||||
""" Add the following checks:
|
||||
- Is the move related to an invoice
|
||||
- Is the move related to a bank statement
|
||||
In that case, we forbid the move to be deleted even if draft. We should
|
||||
never delete directly a move line related or generated by another object.
|
||||
This is mandatory if you use the module setting all moves in draft
|
||||
(module: account_default_draft_move)
|
||||
"""
|
||||
|
||||
- Is the move related to an invoice
|
||||
- Is the move related to a bank statement
|
||||
|
||||
In that case, we forbid the move to be deleted even if draft. We
|
||||
should never delete directly a move line related or generated by
|
||||
another object. This is mandatory if you use the module setting
|
||||
all moves in draft (module: account_default_draft_move)
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
if not context.get('from_parent_object', False):
|
||||
@@ -81,13 +86,15 @@ class AccountMoveLine(orm.Model):
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
|
||||
""" Add the following checks:
|
||||
- Is the move related to an invoice
|
||||
- Is the move related to a bank statement
|
||||
In that case, we forbid the move to be modified even if draft. We should
|
||||
never update directly a move line related or generated by another object.
|
||||
This is mandatory if you use the module setting all moves in draft
|
||||
(module: account_default_draft_move)
|
||||
"""
|
||||
|
||||
- Is the move related to an invoice
|
||||
- Is the move related to a bank statement
|
||||
|
||||
In that case, we forbid the move to be modified even if draft.
|
||||
We should never update directly a move line related or generated
|
||||
by another object. This is mandatory if you use the module
|
||||
setting all moves in draft (module: account_default_draft_move)
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
if not context.get('from_parent_object', False):
|
||||
@@ -139,11 +146,12 @@ class AccountMoveLine(orm.Model):
|
||||
|
||||
class AccountInvoice(orm.Model):
|
||||
_inherit = "account.invoice"
|
||||
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
"""Override the method to add the key 'from_parent_object' in
|
||||
the context. This is to allow to delete move line related to invoice
|
||||
through the cancel button."""
|
||||
the context. This is to allow to delete move line related to
|
||||
invoice through the cancel button.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
else:
|
||||
@@ -167,8 +175,9 @@ class AccountBankStatement(orm.Model):
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context=None):
|
||||
"""Override the method to add the key 'from_parent_object' in
|
||||
the context. This is to allow to delete move line related to bank statement
|
||||
through the cancel button."""
|
||||
the context. This is to allow to delete move line related to
|
||||
bank statement through the cancel button.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
else:
|
||||
@@ -176,13 +185,16 @@ class AccountBankStatement(orm.Model):
|
||||
context['from_parent_object'] = True
|
||||
return super(AccountBankStatement, self).button_cancel(cr, uid, ids, context=context)
|
||||
|
||||
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
|
||||
"""Add the from_parent_object key in context in order to be able to post the move."""
|
||||
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id,
|
||||
st_line_number, context=None):
|
||||
"""Add the from_parent_object key in context in order to be able
|
||||
to post the move.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
else:
|
||||
context = context.copy()
|
||||
context['from_parent_object'] = True
|
||||
return super(AccountBankStatement, self).create_move_from_st_line(cr, uid,
|
||||
st_line_id, company_currency_id, st_line_number, context=context)
|
||||
|
||||
return super(AccountBankStatement, self).create_move_from_st_line(
|
||||
cr, uid, st_line_id, company_currency_id,
|
||||
st_line_number, context=context)
|
||||
|
||||
Reference in New Issue
Block a user