mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Fix Flake8 errors and reformat code using orm instead of osv
This commit is contained in:
committed by
Sandy Carter
parent
137d1c3244
commit
19dd21fd4a
@@ -21,12 +21,12 @@
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
import decimal_precision as dp
|
||||
|
||||
|
||||
class deposit_method(osv.osv):
|
||||
class deposit_method(orm.Model):
|
||||
_name = "deposit.method"
|
||||
_description = "Deposit Method"
|
||||
_columns = {
|
||||
@@ -38,10 +38,7 @@ class deposit_method(osv.osv):
|
||||
}
|
||||
|
||||
|
||||
deposit_method()
|
||||
|
||||
|
||||
class deposit_ticket(osv.osv):
|
||||
class deposit_ticket(orm.Model):
|
||||
_name = "deposit.ticket"
|
||||
_description = "Deposit Ticket"
|
||||
|
||||
@@ -74,7 +71,7 @@ class deposit_ticket(osv.osv):
|
||||
)
|
||||
group_user_ids = [user.id for user in group_verifier.users]
|
||||
if deposit.state != 'draft' and uid not in group_user_ids:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('User Error'),
|
||||
_(
|
||||
"Only a member of '%s' group may delete/edit "
|
||||
@@ -124,12 +121,12 @@ class deposit_ticket(osv.osv):
|
||||
move_lines = []
|
||||
for deposit in self.browse(cr, uid, ids, context=context):
|
||||
if not deposit.journal_id.sequence_id:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('Error !'),
|
||||
_('Please define sequence on deposit journal')
|
||||
)
|
||||
if deposit.journal_id.centralisation:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('UserError'),
|
||||
_('Cannot create move on centralised journal')
|
||||
)
|
||||
@@ -438,10 +435,7 @@ class deposit_ticket(osv.osv):
|
||||
}
|
||||
|
||||
|
||||
deposit_ticket()
|
||||
|
||||
|
||||
class deposit_ticket_line(osv.osv):
|
||||
class deposit_ticket_line(orm.Model):
|
||||
_name = "deposit.ticket.line"
|
||||
_description = "Deposit Ticket Line"
|
||||
_columns = {
|
||||
@@ -496,7 +490,7 @@ class deposit_ticket_line(osv.osv):
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
# Any Line cannot be manually added. Use the wizard to add lines.
|
||||
if not vals.get('move_line_id', False):
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('Processing Error'),
|
||||
_(
|
||||
'You cannot add any new deposit ticket line '
|
||||
@@ -523,6 +517,3 @@ class deposit_ticket_line(osv.osv):
|
||||
return super(deposit_ticket_line, self).unlink(
|
||||
cr, uid, ids, context=context
|
||||
)
|
||||
|
||||
|
||||
deposit_ticket_line()
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
from osv import osv, fields
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
class account_move_line(orm.Model):
|
||||
_inherit = 'account.move.line'
|
||||
_columns = {
|
||||
'draft_assigned': fields.boolean(
|
||||
@@ -38,5 +38,3 @@ class account_move_line(osv.osv):
|
||||
'Deposit Ticket'
|
||||
)
|
||||
}
|
||||
|
||||
account_move_line()
|
||||
|
||||
@@ -20,12 +20,9 @@
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from report import report_sxw
|
||||
from osv import osv
|
||||
from openerp.report import report_sxw
|
||||
|
||||
|
||||
# Enter Report Class Information Here
|
||||
class deposit_ticket_webkit(report_sxw.rml_parse):
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(deposit_ticket_webkit, self).__init__(
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
import decimal_precision as dp
|
||||
|
||||
|
||||
class add_deposit_items(osv.osv_memory):
|
||||
class add_deposit_items(orm.TransientModel):
|
||||
_name = "add.deposit.items"
|
||||
_description = "Add Deposit Items"
|
||||
_columns = {
|
||||
@@ -147,14 +147,16 @@ class add_deposit_items(osv.osv_memory):
|
||||
# Any Line cannot be manually added.
|
||||
# Choose only from the selected lines.
|
||||
if not line.move_line_id:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('Processing Error'),
|
||||
_(
|
||||
'You cannot add any new deposit line item '
|
||||
'manually as of this revision!'
|
||||
)
|
||||
)
|
||||
res_id = deposit_ticket_line_obj.create(
|
||||
|
||||
# Creating but not using the id of the new object anywhere
|
||||
deposit_ticket_line_obj.create(
|
||||
cr, uid,
|
||||
{
|
||||
'name': line.name,
|
||||
@@ -182,10 +184,7 @@ class add_deposit_items(osv.osv_memory):
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
add_deposit_items()
|
||||
|
||||
|
||||
class deposit_items_line(osv.osv_memory):
|
||||
class deposit_items_line(orm.TransientModel):
|
||||
_name = "deposit.items.line"
|
||||
_description = "Deposit Items Line"
|
||||
_columns = {
|
||||
@@ -223,5 +222,3 @@ class deposit_items_line(osv.osv_memory):
|
||||
'Company'
|
||||
),
|
||||
}
|
||||
|
||||
deposit_items_line()
|
||||
|
||||
@@ -21,14 +21,19 @@
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.osv import fields, orm
|
||||
from openerp.tools.translate import _
|
||||
import decimal_precision as dp
|
||||
|
||||
|
||||
class bank_acc_rec_statement(osv.osv):
|
||||
class bank_acc_rec_statement(orm.Model):
|
||||
|
||||
"""Bank account rec statement."""
|
||||
|
||||
def check_group(self, cr, uid, ids, context=None):
|
||||
"""Check if following security constraints are implemented for groups:
|
||||
"""
|
||||
Check if following security constraints are implemented for groups.
|
||||
|
||||
Bank Statement Preparer – they can create, view and delete any of
|
||||
the Bank Statements provided the Bank Statement is not in the DONE
|
||||
state, or the Ready for Review state.
|
||||
@@ -55,7 +60,7 @@ class bank_acc_rec_statement(osv.osv):
|
||||
)
|
||||
group_user_ids = [user.id for user in group_verifier.users]
|
||||
if statement.state != 'draft' and uid not in group_user_ids:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('User Error'),
|
||||
_(
|
||||
"Only a member of '%s' group may delete/edit "
|
||||
@@ -105,10 +110,10 @@ class bank_acc_rec_statement(osv.osv):
|
||||
)
|
||||
|
||||
def check_difference_balance(self, cr, uid, ids, context=None):
|
||||
"Check if difference balance is zero or not."
|
||||
"""Check if difference balance is zero or not."""
|
||||
for statement in self.browse(cr, uid, ids, context=context):
|
||||
if statement.difference != 0.0:
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('Warning!'),
|
||||
_(
|
||||
"Prior to reconciling a statement, all differences "
|
||||
@@ -120,12 +125,12 @@ class bank_acc_rec_statement(osv.osv):
|
||||
return True
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
"Cancel the the statement."
|
||||
"""Cancel the the statement."""
|
||||
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
|
||||
return True
|
||||
|
||||
def action_review(self, cr, uid, ids, context=None):
|
||||
"Change the status of statement from 'draft' to 'to_be_reviewed'."
|
||||
"""Change the status of statement from 'draft' to 'to_be_reviewed'."""
|
||||
# If difference balance not zero prevent further processing
|
||||
self.check_difference_balance(cr, uid, ids, context=context)
|
||||
self.write(cr, uid, ids, {'state': 'to_be_reviewed'}, context=context)
|
||||
@@ -138,7 +143,6 @@ class bank_acc_rec_statement(osv.osv):
|
||||
are marked as 'Cleared'.
|
||||
"""
|
||||
account_move_line_obj = self.pool.get('account.move.line')
|
||||
statement_line_obj = self.pool.get('bank.acc.rec.statement.line')
|
||||
# If difference balance not zero prevent further processing
|
||||
self.check_difference_balance(cr, uid, ids, context=context)
|
||||
for statement in self.browse(cr, uid, ids, context=context):
|
||||
@@ -707,10 +711,7 @@ class bank_acc_rec_statement(osv.osv):
|
||||
]
|
||||
|
||||
|
||||
bank_acc_rec_statement()
|
||||
|
||||
|
||||
class bank_acc_rec_statement_line(osv.osv):
|
||||
class bank_acc_rec_statement_line(orm.Model):
|
||||
_name = "bank.acc.rec.statement.line"
|
||||
_description = "Statement Line"
|
||||
_columns = {
|
||||
@@ -787,7 +788,7 @@ class bank_acc_rec_statement_line(osv.osv):
|
||||
# This would allow only onchange method to pre-populate
|
||||
# statement lines based on the filter rules.
|
||||
if not vals.get('move_line_id', False):
|
||||
raise osv.except_osv(
|
||||
raise orm.except_orm(
|
||||
_('Processing Error'),
|
||||
_('You cannot add any new bank statement line '
|
||||
'manually as of this revision!')
|
||||
@@ -823,6 +824,3 @@ class bank_acc_rec_statement_line(osv.osv):
|
||||
return super(bank_acc_rec_statement_line, self).unlink(
|
||||
cr, uid, ids, context=context
|
||||
)
|
||||
|
||||
|
||||
bank_acc_rec_statement_line()
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from osv import fields, osv
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
class account_move_line(orm.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
_columns = {
|
||||
|
||||
Reference in New Issue
Block a user