mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Add option to auto-archive spreads
This commit is contained in:
@@ -68,6 +68,9 @@ class AccountSpread(models.Model):
|
||||
total_amount = fields.Float(
|
||||
digits=dp.get_precision('Account'),
|
||||
compute='_compute_amounts')
|
||||
all_posted = fields.Boolean(
|
||||
compute='_compute_amounts',
|
||||
store=True)
|
||||
line_ids = fields.One2many(
|
||||
'account.spread.line',
|
||||
'spread_id',
|
||||
@@ -123,6 +126,7 @@ class AccountSpread(models.Model):
|
||||
display_move_line_auto_post = fields.Boolean(
|
||||
compute='_compute_display_move_line_auto_post',
|
||||
string='Display Button Auto-post lines')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
@@ -181,6 +185,7 @@ class AccountSpread(models.Model):
|
||||
spread.unposted_amount = total_amount - posted_amount
|
||||
spread.posted_amount = posted_amount
|
||||
spread.total_amount = total_amount
|
||||
spread.all_posted = spread.unposted_amount == 0.0
|
||||
|
||||
@api.multi
|
||||
def _compute_display_create_all_moves(self):
|
||||
|
||||
@@ -166,3 +166,8 @@ class AccountInvoiceSpreadLine(models.Model):
|
||||
'move_id').filtered(lambda m: m.state != 'posted')
|
||||
unposted_moves.filtered(
|
||||
lambda m: m.company_id.force_move_auto_post).post()
|
||||
|
||||
spreads_to_archive = self.env['account.spread'].search([
|
||||
('all_posted', '=', True)
|
||||
]).filtered(lambda s: s.company_id.auto_archive)
|
||||
spreads_to_archive.write({'active': False})
|
||||
|
||||
@@ -27,3 +27,7 @@ class ResCompany(models.Model):
|
||||
'Auto-post spread lines',
|
||||
help="Enable this option if you want to post automatically the "
|
||||
"accounting moves of all the spreads.")
|
||||
auto_archive = fields.Boolean(
|
||||
'Auto-archive spread',
|
||||
help="Enable this option if you want the cron job to automatically "
|
||||
"archive the spreads when all lines are posted.")
|
||||
|
||||
@@ -18,3 +18,6 @@ the company disable the *Allow Spread Planning* option.
|
||||
On the form view of the company, the *Auto-post spread lines* option forces the account moves created
|
||||
during the cost/revenue spreading to be automatically posted. When this option is false, the user can
|
||||
enable/disable the automatic posting by the flag *Auto-post lines* present in the spread board.
|
||||
|
||||
On the form view of the company, enable the *Auto-archive spread* option if you want the
|
||||
cron job to automatically archive the spreads when all lines are posted.
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
type="object"
|
||||
string="Reconciled entries">
|
||||
</button>
|
||||
<button name="toggle_active" type="object"
|
||||
attrs="{'invisible': [('all_posted','=',False)]}"
|
||||
class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button"
|
||||
options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oe_title">
|
||||
<label for="name" string="Spread Board Name"/>
|
||||
@@ -30,6 +36,7 @@
|
||||
<field name="invoice_type" attrs="{'readonly':[('invoice_line_id','!=',False)]}"/>
|
||||
<field name="display_recompute_buttons" invisible="1"/>
|
||||
<field name="display_move_line_auto_post" invisible="1"/>
|
||||
<field name="all_posted" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="accounts">
|
||||
@@ -167,6 +174,15 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_spread_search" model="ir.ui.view">
|
||||
<field name="model">account.spread</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<filter string="Archived" name="inactive" domain="[('active','=',False)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_spread_form" model="ir.actions.act_window">
|
||||
<field name="name">Spread Costs/Revenues</field>
|
||||
<field name="res_model">account.spread</field>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</group>
|
||||
<group name="spreading_options_right">
|
||||
<field name="force_move_auto_post"/>
|
||||
<field name="auto_archive"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user