diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py
index a9767234f..f3410cf48 100644
--- a/account_payment_order/__manifest__.py
+++ b/account_payment_order/__manifest__.py
@@ -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, "
diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py
index 8736b5283..8613fde74 100644
--- a/account_payment_order/models/account_payment_order.py
+++ b/account_payment_order/models/account_payment_order.py
@@ -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
diff --git a/account_payment_order/views/account_payment_order.xml b/account_payment_order/views/account_payment_order.xml
index c09d692a3..37e44780b 100644
--- a/account_payment_order/views/account_payment_order.xml
+++ b/account_payment_order/views/account_payment_order.xml
@@ -26,6 +26,14 @@
+
+
+