[FIX] account_asset: do not create move
- Create an asset, post one line. - Go back to the asset => the button is green - Click again on the line => the button is orange There is no protection to prevent the user to post the same entry several times (a new account move is created every time it is clicked). We fix the JS widget, but we add an extra layer of protection at the Python level. opw-778756
This commit is contained in:
@@ -941,6 +941,12 @@ msgstr ""
|
||||
msgid "The number of depreciations needed to depreciate your asset"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_asset
|
||||
#: code:addons/account_asset/models/account_asset.py:477
|
||||
#, python-format
|
||||
msgid "This depreciation is already linked to a journal entry! Please post or delete it."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_asset
|
||||
#: model:ir.ui.view,arch_db:account_asset.view_asset_depreciation_confirmation_wizard
|
||||
msgid "This wizard will post installment/depreciation lines for the selected month.<br/>\n"
|
||||
|
||||
@@ -473,6 +473,8 @@ class AccountAssetDepreciationLine(models.Model):
|
||||
created_moves = self.env['account.move']
|
||||
prec = self.env['decimal.precision'].precision_get('Account')
|
||||
for line in self:
|
||||
if line.move_id:
|
||||
raise UserError(_('This depreciation is already linked to a journal entry! Please post or delete it.'))
|
||||
category_id = line.asset_id.category_id
|
||||
depreciation_date = self.env.context.get('depreciation_date') or line.depreciation_date or fields.Date.context_today(self)
|
||||
company_currency = line.asset_id.company_id.currency_id
|
||||
|
||||
@@ -25,8 +25,8 @@ var WidgetOnButton = core.list_widget_registry.get('field').extend({
|
||||
}
|
||||
return $('<div/>').append((this.parent_state === 'open')? $('<button/>', {
|
||||
type: 'button',
|
||||
title: (this.has_value)? _t('Posted') : _t('Unposted'),
|
||||
disabled: !!this.has_value,
|
||||
title: (this.is_posted)? _t('Posted') : _t('Unposted'),
|
||||
disabled: row_data.move_check.value,
|
||||
'class': 'btn btn-sm btn-link fa fa-circle o_widgetonbutton ' + class_color,
|
||||
}) : '').html();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user