Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
account_asset_compute_batch/wizard/__init__.py
Executable file
1
account_asset_compute_batch/wizard/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import account_asset_compute
|
||||
44
account_asset_compute_batch/wizard/account_asset_compute.py
Executable file
44
account_asset_compute_batch/wizard/account_asset_compute.py
Executable file
@@ -0,0 +1,44 @@
|
||||
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAssetCompute(models.TransientModel):
|
||||
_inherit = "account.asset.compute"
|
||||
|
||||
use_batch = fields.Boolean(string="Create Batch", help="Use batch opton")
|
||||
batch_name = fields.Char(
|
||||
help="If batch name is specified, computation will be tracked by a batch",
|
||||
)
|
||||
description = fields.Char()
|
||||
profile_ids = fields.Many2many(
|
||||
comodel_name="account.asset.profile",
|
||||
string="Profiles",
|
||||
)
|
||||
delay_compute = fields.Boolean(string="Delay Compute Asset")
|
||||
|
||||
def _prepare_asset_compute_batch(self):
|
||||
return {
|
||||
"date_end": self.date_end,
|
||||
"name": self.batch_name,
|
||||
"description": self.description,
|
||||
"profile_ids": [(4, profile.id) for profile in self.profile_ids],
|
||||
}
|
||||
|
||||
def asset_compute(self):
|
||||
if not self.use_batch:
|
||||
return super().asset_compute()
|
||||
|
||||
batch = self.env["account.asset.compute.batch"].create(
|
||||
self._prepare_asset_compute_batch()
|
||||
)
|
||||
if not self.delay_compute:
|
||||
batch.action_compute()
|
||||
return {
|
||||
"name": self.env._("Asset Compute Batch"),
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "form",
|
||||
"res_model": "account.asset.compute.batch",
|
||||
"res_id": batch.id,
|
||||
}
|
||||
40
account_asset_compute_batch/wizard/account_asset_compute.xml
Executable file
40
account_asset_compute_batch/wizard/account_asset_compute.xml
Executable file
@@ -0,0 +1,40 @@
|
||||
<odoo>
|
||||
<record id="account_asset_compute_view_form" model="ir.ui.view">
|
||||
<field name="name">account.asset.compute</field>
|
||||
<field name="model">account.asset.compute</field>
|
||||
<field
|
||||
name="inherit_id"
|
||||
ref="account_asset_management.account_asset_compute_view_form"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<group position="after">
|
||||
<group>
|
||||
<group>
|
||||
<field name="use_batch" widget="boolean_toggle" />
|
||||
<field
|
||||
name="batch_name"
|
||||
invisible="not use_batch"
|
||||
required="use_batch"
|
||||
/>
|
||||
<field
|
||||
name="description"
|
||||
invisible="not use_batch"
|
||||
required="use_batch"
|
||||
/>
|
||||
<field
|
||||
name="delay_compute"
|
||||
invisible="not use_batch"
|
||||
/>
|
||||
</group>
|
||||
<group>
|
||||
<field
|
||||
name="profile_ids"
|
||||
invisible="not use_batch"
|
||||
widget="many2many_tags"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user