[FIX] account: Bill payment flow
1. Link to payment not clickable since the owl migration, the click method in xml wasn't there anymore 2. In the past, the view given in the context was problematic, so now we let the orm pick the view Also removed the function open_move and open_payment which was useless since action_open_business_doc_from_aml do the job. I also moved the function in account.move closes odoo/odoo#101342 Task-id: 2988037 X-original-commit: 739ea262b821a71dcb9c7d61d6bd179a4996de0e Related: odoo/enterprise#31876 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -3303,25 +3303,33 @@ class AccountMove(models.Model):
|
||||
def open_reconcile_view(self):
|
||||
return self.line_ids.open_reconcile_view()
|
||||
|
||||
def open_move(self):
|
||||
def action_open_business_doc(self):
|
||||
self.ensure_one()
|
||||
if self.payment_id:
|
||||
return self.open_payment_view()
|
||||
name = _("Payment")
|
||||
res_model = 'account.payment'
|
||||
res_id = self.payment_id.id
|
||||
elif self.statement_line_id:
|
||||
name = _("Bank Transaction")
|
||||
res_model = 'account.bank.statement.line'
|
||||
res_id = self.statement_line_id.id
|
||||
else:
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'account.move',
|
||||
'view_mode': 'form',
|
||||
'res_id': self.id,
|
||||
'views': [(False, 'form')],
|
||||
}
|
||||
name = _("Journal Entry")
|
||||
res_model = 'account.move'
|
||||
res_id = self.id
|
||||
|
||||
def open_payment_view(self):
|
||||
return {
|
||||
'name': name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'account.payment',
|
||||
'view_mode': 'form',
|
||||
'res_id': self.payment_id.id,
|
||||
'views': [(False, 'form')],
|
||||
'res_model': res_model,
|
||||
'res_id': res_id,
|
||||
'context': {
|
||||
'create': False,
|
||||
'delete': False,
|
||||
},
|
||||
'target': 'current',
|
||||
}
|
||||
|
||||
def open_created_caba_entries(self):
|
||||
|
||||
@@ -2509,8 +2509,8 @@ class AccountMoveLine(models.Model):
|
||||
action['domain'] = [('id', 'in', ids)]
|
||||
return clean_action(action, self.env)
|
||||
|
||||
def open_move(self):
|
||||
return self.move_id.open_move()
|
||||
def action_open_business_doc(self):
|
||||
return self.move_id.action_open_business_doc()
|
||||
|
||||
def action_automatic_entry(self):
|
||||
action = self.env['ir.actions.act_window']._for_xml_id('account.account_automatic_entry_wizard_action')
|
||||
@@ -2523,36 +2523,6 @@ class AccountMoveLine(models.Model):
|
||||
action['context'] = ctx
|
||||
return action
|
||||
|
||||
def action_open_business_doc_from_aml(self):
|
||||
self.ensure_one()
|
||||
|
||||
if self.payment_id:
|
||||
name = _("Payment")
|
||||
res_model = 'account.payment'
|
||||
res_id = self.payment_id.id
|
||||
elif self.statement_line_id:
|
||||
name = _("Bank Transaction")
|
||||
res_model = 'account.bank.statement.line'
|
||||
res_id = self.statement_line_id.id
|
||||
else:
|
||||
name = _("Journal Entry")
|
||||
res_model = 'account.move'
|
||||
res_id = self.move_id.id
|
||||
|
||||
return {
|
||||
'name': name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'view_id': self.env.ref('account.view_move_form').id,
|
||||
'res_model': res_model,
|
||||
'res_id': res_id,
|
||||
'context': {
|
||||
'create': False,
|
||||
'delete': False,
|
||||
},
|
||||
'target': 'current',
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# TOOLING
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<a t-att-title="line.date"
|
||||
role="button"
|
||||
class="oe_form_field btn btn-link open_account_move"
|
||||
t-att-move-id="line.move_id"
|
||||
t-on-click="() => this.openMove(line.move_id)"
|
||||
style="margin-right: 5px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding-left: 0px; width:100%; text-align:left;"
|
||||
data-bs-toggle="tooltip"
|
||||
t-att-payment-id="account_payment_id"
|
||||
|
||||
@@ -83,7 +83,7 @@ export class AccountPaymentField extends Component {
|
||||
}
|
||||
|
||||
async openMove(moveId) {
|
||||
const action = await this.orm.call(this.props.record.resModel, 'open_move', [moveId], {});
|
||||
const action = await this.orm.call(this.props.record.resModel, 'action_open_business_doc', [moveId], {});
|
||||
this.action.doAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class OpenMoveWidget extends Component {
|
||||
}
|
||||
|
||||
async openMove(ev) {
|
||||
const action = await this.orm.call("account.move.line", "open_move", [this.props.record.resId], {});
|
||||
const action = await this.orm.call("account.move.line", "action_open_business_doc", [this.props.record.resId], {});
|
||||
this.action.doAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ var ShowPaymentLineWidget = AbstractField.extend({
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: 'account.move',
|
||||
method: 'open_move',
|
||||
method: 'action_open_business_doc',
|
||||
args: [moveId],
|
||||
}).then(function (actionData) {
|
||||
return self.do_action(actionData);
|
||||
|
||||
@@ -13,7 +13,7 @@ const OpenMoveWidget = FieldChar.extend({
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: 'account.move.line',
|
||||
method: 'open_move',
|
||||
method: 'action_open_business_doc',
|
||||
args: [this.res_id],
|
||||
}).then(function (actionData){
|
||||
return self.do_action(actionData);
|
||||
|
||||
@@ -46,8 +46,8 @@ QUnit.module('account', {
|
||||
assert.deepEqual(args.args, [4, 20], "should call js_assign_outstanding_line {warning: required focus}");
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (args.method === 'open_move') {
|
||||
assert.deepEqual(args.args, [10], "should call open_move {warning: required focus}");
|
||||
if (args.method === 'action_open_business_doc') {
|
||||
assert.deepEqual(args.args, [10], "should call action_open_business_doc {warning: required focus}");
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
|
||||
@@ -675,7 +675,7 @@
|
||||
</div>
|
||||
<sheet>
|
||||
<div name="button_box" class="oe_button_box">
|
||||
<button name="open_payment_view"
|
||||
<button name="action_open_business_doc"
|
||||
class="oe_stat_button"
|
||||
icon="fa-bars"
|
||||
type="object"
|
||||
|
||||
Reference in New Issue
Block a user