mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Code review
This commit is contained in:
@@ -113,7 +113,7 @@ class AccountSpread(models.Model):
|
||||
analytic_tag_ids = fields.Many2many(
|
||||
'account.analytic.tag',
|
||||
string='Analytic Tags')
|
||||
move_line_auto_post = fields.Boolean('Auto-post lines')
|
||||
move_line_auto_post = fields.Boolean('Auto-post lines', default=True)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
|
||||
@@ -25,7 +25,7 @@ class AccountSpreadTemplate(models.Model):
|
||||
required=True)
|
||||
spread_account_id = fields.Many2one(
|
||||
'account.account',
|
||||
string='Spread Account',
|
||||
string='Spread Balance Sheet Account',
|
||||
required=True)
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
Define Spread Costs/Revenues Board
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Under Invoicing -> Adviser -> Accounting Entries -> Spread Costs/Revenues, create a new spread board.
|
||||
|
||||
Complete the definition of the spreading criteria, by setting the the fields:
|
||||
@@ -23,8 +26,14 @@ A cron job will automatically create the accounting moves for all the lines havi
|
||||
.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/11.0/account_spread_cost_revenue/static/description/update_spread.png
|
||||
:alt: The spreading board is updated by the cron job
|
||||
|
||||
By default, the status of the created accounting moves is unposted, so you should post them manually one by one.
|
||||
To allow the automatic posting of the accounting moves, set the flag *Auto-post lines* to True.
|
||||
By default, the status of the created accounting moves is posted.
|
||||
To disable the automatic posting of the accounting moves, set the flag *Auto-post lines* to False.
|
||||
|
||||
Click on button *Recalculate entire spread* button in the spread board to force the recalculation of the spread lines:
|
||||
this will also reset all the journal entries previously created.
|
||||
|
||||
Link Invoice to Spread Costs/Revenues Board
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Create an invoice or vendor bill in draft. On its lines, the spreading right-arrow icon are displayed in dark-grey color.
|
||||
|
||||
@@ -52,5 +61,14 @@ on the smart button *Reconciled entries*: the moves of the spread lines are reco
|
||||
In case the Subtotal Price of the invoice line is different than the *Estimated Amount* of the spread board, the spread
|
||||
lines (not yet posted) will be recalculated when validating the invoice/bill.
|
||||
|
||||
Click on button *Recalculate entire spread* button in the spread board to force the recalculation of the spread lines:
|
||||
this will also reset all the journal entries previously created.
|
||||
Define Spread Costs/Revenues Template
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Under Invoicing -> Configuration -> Accounting -> Spread Templates, create a new spread template.
|
||||
|
||||
* *Spread Type*
|
||||
* *Spread Balance Sheet Account*
|
||||
* *Journal*
|
||||
|
||||
When creating a new Spread Costs/Revenues Board, select the right template.
|
||||
This way the above fields will be copied to the Spread Board.
|
||||
|
||||
@@ -460,6 +460,7 @@ class TestAccountInvoiceSpread(AccountingTestCase):
|
||||
'period_type': 'month',
|
||||
'spread_date': '2017-01-07',
|
||||
'invoice_line_id': self.invoice_line.id,
|
||||
'move_line_auto_post': False,
|
||||
})
|
||||
|
||||
spread_lines = self.spread.line_ids
|
||||
@@ -519,6 +520,7 @@ class TestAccountInvoiceSpread(AccountingTestCase):
|
||||
'period_type': 'month',
|
||||
'spread_date': '2017-01-07',
|
||||
'invoice_line_id': self.invoice_line.id,
|
||||
'move_line_auto_post': False,
|
||||
})
|
||||
|
||||
spread_lines = self.spread.line_ids
|
||||
@@ -579,6 +581,7 @@ class TestAccountInvoiceSpread(AccountingTestCase):
|
||||
'period_type': 'month',
|
||||
'spread_date': '2017-01-07',
|
||||
'invoice_line_id': self.invoice_line_2.id,
|
||||
'move_line_auto_post': False,
|
||||
})
|
||||
|
||||
spread_lines = self.spread2.line_ids
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestAccountSpreadCostRevenue(AccountingTestCase):
|
||||
self.assertFalse(spread.invoice_id)
|
||||
self.assertFalse(spread.account_analytic_id)
|
||||
self.assertFalse(spread.analytic_tag_ids)
|
||||
self.assertFalse(spread.move_line_auto_post)
|
||||
self.assertTrue(spread.move_line_auto_post)
|
||||
self.assertEqual(spread.name, 'test')
|
||||
self.assertEqual(spread.invoice_type, 'out_invoice')
|
||||
self.assertEqual(spread.company_id, my_company)
|
||||
|
||||
@@ -156,7 +156,8 @@ class TestComputeSpreadBoard(AccountingTestCase):
|
||||
self.spread.write({
|
||||
'period_number': 12,
|
||||
'period_type': 'month',
|
||||
'spread_date': '2017-01-31'
|
||||
'spread_date': '2017-01-31',
|
||||
'move_line_auto_post': False
|
||||
})
|
||||
|
||||
self.spread.compute_spread_board()
|
||||
@@ -295,7 +296,8 @@ class TestComputeSpreadBoard(AccountingTestCase):
|
||||
# spread date set
|
||||
self.spread.write({
|
||||
'period_number': 3,
|
||||
'period_type': 'quarter'
|
||||
'period_type': 'quarter',
|
||||
'move_line_auto_post': False
|
||||
})
|
||||
|
||||
self.spread.compute_spread_board()
|
||||
@@ -410,6 +412,7 @@ class TestComputeSpreadBoard(AccountingTestCase):
|
||||
self.assertTrue(line.move_id)
|
||||
|
||||
def test_11_create_move_sale_invoice(self):
|
||||
self.spread2.move_line_auto_post = False
|
||||
self.spread2.compute_spread_board()
|
||||
for line in self.spread2.line_ids:
|
||||
self.assertFalse(line.move_id)
|
||||
|
||||
@@ -118,6 +118,10 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
|
||||
else:
|
||||
debit_account = self.invoice_line_id.account_id
|
||||
|
||||
analytic_account = self.invoice_line_id.account_analytic_id
|
||||
analytic_tags = self.invoice_line_id.analytic_tag_ids
|
||||
date_invoice = self.invoice_id.date_invoice or fields.Date.today()
|
||||
|
||||
return {
|
||||
'name': _('New Spread Board'),
|
||||
'view_type': 'form',
|
||||
@@ -133,20 +137,37 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
|
||||
'default_debit_account_id': debit_account.id,
|
||||
'default_credit_account_id': credit_account.id,
|
||||
'default_journal_id': self.spread_journal_id.id,
|
||||
'default_account_analytic_id': analytic_account.id,
|
||||
'default_analytic_tag_ids': analytic_tags.ids,
|
||||
'default_spread_date': date_invoice,
|
||||
},
|
||||
}
|
||||
elif self.spread_action_type == 'template':
|
||||
if not self.invoice_line_id.spread_id:
|
||||
account = self.invoice_line_id.account_id
|
||||
spread_vals = self.template_id._prepare_spread_from_template()
|
||||
spread_vals['debit_account_id'] = account.id
|
||||
|
||||
date_invoice = self.invoice_id.date_invoice or fields.Date.today()
|
||||
spread_vals['spread_date'] = date_invoice
|
||||
|
||||
spread_vals['name'] = ('%s %s') % (
|
||||
spread_vals['name'],
|
||||
self.invoice_line_id.name
|
||||
)
|
||||
|
||||
if spread_vals['invoice_type'] == 'out_invoice':
|
||||
spread_vals['credit_account_id'] = account.id
|
||||
else:
|
||||
spread_vals['debit_account_id'] = account.id
|
||||
|
||||
analytic_account = self.invoice_line_id.account_analytic_id
|
||||
spread_vals['account_analytic_id'] = analytic_account.id
|
||||
|
||||
spread = self.env['account.spread'].create(spread_vals)
|
||||
|
||||
analytic_tags = self.invoice_line_id.analytic_tag_ids
|
||||
spread.analytic_tag_ids = analytic_tags
|
||||
|
||||
self.invoice_line_id.spread_id = spread
|
||||
return {
|
||||
'name': _('Spread Details'),
|
||||
|
||||
Reference in New Issue
Block a user