[MIG] account_check_printing: replace openerp tags, clean imports and rename classes

This commit is contained in:
fwi-odoo
2016-08-03 11:18:32 +02:00
committed by Thibault Delavallée
parent dcab4afda4
commit 2163d2b7f7
10 changed files with 37 additions and 34 deletions
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import models
import wizard
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Check Printing Base',
'version': '1.0',
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data noupdate="1">
<record id="account_payment_method_check" model="account.payment.method">
@@ -30,4 +30,4 @@
</record>
</data>
</openerp>
</odoo>
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class AccountJournal(models.Model):
_inherit = "account.journal"
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import math
from openerp import models, fields, api, _
from openerp.tools import amount_to_text_en, float_round
from openerp.exceptions import UserError, ValidationError
from odoo import models, fields, api, _
from odoo.tools import amount_to_text_en, float_round
from odoo.exceptions import UserError, ValidationError
class account_register_payments(models.TransientModel):
class AccountRegisterPayments(models.TransientModel):
_inherit = "account.register.payments"
check_amount_in_words = fields.Char(string="Amount in Words")
@@ -18,15 +20,15 @@ class account_register_payments(models.TransientModel):
@api.onchange('journal_id')
def _onchange_journal_id(self):
if hasattr(super(account_register_payments, self), '_onchange_journal_id'):
super(account_register_payments, self)._onchange_journal_id()
if hasattr(super(AccountRegisterPayments, self), '_onchange_journal_id'):
super(AccountRegisterPayments, self)._onchange_journal_id()
if self.journal_id.check_manual_sequencing:
self.check_number = self.journal_id.check_sequence_id.number_next_actual
@api.onchange('amount')
def _onchange_amount(self):
if hasattr(super(account_register_payments, self), '_onchange_amount'):
super(account_register_payments, self)._onchange_amount()
if hasattr(super(AccountRegisterPayments, self), '_onchange_amount'):
super(AccountRegisterPayments, self)._onchange_amount()
# TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
@@ -36,7 +38,7 @@ class account_register_payments(models.TransientModel):
self.check_amount_in_words = check_amount_in_words
def get_payment_vals(self):
res = super(account_register_payments, self).get_payment_vals()
res = super(AccountRegisterPayments, self).get_payment_vals()
if self.payment_method_id == self.env.ref('account_check_printing.account_payment_method_check'):
res.update({
'check_amount_in_words': self.check_amount_in_words,
@@ -45,7 +47,7 @@ class account_register_payments(models.TransientModel):
return res
class account_payment(models.Model):
class AccountPayment(models.Model):
_inherit = "account.payment"
check_amount_in_words = fields.Char(string="Amount in Words")
@@ -56,15 +58,15 @@ class account_payment(models.Model):
@api.onchange('journal_id')
def _onchange_journal_id(self):
if hasattr(super(account_payment, self), '_onchange_journal_id'):
super(account_payment, self)._onchange_journal_id()
if hasattr(super(AccountPayment, self), '_onchange_journal_id'):
super(AccountPayment, self)._onchange_journal_id()
if self.journal_id.check_manual_sequencing:
self.check_number = self.journal_id.check_sequence_id.number_next_actual
@api.onchange('amount')
def _onchange_amount(self):
if hasattr(super(account_payment, self), '_onchange_amount'):
super(account_payment, self)._onchange_amount()
if hasattr(super(AccountPayment, self), '_onchange_amount'):
super(AccountPayment, self)._onchange_amount()
check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
decimals = self.amount % 1
@@ -73,7 +75,7 @@ class account_payment(models.Model):
self.check_amount_in_words = check_amount_in_words
def _check_communication(self, payment_method_id, communication):
super(account_payment, self)._check_communication(payment_method_id, communication)
super(AccountPayment, self)._check_communication(payment_method_id, communication)
if payment_method_id == self.env.ref('account_check_printing.account_payment_method_check').id:
if not communication:
return
@@ -86,7 +88,7 @@ class account_payment(models.Model):
and vals.get('check_manual_sequencing'):
sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id
vals.update({'check_number': sequence.next_by_id()})
return super(account_payment, self.sudo()).create(vals)
return super(AccountPayment, self.sudo()).create(vals)
@api.multi
def print_checks(self):
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="account_journal_dashboard_kanban_view_inherited" model="ir.ui.view">
<field name="name">account.journal.dashboard.kanban.inherited</field>
<field name="model">account.journal</field>
@@ -37,5 +36,4 @@
</xpath>
</field>
</record>
</data>
</openerp>
</odoo>
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="view_account_payment_form_inherited" model="ir.ui.view">
<field name="name">account.payment.form.inherited</field>
<field name="model">account.payment</field>
@@ -61,5 +60,4 @@
</field>
</record>
</data>
</openerp>
</odoo>
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import print_prenumbered_checks
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import api, fields, models
from odoo import api, fields, models
class print_pre_numbered_checks(models.TransientModel):
class PrintPreNumberedChecks(models.TransientModel):
_name = 'print.prenumbered.checks'
_description = 'Print Pre-numbered Checks'
@@ -1,6 +1,5 @@
<?xml version="1.0" ?>
<openerp>
<data>
<odoo>
<record id="print_pre_numbered_checks_view" model="ir.ui.view">
<field name="name">Print Pre-numbered Checks</field>
@@ -21,5 +20,4 @@
</field>
</record>
</data>
</openerp>
</odoo>