Skip to content

Commit

Permalink
[IMP] account_move_cutoff: improve module settings
Browse files Browse the repository at this point in the history
* exposing default cutoff method using default odoo features
* allow to forward product attribute on account move line
  to make better analysis
  • Loading branch information
petrus-v committed Sep 23, 2024
1 parent ec6e843 commit 1a86d45
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
12 changes: 1 addition & 11 deletions account_move_cutoff/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ class AccountMoveLine(models.Model):
"cutoff.period.mixin",
]

@api.model
def _get_default_cutoff_method(self):
return (
self.env["ir.config_parameter"]
.sudo()
.get_param(
"account_move_cutoff.default_cutoff_method", "monthly_prorata_temporis"
)
)

is_deferrable_line = fields.Boolean(
string="Is deferrable line",
compute="_compute_is_deferrable_line",
Expand All @@ -41,7 +31,7 @@ def _get_default_cutoff_method(self):
],
string="Cut-off method",
required=True,
default=lambda self: self._get_default_cutoff_method(),
default="monthly_prorata_temporis",
help=(
"Determine how to split amounts over periods:\n"
" * Equal: same amount is splitted over periods of the service"
Expand Down
17 changes: 17 additions & 0 deletions account_move_cutoff/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ class ResConfigSettings(models.TransientModel):
config_parameter="account_move_cutoff.link_product",
help="Link product on deferred account.move.line.",
)
default_cutoff_method = fields.Selection(
[
("equal", "Equal"),
("monthly_prorata_temporis", "Prorata temporis (by month %)"),
],
string="Default Cutoff method",
default="monthly_prorata_temporis",
default_model="account.move.line",
required=True,
help=(
"Determine how to split amounts over periods:\n"
" * Equal: same amount is splitted over periods of the service"
" (using start and end date on the invoice line).\n"
" * Prorata temporis by month %: amount is splitted over"
" the rate of service days in the month.\n"
),
)
9 changes: 8 additions & 1 deletion account_move_cutoff/views/account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
/>
</field>
<xpath
expr="//notebook/page[@id='aml_tab']/field[@name='line_ids']/tree/field[@name='name']"
expr="//notebook/page[@id='invoice_tab']/field[@name='invoice_line_ids']/tree/field[@name='account_id']"
position="after"
>
<field name="cutoff_method" optional="hide" />
</xpath>
<xpath
expr="//notebook/page[@id='aml_tab']/field[@name='line_ids']/tree/field[@name='account_id']"
position="after"
>
<field name="cutoff_method" optional="hide" />
<field name="cutoff_source_move_id" optional="hide" />
<field name="cutoff_source_id" optional="hide" />
</xpath>
Expand Down
3 changes: 3 additions & 0 deletions account_move_cutoff/views/account_move_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
string="Deferred Revenue/Expense"
attrs="{'invisible': [('cutoff_source_move_id', '=', False)]}"
>
<field name="cutoff_method" />
<field name="cutoff_source_move_id" />
<field name="cutoff_source_id" />
</group>
Expand All @@ -28,6 +29,7 @@
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="cutoff_method" optional="hide" />
<field name="cutoff_source_move_id" optional="hide" />
<field name="cutoff_source_id" optional="hide" />
</field>
Expand All @@ -41,6 +43,7 @@
<field name="inherit_id" ref="account.view_move_line_tree_grouped" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="cutoff_method" optional="hide" />
<field name="cutoff_source_move_id" optional="hide" />
<field name="cutoff_source_id" optional="hide" />
</field>
Expand Down
22 changes: 22 additions & 0 deletions account_move_cutoff/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@
</div>
</div>
</div>

<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<field
name="default_cutoff_method"
string="Default cutoff method"
/>
<div class="text-muted">
Determine how to split amounts over periods:
<li>
<ul
>Equal: same amount is splitted over periods of the service"
(using start and end date on the invoice line).</ul>
<ul>
Prorata temporis by month %: amount is splitted over"
the rate of service days in the month.\n"
</ul>
</li>
</div>
</div>
</div>
</xpath>

</field>
Expand Down

0 comments on commit 1a86d45

Please sign in to comment.