diff --git a/addons/account_asset/__openerp__.py b/addons/account_asset/__openerp__.py index a59e1b13aba..5ec4d3e4c65 100644 --- a/addons/account_asset/__openerp__.py +++ b/addons/account_asset/__openerp__.py @@ -29,6 +29,7 @@ Keeps track of depreciations, and creates corresponding journal entries. 'views/account_asset_views.xml', 'views/account_invoice_views.xml', 'views/account_asset_templates.xml', + 'views/product_views.xml', 'report/account_asset_report_views.xml', 'data/account_asset_data.xml', ], diff --git a/addons/account_asset/models/__init__.py b/addons/account_asset/models/__init__.py index a34a91f91b1..458b4b1b230 100644 --- a/addons/account_asset/models/__init__.py +++ b/addons/account_asset/models/__init__.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import account import account_asset -import account_asset_invoice +import account_invoice +import product diff --git a/addons/account_asset/models/account.py b/addons/account_asset/models/account.py new file mode 100644 index 00000000000..f2ee6075f74 --- /dev/null +++ b/addons/account_asset/models/account.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +from openerp import api, fields, models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + asset_depreciation_ids = fields.One2many('account.asset.depreciation.line', 'move_id', string='Assets Depreciation Lines', ondelete="restrict") + + @api.multi + def button_cancel(self): + for move in self: + for line in move.asset_depreciation_ids: + line.move_posted_check = False + return super(AccountMove, self).button_cancel() + + @api.multi + def post(self): + for move in self: + for depreciation_line in move.asset_depreciation_ids: + depreciation_line.post_lines_and_close_asset() + return super(AccountMove, self).post() diff --git a/addons/account_asset/models/account_asset.py b/addons/account_asset/models/account_asset.py index 4575adcd3f5..1587731342b 100644 --- a/addons/account_asset/models/account_asset.py +++ b/addons/account_asset/models/account_asset.py @@ -573,23 +573,3 @@ class AccountAssetDepreciationLine(models.Model): msg = _("You cannot delete posted installment lines.") raise UserError(msg) return super(AccountAssetDepreciationLine, self).unlink() - - -class AccountMove(models.Model): - _inherit = 'account.move' - - asset_depreciation_ids = fields.One2many('account.asset.depreciation.line', 'move_id', string='Assets Depreciation Lines', ondelete="restrict") - - @api.multi - def button_cancel(self): - for move in self: - for line in move.asset_depreciation_ids: - line.move_posted_check = False - return super(AccountMove, self).button_cancel() - - @api.multi - def post(self): - for move in self: - for depreciation_line in move.asset_depreciation_ids: - depreciation_line.post_lines_and_close_asset() - return super(AccountMove, self).post() diff --git a/addons/account_asset/models/account_invoice.py b/addons/account_asset/models/account_invoice.py index 81bc658ac98..c188260e33c 100644 --- a/addons/account_asset/models/account_invoice.py +++ b/addons/account_asset/models/account_invoice.py @@ -103,19 +103,3 @@ class AccountInvoiceLine(models.Model): elif invoice.type == 'in_invoice': self.asset_category_id = self.product_id.product_tmpl_id.asset_category_id.id super(AccountInvoiceLine, self)._set_additional_fields(invoice) - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - asset_category_id = fields.Many2one('account.asset.category', string='Asset Type', company_dependent=True, ondelete="restrict") - deferred_revenue_category_id = fields.Many2one('account.asset.category', string='Deferred Revenue Type', company_dependent=True, ondelete="restrict") - - - @api.multi - def _get_asset_accounts(self): - res = super(ProductTemplate, self)._get_asset_accounts() - if self.asset_category_id: - res['stock_input'] = self.property_account_expense_id - if self.deferred_revenue_category_id: - res['stock_output'] = self.property_account_income_id - return res \ No newline at end of file diff --git a/addons/account_asset/models/product.py b/addons/account_asset/models/product.py new file mode 100644 index 00000000000..10177f4f37d --- /dev/null +++ b/addons/account_asset/models/product.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from openerp import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + asset_category_id = fields.Many2one('account.asset.category', string='Asset Type', company_dependent=True, ondelete="restrict") + deferred_revenue_category_id = fields.Many2one('account.asset.category', string='Deferred Revenue Type', company_dependent=True, ondelete="restrict") + + @api.multi + def _get_asset_accounts(self): + res = super(ProductTemplate, self)._get_asset_accounts() + if self.asset_category_id: + res['stock_input'] = self.property_account_expense_id + if self.deferred_revenue_category_id: + res['stock_output'] = self.property_account_income_id + return res diff --git a/addons/account_asset/views/account_asset_views.xml b/addons/account_asset/views/account_asset_views.xml index b4d5f7ec837..1a54a50880a 100644 --- a/addons/account_asset/views/account_asset_views.xml +++ b/addons/account_asset/views/account_asset_views.xml @@ -235,19 +235,7 @@ - - - Product Template (form) - product.template - - - - - - - + Assets diff --git a/addons/account_asset/views/product_views.xml b/addons/account_asset/views/product_views.xml new file mode 100644 index 00000000000..57f8c00c27a --- /dev/null +++ b/addons/account_asset/views/product_views.xml @@ -0,0 +1,16 @@ + + + + + Product Template (form) + product.template + + + + + + + + \ No newline at end of file