Add button to post all spread lines
This commit is contained in:
parent
3fbfa32f73
commit
85584004f0
@ -114,6 +114,9 @@ class AccountSpread(models.Model):
|
|||||||
'account.analytic.tag',
|
'account.analytic.tag',
|
||||||
string='Analytic Tags')
|
string='Analytic Tags')
|
||||||
move_line_auto_post = fields.Boolean('Auto-post lines', default=True)
|
move_line_auto_post = fields.Boolean('Auto-post lines', default=True)
|
||||||
|
display_create_all_moves = fields.Boolean(
|
||||||
|
compute='_compute_display_create_all_moves',
|
||||||
|
string='Display Button All Moves')
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields):
|
def default_get(self, fields):
|
||||||
@ -173,6 +176,14 @@ class AccountSpread(models.Model):
|
|||||||
spread.posted_amount = posted_amount
|
spread.posted_amount = posted_amount
|
||||||
spread.total_amount = total_amount
|
spread.total_amount = total_amount
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _compute_display_create_all_moves(self):
|
||||||
|
for spread in self:
|
||||||
|
if any(not line.move_id for line in spread.line_ids):
|
||||||
|
spread.display_create_all_moves = True
|
||||||
|
else:
|
||||||
|
spread.display_create_all_moves = False
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_spread_entry_name(self, seq):
|
def _get_spread_entry_name(self, seq):
|
||||||
"""Use this method to customise the name of the accounting entry."""
|
"""Use this method to customise the name of the accounting entry."""
|
||||||
@ -409,8 +420,7 @@ class AccountSpread(models.Model):
|
|||||||
spread_mls = spread.line_ids.mapped('move_id.line_ids')
|
spread_mls = spread.line_ids.mapped('move_id.line_ids')
|
||||||
spread_mls.remove_move_reconcile()
|
spread_mls.remove_move_reconcile()
|
||||||
inv_link = '<a href=# data-oe-model=account.invoice ' \
|
inv_link = '<a href=# data-oe-model=account.invoice ' \
|
||||||
'data-oe-id=%d>%s</a>' % (
|
'data-oe-id=%d>%s</a>' % (spread.invoice_id.id, _("Invoice"))
|
||||||
spread.invoice_id.id, _("Invoice"))
|
|
||||||
msg_body = _("Unlinked invoice line '%s' (view %s).") % (
|
msg_body = _("Unlinked invoice line '%s' (view %s).") % (
|
||||||
spread.invoice_line_id.name, inv_link)
|
spread.invoice_line_id.name, inv_link)
|
||||||
spread.message_post(body=msg_body)
|
spread.message_post(body=msg_body)
|
||||||
@ -477,6 +487,13 @@ class AccountSpread(models.Model):
|
|||||||
do_reconcile.remove_move_reconcile()
|
do_reconcile.remove_move_reconcile()
|
||||||
do_reconcile.reconcile()
|
do_reconcile.reconcile()
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def create_all_moves(self):
|
||||||
|
for spread in self:
|
||||||
|
for line in spread.line_ids:
|
||||||
|
if not line.move_id:
|
||||||
|
line.create_move()
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_deprecated_accounts(self):
|
def _compute_deprecated_accounts(self):
|
||||||
for spread in self:
|
for spread in self:
|
||||||
|
@ -1 +0,0 @@
|
|||||||
* Add option to post all spread lines in one click
|
|
@ -724,3 +724,16 @@ class TestAccountInvoiceSpread(common.TransactionCase):
|
|||||||
self.assertTrue(other_journal)
|
self.assertTrue(other_journal)
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
self.spread2.journal_id = other_journal
|
self.spread2.journal_id = other_journal
|
||||||
|
|
||||||
|
def test_14_create_all_moves(self):
|
||||||
|
self.spread.compute_spread_board()
|
||||||
|
spread_lines = self.spread.line_ids
|
||||||
|
self.assertEqual(len(spread_lines), 12)
|
||||||
|
for line in spread_lines:
|
||||||
|
self.assertFalse(line.move_id)
|
||||||
|
|
||||||
|
# create moves for all the spread lines
|
||||||
|
self.spread.create_all_moves()
|
||||||
|
spread_lines = self.spread.line_ids
|
||||||
|
for line in spread_lines:
|
||||||
|
self.assertTrue(line.move_id)
|
||||||
|
@ -107,6 +107,9 @@
|
|||||||
<group name="extension_left">
|
<group name="extension_left">
|
||||||
</group>
|
</group>
|
||||||
<group name="extension_right">
|
<group name="extension_right">
|
||||||
|
<field name="display_create_all_moves" invisible="1"/>
|
||||||
|
<button name="create_all_moves" string="Create All Moves" type="object"
|
||||||
|
icon="fa-play" attrs="{'invisible':[('display_create_all_moves','!=',True)]}"/>
|
||||||
<field name="unspread_amount" attrs="{'invisible': [('unspread_amount', '=', 0)]}" />
|
<field name="unspread_amount" attrs="{'invisible': [('unspread_amount', '=', 0)]}" />
|
||||||
<field name="unposted_amount" attrs="{'invisible': [('unposted_amount', '=', 0)]}" />
|
<field name="unposted_amount" attrs="{'invisible': [('unposted_amount', '=', 0)]}" />
|
||||||
<field name="posted_amount" attrs="{'invisible': [('posted_amount', '=', 0)]}" />
|
<field name="posted_amount" attrs="{'invisible': [('posted_amount', '=', 0)]}" />
|
||||||
|
Loading…
Reference in New Issue
Block a user