Comments (7)
In om_account_asset/models/account_move.py
we can override move_id's button_draft method to look for assets created by the move and then unlink them (see code below). But the asset.unlink method will only allow an asset to be deleted if the asset is in 'draft' state. It's possible that some or all of the assets created by the move are not in 'draft' state.
My question is: what should the business logic be? As written below, if any of the assets created by the invoice or bill have a state != 'draft', the following would result:
- none of the assets would be deleted (even the ones that are in 'draft' state),
- a UserError is raised such that the invoice or bill would not actually be changed to the draft state.
It would then be up to the user to address the situation as best they can. I'm not sure this is the best solution though. Other business logic options are:
- Instead of trying to unlink the assets, we merely inform the user that there exists assets that were created by the move that they just deleted.
- We delete any assets that are in 'draft' state and inform the user that there were other assets that could not be handled.
- We disallow setting an invoice/bill back to draft (I'm not a fan of this option).
Thoughts? Thank you,
Ken
om_account_asset/models/account_move.py
def button_draft(self):
# we want to do the native button_draft function steps first to give it a chance to error-out before our steps
res = super(AccountMove, self).button_draft()
for move in self:
if move.state == 'draft':
# the invoice was successfully set to draft state, therefore delete assets created by this move
move_assets = self.env["account.asset.asset"].search([("invoice_id", "=", move.id)])
move_assets.unlink()
return True
from odooapps.
Thanks for reporting the issues, we will look at the issues and will get back to you.
from odooapps.
How about keeping the assets as inactive instead of deleting them ? Upon checking v11, seems instead of deleting, records are set to active False.
def button_draft(self):
res = super(AccountMove, self).button_draft()
for move in self:
if move.state == 'draft':
self.env['account.asset.asset'].search(
[('invoice_id', 'in', self.ids)]).write({'active': False})
return res
Your thoughts ? @kwoychesko
from odooapps.
I think setting active to False is a better idea than deleting the asset--great idea! We could even add a message to the chatter about why.
Unfortunately we still have the problem of duplicate assets being created if any of the assets were already approved.
from odooapps.
one more enhancement is added related to this, validation error will be shown now upon resetting the invoice when there is a asset in non drafted state.
See: a7531b7
from odooapps.
updated: a7531b7
can you review and shall we close this ?
from odooapps.
Looks great! Thanks!
from odooapps.
Related Issues (20)
- [om_report_pdf_options, v14, Enterprise] method not found
- [16.0] om_account_accountant: You can't create a new statement line HOT 1
- Odoo 15: Can not find periodicity settings.
- [16.0] "om_data_remove": odoo.exceptions.CacheMiss: 'res.company(1,).hr_attendance_overtime'
- [15.0] Partner Ledger under Partners HOT 2
- [15.0] Translation double quote breaking module update
- [Odoo 15.0] - [om_account_followup] - Date Format on Report HOT 1
- [Odoo 15.0] - [om_account_followup] - Subject Line on PDF Report HOT 4
- Is there any support for withholding taxes in accounting?
- Bur on mobile responsive mode
- [16.0] account_asset: OWL error with asset creation HOT 4
- Error in Installation of Odoo Accounting 16 : Field `analytic_distribution_stored_char` does not exist HOT 2
- [16.0] Please migrate om_data_remove app to version 16.0 HOT 2
- [16.0] Unable to Create Cash transaction. (Error: Please install Accounting for this feature) HOT 3
- [16.0] Error when printing General Ledger Audit Report HOT 2
- [14.0] Payslip won't compute om_hr_payroll
- om_account_accountant can not install V13ce The element '<field name="journal_ids">' not found in parent view
- [14.0] Error when try to generate General Ledger
- Error on instalation Odoo 16 Assets Management
- [om_account_bank_statement_import, v16] Import error HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odooapps.