[ADD] hr_expense_check: add amount in words on check
- Create an expense, approve. - Register the payment by check - Print the check The amount in words is not written. The core of the issue is that the wizard `hr.expense.register.payment.wizard` has been defined as a brand new model instead of inheriting from `account.register.payments`. Hence the Enterprise module "hr_expense_sepa" and now "hr_expense_check". opw-742305
This commit is contained in:
@@ -0,0 +1 @@
|
||||
import models
|
||||
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "Check Printing in Expenses",
|
||||
'summary': """Print amount in words on checks issued for expenses""",
|
||||
'category': 'Accounting',
|
||||
'description': """
|
||||
Print amount in words on checks issued for expenses
|
||||
""",
|
||||
'category': 'Accounting & Finance',
|
||||
'version': '1.0',
|
||||
'depends': ['account_check_printing', 'hr_expense'],
|
||||
'auto_install': True,
|
||||
'data': [
|
||||
'views/payment.xml',
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import payment
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HrExpenseRegisterPaymentWizard(models.TransientModel):
|
||||
_inherit = "hr.expense.register.payment.wizard"
|
||||
|
||||
check_amount_in_words = fields.Char(string="Amount in Words")
|
||||
check_manual_sequencing = fields.Boolean(related='journal_id.check_manual_sequencing')
|
||||
# Note: a check_number == 0 means that it will be attributed when the check is printed
|
||||
check_number = fields.Integer(string="Check Number", readonly=True, copy=False, default=0,
|
||||
help="Number of the check corresponding to this payment. If your pre-printed check are not already numbered, "
|
||||
"you can manage the numbering in the journal configuration page.")
|
||||
payment_method_code_2 = fields.Char(related='payment_method_id.code',
|
||||
help="Technical field used to adapt the interface to the payment type selected.",
|
||||
readonly=True)
|
||||
|
||||
@api.onchange('journal_id')
|
||||
def _onchange_journal_id(self):
|
||||
if hasattr(super(HrExpenseRegisterPaymentWizard, self), '_onchange_journal_id'):
|
||||
super(HrExpenseRegisterPaymentWizard, 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(HrExpenseRegisterPaymentWizard, self), '_onchange_amount'):
|
||||
super(HrExpenseRegisterPaymentWizard, self)._onchange_amount()
|
||||
self.check_amount_in_words = self.env['account.payment']._get_check_amount_in_words(self.amount)
|
||||
|
||||
def get_payment_vals(self):
|
||||
res = super(HrExpenseRegisterPaymentWizard, 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,
|
||||
'check_manual_sequencing': self.check_manual_sequencing,
|
||||
})
|
||||
return res
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<data>
|
||||
<record id="hr_expense_register_payment_view_form_check_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.expense.register.payment.wizard.form.check.inherited</field>
|
||||
<field name="model">hr.expense.register.payment.wizard</field>
|
||||
<field name="inherit_id" ref="hr_expense.hr_expense_register_payment_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='amount_div']" position="after">
|
||||
<field name="check_amount_in_words" attrs="{'invisible': [('payment_method_code_2', '!=', 'check_printing')]}" groups="base.group_no_one"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='communication']" position="after">
|
||||
<field name="payment_method_code_2" invisible="1"/>
|
||||
<field name="check_manual_sequencing" invisible="1"/>
|
||||
<field name="check_number" attrs="{'invisible': ['|', ('payment_method_code_2', '!=', 'check_printing'), ('check_manual_sequencing', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
Reference in New Issue
Block a user