[13.0][account_asset_management] propose account when user chooses
This commit is contained in:
parent
cf6de3db86
commit
ffa8d96851
@ -30,12 +30,15 @@ FIELDS_AFFECTS_ASSET_MOVE_LINE = {
|
|||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = "account.move"
|
_inherit = "account.move"
|
||||||
|
|
||||||
asset_count = fields.Integer(compute='_compute_asset_count')
|
asset_count = fields.Integer(compute="_compute_asset_count")
|
||||||
|
|
||||||
def _compute_asset_count(self):
|
def _compute_asset_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
assets = self.env['account.asset.line'].search([
|
assets = (
|
||||||
('move_id', '=', self.id)]).mapped('asset_id')
|
self.env["account.asset.line"]
|
||||||
|
.search([("move_id", "=", self.id)])
|
||||||
|
.mapped("asset_id")
|
||||||
|
)
|
||||||
rec.asset_count = len(assets)
|
rec.asset_count = len(assets)
|
||||||
|
|
||||||
def unlink(self):
|
def unlink(self):
|
||||||
@ -125,12 +128,17 @@ class AccountMove(models.Model):
|
|||||||
return move_vals
|
return move_vals
|
||||||
|
|
||||||
def action_view_assets(self):
|
def action_view_assets(self):
|
||||||
assets = self.env['account.asset.line'].search([
|
assets = (
|
||||||
('move_id', '=', self.id)]).mapped('asset_id')
|
self.env["account.asset.line"]
|
||||||
|
.search([("move_id", "=", self.id)])
|
||||||
|
.mapped("asset_id")
|
||||||
|
)
|
||||||
action = self.env.ref("account_asset_management.account_asset_action")
|
action = self.env.ref("account_asset_management.account_asset_action")
|
||||||
action_dict = action.read()[0]
|
action_dict = action.read()[0]
|
||||||
if len(assets) == 1:
|
if len(assets) == 1:
|
||||||
res = self.env.ref("account_asset_management.account_asset_view_form", False)
|
res = self.env.ref(
|
||||||
|
"account_asset_management.account_asset_view_form", False
|
||||||
|
)
|
||||||
action_dict["views"] = [(res and res.id or False, "form")]
|
action_dict["views"] = [(res and res.id or False, "form")]
|
||||||
action_dict["res_id"] = assets.id
|
action_dict["res_id"] = assets.id
|
||||||
elif assets:
|
elif assets:
|
||||||
@ -144,10 +152,10 @@ class AccountMoveLine(models.Model):
|
|||||||
_inherit = "account.move.line"
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
asset_profile_id = fields.Many2one(
|
asset_profile_id = fields.Many2one(
|
||||||
comodel_name="account.asset.profile", string="Asset Profile"
|
comodel_name="account.asset.profile", string="Asset Profile",
|
||||||
)
|
)
|
||||||
asset_id = fields.Many2one(
|
asset_id = fields.Many2one(
|
||||||
comodel_name="account.asset", string="Asset", ondelete="restrict"
|
comodel_name="account.asset", string="Asset", ondelete="restrict",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.onchange("account_id")
|
@api.onchange("account_id")
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
* [BREAKING] Removed all functionality associated with `account.fiscal.year`
|
* [BREAKING] Removed all functionality associated with `account.fiscal.year`
|
||||||
|
|
||||||
|
13.0.2.0.0 (2021-02-19)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* Add support for multi-company
|
||||||
|
|
||||||
13.0.1.0.0 (2019-10-21)
|
13.0.1.0.0 (2019-10-21)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -6,13 +6,17 @@
|
|||||||
<field name="inherit_id" ref="account.view_move_form" />
|
<field name="inherit_id" ref="account.view_move_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
||||||
<button name="action_view_assets"
|
<button
|
||||||
type="object"
|
name="action_view_assets"
|
||||||
class="oe_stat_button"
|
type="object"
|
||||||
icon="fa-cube"
|
class="oe_stat_button"
|
||||||
attrs="{'invisible': [('asset_count', '=', 0)]}">
|
icon="fa-cube"
|
||||||
|
attrs="{'invisible': [('asset_count', '=', 0)]}"
|
||||||
|
>
|
||||||
<div class="o_field_widget o_stat_info">
|
<div class="o_field_widget o_stat_info">
|
||||||
<span class="o_stat_value"><field name="asset_count"/></span>
|
<span class="o_stat_value">
|
||||||
|
<field name="asset_count" />
|
||||||
|
</span>
|
||||||
<span class="o_stat_text"> Asset(s)</span>
|
<span class="o_stat_text"> Asset(s)</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
@ -37,7 +41,10 @@
|
|||||||
expr="//notebook//field[@name='line_ids']/tree/field[@name='date_maturity']"
|
expr="//notebook//field[@name='line_ids']/tree/field[@name='date_maturity']"
|
||||||
position="after"
|
position="after"
|
||||||
>
|
>
|
||||||
<field name="asset_profile_id" />
|
<field
|
||||||
|
name="asset_profile_id"
|
||||||
|
domain="[('company_id','=', parent.company_id)]"
|
||||||
|
/>
|
||||||
<field name="asset_id" groups="account.group_account_manager" />
|
<field name="asset_id" groups="account.group_account_manager" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
<field name="inherit_id" ref="account.view_move_line_form" />
|
<field name="inherit_id" ref="account.view_move_line_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="statement_id" position="after">
|
<field name="statement_id" position="after">
|
||||||
<field name="asset_profile_id" />
|
<field
|
||||||
|
name="asset_profile_id"
|
||||||
|
domain="[('company_id','=', parent.company_id)]"
|
||||||
|
/>
|
||||||
<field name="asset_id" />
|
<field name="asset_id" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
|
Loading…
Reference in New Issue
Block a user