[10.0] Usability of account_payment_order: access journal entries via top-right button (#457)

account_payment_order: access journal entries via top-right button instead of dedicated tab
This commit is contained in:
Alexis de Lattre
2018-03-23 10:11:26 +01:00
committed by GitHub
parent 8d1cb348fc
commit 6d2900d297
3 changed files with 42 additions and 4 deletions

View File

@@ -9,7 +9,7 @@
{
'name': 'Account Payment Order',
'version': '10.0.1.3.2',
'version': '10.0.1.3.3',
'license': 'AGPL-3',
'author': "ACSONE SA/NV, "
"Therp BV, "

View File

@@ -91,8 +91,22 @@ class AccountPaymentOrder(models.Model):
move_ids = fields.One2many(
'account.move', 'payment_order_id', string='Journal Entries',
readonly=True)
move_count = fields.Integer(
compute='_compute_move_count', readonly=True, store=True,
string="# of Journal Entries")
description = fields.Char()
@api.depends('move_ids')
def _compute_move_count(self):
move_data = self.env['account.move'].read_group(
[('payment_order_id', 'in', self.ids)],
['payment_order_id'], ['payment_order_id'])
mapped_data = dict([
(move['payment_order_id'][0], move['payment_order_id_count'])
for move in move_data])
for order in self:
order.move_count = mapped_data.get(order.id, 0)
@api.multi
def unlink(self):
for order in self:
@@ -488,3 +502,22 @@ class AccountPaymentOrder(models.Model):
blines.reconcile_payment_lines()
if post_move:
move.post()
def open_moves(self):
self.ensure_one()
action = self.env['ir.actions.act_window'].for_xml_id(
'account', 'action_move_journal_line')
action.update({
'context': self._context,
'views': False,
'view_id': False,
})
if self.move_ids:
if len(self.move_ids) == 1:
action.update({
'view_mode': 'form,tree',
'res_id': self.move_ids[0].id,
})
else:
action['domain'] = "[('id', 'in', %s)]" % self.move_ids.ids
return action

View File

@@ -26,6 +26,14 @@
<field name="state" widget="statusbar"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="open_moves" type="object"
attrs="{'invisible': [('move_count', '=', 0)]}"
class="oe_stat_button" icon="fa-pencil-square-o">
<field name="move_count" string="Journal Entries"
widget="statinfo"/>
</button>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@@ -61,9 +69,6 @@
<field name="bank_line_ids"
context="{'default_payment_type': payment_type}"/>
</page>
<page name="moves" string="Transfer Journal Entries">
<field name="move_ids"/>
</page>
</notebook>
</sheet>
<div class="oe_chatter">