[IMP] account: make reverse wiazrd extendable

This commit sets the call to default method on move field in reversal
wizard as lambda to ensure that the right method
is called when it is inherited (as in helpdesk_account module).

It also changes the form view so other module can use it to refund
invoices (move_id field first in the view as it will determine if refund
method should be visible or not).

Task-2047999

closes odoo/odoo#37635

X-original-commit: bcda50aeca44b292417024a5e422ffb8698e0c99
Signed-off-by: gla-odoo <gla-odoo@users.noreply.github.com>
This commit is contained in:
Geoffroy Larue
2019-10-01 09:47:59 +00:00
parent 44a500c8d0
commit 0e94c675ef
2 changed files with 8 additions and 2 deletions
@@ -21,7 +21,7 @@ class AccountMoveReversal(models.TransientModel):
return self.env['account.move']
move_id = fields.Many2one('account.move', string='Journal Entry',
default=_get_default_move,
default=lambda self: self._get_default_move,
domain=[('state', '=', 'posted'), ('type', 'not in', ('out_refund', 'in_refund'))])
date = fields.Date(string='Reversal date', default=fields.Date.context_today, required=True)
reason = fields.Char(string='Reason')
@@ -8,6 +8,11 @@
<form string="Reverse Journal Entry">
<field name="residual" invisible="1"/>
<field name="move_type" invisible="1"/>
<group>
<group>
<field name="move_id" readonly="context.get('active_id')" invisible="context.get('active_id')" />
</group>
</group>
<group>
<group attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'in_invoice'))]}">
<field name="refund_method" widget="radio" attrs="{'readonly': [('residual', '=', 0)]}"/>
@@ -24,8 +29,9 @@
The original invoice is duplicated as a new draft.
</div>
</group>
</group>
<group>
<group>
<field name="move_id" readonly="context.get('active_id')" invisible="context.get('active_id')" />
<field name="reason" attrs="{'invisible': [('move_type', '==', 'entry')], 'reason': [('move_type', '==', 'entry')]}"/>
<field name="date" string="Refund Date" attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'in_invoice'))]}"/>
<field name="date" attrs="{'invisible': [('move_type', 'in', ('out_invoice', 'in_invoice'))]}"/>