diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 1b983dff050..a514d2bb58a 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -925,8 +925,7 @@ class AccountInvoice(models.Model): subtype_id=self.env.ref('mail.mt_note').id) return True - @api.multi - def invoice_validate(self): + def _check_invoice_reference(self): for invoice in self.filtered(lambda invoice: invoice.partner_id not in invoice.message_partner_ids): invoice.message_subscribe([invoice.partner_id.id]) @@ -936,6 +935,10 @@ class AccountInvoice(models.Model): if invoice.type in ('in_invoice', 'in_refund') and invoice.reference: if self.search([('type', '=', invoice.type), ('reference', '=', invoice.reference), ('company_id', '=', invoice.company_id.id), ('commercial_partner_id', '=', invoice.commercial_partner_id.id), ('id', '!=', invoice.id)]): raise UserError(_("Duplicated vendor reference detected. You probably encoded twice the same vendor bill/refund.")) + + @api.multi + def invoice_validate(self): + self._check_invoice_reference() return self.write({'state': 'open'}) @api.model diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 41c06eeb559..211bf774f1f 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -41,6 +41,13 @@ def migrate_tags_on_taxes(cr, registry): if len(tax_id.ids) == 1: tax_id.sudo().write({'tag_ids': [(6, 0, tax_template.tag_ids.ids)]}) +def preserve_existing_tags_on_taxes(cr, registry, module): + ''' This is a utility function used to preserve existing previous tags during upgrade of the module.''' + env = api.Environment(cr, SUPERUSER_ID, {}) + xml_records = env['ir.model.data'].search([('model', '=', 'account.account.tag'), ('module', 'like', module)]) + if xml_records: + cr.execute("update ir_model_data set noupdate = 't' where id in %s", [tuple(xml_records.ids)]) + # --------------------------------------------------------------- # Account Templates: Account, Tax, Tax Code and chart. + Wizard # --------------------------------------------------------------- diff --git a/addons/account_asset/models/account_asset.py b/addons/account_asset/models/account_asset.py index d6bc83b9087..78cd786cda8 100644 --- a/addons/account_asset/models/account_asset.py +++ b/addons/account_asset/models/account_asset.py @@ -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 diff --git a/addons/account_asset/static/src/js/account_asset.js b/addons/account_asset/static/src/js/account_asset.js index 5fe995a98a8..9b3b4d9b3ee 100644 --- a/addons/account_asset/static/src/js/account_asset.js +++ b/addons/account_asset/static/src/js/account_asset.js @@ -25,8 +25,8 @@ var WidgetOnButton = core.list_widget_registry.get('field').extend({ } return $('
').append((this.parent_state === 'open')? $('', { 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(); }, diff --git a/addons/l10n_fr/__init__.py b/addons/l10n_fr/__init__.py index 4b6eae9a9e4..50d8a515f48 100644 --- a/addons/l10n_fr/__init__.py +++ b/addons/l10n_fr/__init__.py @@ -4,3 +4,8 @@ # Copyright (c) 2008 JAILLET Simon - CrysaLEAD - www.crysalead.fr import models + + +def _preserve_tag_on_taxes(cr, registry): + from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes + preserve_existing_tags_on_taxes(cr, registry, 'l10n_fr') diff --git a/addons/l10n_fr/__manifest__.py b/addons/l10n_fr/__manifest__.py index be99c258b1d..dc0436ce456 100644 --- a/addons/l10n_fr/__manifest__.py +++ b/addons/l10n_fr/__manifest__.py @@ -39,4 +39,5 @@ configuration of their taxes and fiscal positions manually. 'data/account_reconcile_model_template.xml', 'data/account_chart_template_data.yml', ], + 'post_init_hook': '_preserve_tag_on_taxes', } diff --git a/addons/l10n_lu/__init__.py b/addons/l10n_lu/__init__.py index 67dee8c60db..4ca483f7aff 100644 --- a/addons/l10n_lu/__init__.py +++ b/addons/l10n_lu/__init__.py @@ -1,2 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + + +def _preserve_tag_on_taxes(cr, registry): + from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes + preserve_existing_tags_on_taxes(cr, registry, 'l10n_lu') diff --git a/addons/l10n_lu/__manifest__.py b/addons/l10n_lu/__manifest__.py index 59025f62596..6123ab2c81b 100644 --- a/addons/l10n_lu/__manifest__.py +++ b/addons/l10n_lu/__manifest__.py @@ -39,4 +39,5 @@ Notes: 'data/account.chart.template.csv', 'data/account_chart_template_data.yml', ], + 'post_init_hook': '_preserve_tag_on_taxes', } diff --git a/addons/l10n_no/__init__.py b/addons/l10n_no/__init__.py index 67dee8c60db..52c150be0f0 100644 --- a/addons/l10n_no/__init__.py +++ b/addons/l10n_no/__init__.py @@ -1,2 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + + +def _preserve_tag_on_taxes(cr, registry): + from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes + preserve_existing_tags_on_taxes(cr, registry, 'l10n_no') diff --git a/addons/l10n_no/__manifest__.py b/addons/l10n_no/__manifest__.py index ca292e63a93..6668e79bacb 100644 --- a/addons/l10n_no/__manifest__.py +++ b/addons/l10n_no/__manifest__.py @@ -15,4 +15,5 @@ Updated for Odoo 9 by Bringsvor Consulting AS