diff --git a/addons/account/account.py b/addons/account/account.py
index ee0da138daf..04bf1a02fe9 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -5,6 +5,7 @@ import math
from openerp.osv import expression
from openerp.tools.float_utils import float_round as round
+from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.exceptions import UserError
from openerp import api, fields, models, _
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 866ad49c01d..d71735a12b7 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -2,11 +2,13 @@
from openerp import api, fields, models, _
from openerp.osv import expression
+from openerp.tools import float_is_zero
from openerp.tools import float_compare, float_round
from openerp.tools.misc import formatLang
from openerp.exceptions import UserError, ValidationError
import time
+import math
class AccountCashboxLine(models.Model):
""" Cash Box Details """
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index e7ec5649f2f..a6e6ad03257 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -95,7 +95,7 @@ class AccountInvoice(models.Model):
if line.account_id.internal_type in ('receivable', 'payable'):
residual_signed += line.amount_residual * sign
if line.currency_id == self.currency_id:
- residual += line.currency_id and line.amount_residual_currency or line.amount_residual
+ residual += line.amount_residual_currency if line.currency_id else line.amount_residual
else:
from_currency = (line.currency_id and line.currency_id.with_context(date=line.date)) or line.company_id.currency_id.with_context(date=line.date)
residual += from_currency.compute(line.amount_residual, self.currency_id)
diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py
index 4a6f923979c..b324d06aded 100644
--- a/addons/account/report/account_invoice_report.py
+++ b/addons/account/report/account_invoice_report.py
@@ -158,18 +158,23 @@ class AccountInvoiceReport(models.Model):
# self._table = account_invoice_report
tools.drop_view_if_exists(cr, self._table)
cr.execute("""CREATE or REPLACE VIEW %s as (
+ WITH currency_rate (currency_id, rate, date_start, date_end) AS (
+ SELECT r.currency_id, r.rate, r.name AS date_start,
+ (SELECT name FROM res_currency_rate r2
+ WHERE r2.name > r.name AND
+ r2.currency_id = r.currency_id
+ ORDER BY r2.name ASC
+ LIMIT 1) AS date_end
+ FROM res_currency_rate r
+ )
%s
FROM (
%s %s %s
) AS sub
- JOIN res_currency_rate cr ON (cr.currency_id = sub.currency_id)
- WHERE
- cr.id IN (SELECT id
- FROM res_currency_rate cr2
- WHERE (cr2.currency_id = sub.currency_id)
- AND ((sub.date IS NOT NULL AND cr2.name <= sub.date)
- OR (sub.date IS NULL AND cr2.name <= NOW()))
- ORDER BY name DESC LIMIT 1)
+ JOIN currency_rate cr ON
+ (cr.currency_id = sub.currency_id AND
+ cr.date_start <= COALESCE(sub.date, NOW()) AND
+ (cr.date_end IS NULL OR cr.date_end > COALESCE(sub.date, NOW())))
)""" % (
self._table,
self._select(), self._sub_select(), self._from(), self._group_by()))
diff --git a/addons/account/res_config.py b/addons/account/res_config.py
index 9a6443854e5..b29e0175f1a 100644
--- a/addons/account/res_config.py
+++ b/addons/account/res_config.py
@@ -83,9 +83,11 @@ class AccountConfigSettings(models.TransientModel):
module_account_accountant = fields.Boolean(string='Full accounting features: journals, legal statements, chart of accounts, etc.',
help="""If you do not check this box, you will be able to do invoicing & payments,
but not accounting (Journal Items, Chart of Accounts, ...)""")
- module_account_asset = fields.Boolean(string='Assets management',
- help='This allows you to manage the assets owned by a company or a person.\n'
- 'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n'
+ module_account_asset = fields.Boolean(string='Assets management & Revenue recognition',
+ help='Asset management: This allows you to manage the assets owned by a company or a person.'
+ 'It keeps track of the depreciation occurred on those assets, and creates account move for those depreciation lines.\n\n'
+ 'Revenue recognition: This allows you to manage the Revenue recognition on selling product.'
+ 'It keeps track of the installment occurred on those revenue recognition, and creates account move for those installment lines.\n'
'-This installs the module account_asset. If you do not check this box, you will be able to do invoicing & payments, '
'but not accounting (Journal Items, Chart of Accounts, ...)')
module_account_budget = fields.Boolean(string='Budget management',
diff --git a/addons/account/static/src/css/account_reconciliation.scss b/addons/account/static/src/css/account_reconciliation.scss
index 1e1c3e5ed23..c2d4973d259 100644
--- a/addons/account/static/src/css/account_reconciliation.scss
+++ b/addons/account/static/src/css/account_reconciliation.scss
@@ -560,11 +560,10 @@ $aestetic_animation_speed: 300ms;
}
&.add_line_container {
- &:nth-child(2n+1) {
- width: 98%;
- float: none;
- margin: auto;
- }
+ width: 98%;
+ float: none;
+ clear: both;
+ margin: auto;
td {
text-align: center;
diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js
index 86b486de48b..c650c15d291 100644
--- a/addons/account/static/src/js/account_reconciliation_widgets.js
+++ b/addons/account/static/src/js/account_reconciliation_widgets.js
@@ -1853,10 +1853,11 @@ var bankStatementReconciliationLine = abstractReconciliationLine.extend({
changePartnerClickHandler: function() {
var self = this;
- self.$(".change_partner_container").find("input").attr("placeholder", self.st_line.partner_name);
- self.$(".change_partner_container").show();
- self.$(".partner_name").hide();
- self.change_partner_field.$drop_down.trigger("click");
+ $.when(self.changePartner(false)).then(function(){
+ self.$(".change_partner_container").show();
+ self.$(".partner_name").hide();
+ self.change_partner_field.$drop_down.trigger("click");
+ })
},
diff --git a/addons/account/tests/test_search.py b/addons/account/tests/test_search.py
index 7a8ceaef362..f79e368d9c2 100644
--- a/addons/account/tests/test_search.py
+++ b/addons/account/tests/test_search.py
@@ -54,3 +54,18 @@ class TestSearch(AccountTestUsers):
asale_ids = self.account_model.name_search(name='XX200', operator='ilike', args=[('id', 'in', self.all_ids)])
self.assertEqual(set([self.asale[0]]), set([a[0] for a in asale_ids]), "name_search 'ilike XX200' should have returned Product Sales account only")
+
+ def test_property_unset_search(self):
+ cr, uid = self.cr, self.uid
+ res_partner_model = self.registry('res.partner')
+ account_payment_term_model = self.registry('account.payment.term')
+
+ a_partner = res_partner_model.create(cr, uid, {'name': 'test partner'})
+ a_payment_term = account_payment_term_model.create(cr, uid, {'name': 'test payment term'})
+
+ partner_ids = res_partner_model.search(cr, uid, [('property_payment_term', '=', False), ('id', '=', a_partner)])
+ self.assertTrue(partner_ids, "unset property field 'propety_payment_term' should have been found")
+
+ res_partner_model.write(cr, uid, [a_partner], {'property_payment_term': a_payment_term})
+ partner_ids = res_partner_model.search(cr, uid, [('property_payment_term', '=', False), ('id', '=', a_partner)])
+ self.assertFalse(partner_ids, "set property field 'propety_payment_term' should not have been found")
diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml
index 9bacb760f79..b6d801e27f9 100644
--- a/addons/account/views/account_invoice_view.xml
+++ b/addons/account/views/account_invoice_view.xml
@@ -545,7 +545,7 @@
tree,form,calendar,graph[('type','in', ['out_invoice', 'out_refund']), ('state', 'not in', ['draft', 'cancel'])]
- {'type':False}
+ {'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}
diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py
index 4aaf8b8ca16..cb6645739a4 100644
--- a/addons/account/wizard/account_invoice_refund.py
+++ b/addons/account/wizard/account_invoice_refund.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
+from openerp.tools.safe_eval import safe_eval as eval
from openerp.exceptions import UserError
diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py
index 605e4379cee..17a05e1da90 100644
--- a/addons/account_analytic_analysis/account_analytic_analysis.py
+++ b/addons/account_analytic_analysis/account_analytic_analysis.py
@@ -669,34 +669,36 @@ class account_analytic_account(osv.osv):
context = context or {}
journal_obj = self.pool.get('account.journal')
+ fpos_obj = self.pool['account.fiscal.position']
+ partner = contract.partner_id
- if not contract.partner_id:
+ if not partner:
raise UserError(_("You must first select a Customer for Contract %s!") % contract.name )
- fpos = contract.partner_id.property_account_position or False
+ fpos_id = fpos_obj.get_fiscal_position(cr, uid, partner.company_id.id, partner.id, context=context)
journal_ids = journal_obj.search(cr, uid, [('type', '=','sale'),('company_id', '=', contract.company_id.id or False)], limit=1)
if not journal_ids:
raise UserError(_('Please define a sale journal for the company "%s".') % (contract.company_id.name or '', ))
- partner_payment_term = contract.partner_id.property_payment_term and contract.partner_id.property_payment_term.id or False
+ partner_payment_term = partner.property_payment_term and partner.property_payment_term.id or False
currency_id = False
if contract.pricelist_id:
currency_id = contract.pricelist_id.currency_id.id
- elif contract.partner_id.property_product_pricelist:
- currency_id = contract.partner_id.property_product_pricelist.currency_id.id
+ elif partner.property_product_pricelist:
+ currency_id = partner.property_product_pricelist.currency_id.id
elif contract.company_id:
currency_id = contract.company_id.currency_id.id
invoice = {
- 'account_id': contract.partner_id.property_account_receivable.id,
+ 'account_id': partner.property_account_receivable.id,
'type': 'out_invoice',
- 'partner_id': contract.partner_id.id,
+ 'partner_id': partner.id,
'currency_id': currency_id,
'journal_id': len(journal_ids) and journal_ids[0] or False,
'date_invoice': contract.recurring_next_date,
'origin': contract.code,
- 'fiscal_position_id': fpos and fpos.id,
+ 'fiscal_position_id': fpos_id,
'payment_term_id': partner_payment_term,
'company_id': contract.company_id.id or False,
}
diff --git a/addons/account_asset/__init__.py b/addons/account_asset/__init__.py
index 8c1b6b60c16..f826640892b 100644
--- a/addons/account_asset/__init__.py
+++ b/addons/account_asset/__init__.py
@@ -1,23 +1,4 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
import account_asset
import account_asset_invoice
diff --git a/addons/account_asset/__openerp__.py b/addons/account_asset/__openerp__.py
index 010fc167bfc..7a1f36b6f8c 100644
--- a/addons/account_asset/__openerp__.py
+++ b/addons/account_asset/__openerp__.py
@@ -1,36 +1,20 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
{
- 'name': 'Assets Management',
+ 'name': 'Assets & Revenue Recognitions Management',
'version': '1.0',
- 'depends': ['account'],
- 'author': 'OpenERP S.A.',
+ 'depends': ['account_accountant'],
+ 'author': 'Odoo S.A.',
'description': """
-Financial and accounting asset management.
-==========================================
+Assets management
+=================
+Manage assets owned by a company or a person.
+Keeps track of depreciations, and creates corresponding journal entries.
-This Module manages the assets owned by a company or an individual. It will keep
-track of depreciation's occurred on those assets. And it allows to create Move's
-of the depreciation lines.
+Revenue recognition
+===================
+Manage revenue recognition on product sales.
+Keeps track of the revenue recognition installments, and creates corresponding journal entries.
""",
'website': 'https://www.odoo.com/page/accounting',
@@ -39,23 +23,23 @@ of the depreciation lines.
'demo': [
'account_asset_demo.yml',
],
- 'test': [
- '../account/test/account_minimal_test.xml',
- 'test/account_asset_demo_test.xml',
- 'test/account_asset_demo.yml',
- 'test/account_asset.yml',
- 'test/account_asset_wizard.yml',
- ],
+ # 'test': [
+ # '../account/test/account_minimal_test.xml',
+ # 'test/account_asset_demo_test.xml',
+ # ],
'data': [
'security/account_asset_security.xml',
'security/ir.model.access.csv',
'wizard/account_asset_change_duration_view.xml',
'wizard/wizard_asset_compute_view.xml',
- 'account_asset_view.xml',
- 'account_asset_invoice_view.xml',
+ 'views/account_asset_view.xml',
+ 'views/account_asset_invoice_view.xml',
'report/account_asset_report_view.xml',
+ 'views/account_asset.xml',
+ ],
+ 'qweb': [
+ "static/src/xml/account_asset_template.xml",
],
- 'auto_install': False,
'installable': True,
'application': False,
}
diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py
index 7a326a8df7a..ebe22bc408c 100644
--- a/addons/account_asset/account_asset.py
+++ b/addons/account_asset/account_asset.py
@@ -1,335 +1,313 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
-import time
-from datetime import datetime
+from datetime import date, datetime
from dateutil.relativedelta import relativedelta
-from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
-from openerp.tools.translate import _
-from openerp.exceptions import UserError
+from openerp import api, fields, models, _
+from openerp.exceptions import UserError, ValidationError
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DF
-class account_asset_category(osv.osv):
+
+class AccountAssetCategory(models.Model):
_name = 'account.asset.category'
_description = 'Asset category'
- _columns = {
- 'name': fields.char('Name', required=True, select=1),
- 'note': fields.text('Note'),
- 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
- 'account_asset_id': fields.many2one('account.account', 'Asset Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)]),
- 'account_depreciation_id': fields.many2one('account.account', 'Depreciation Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)]),
- 'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)]),
- 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
- 'company_id': fields.many2one('res.company', 'Company', required=True),
- 'method': fields.selection([('linear','Linear: Computed on basis of Gross Value / Number of Depreciations'),('degressive','Degressive: Computed on basis of Residual Value * Degressive Factor')], 'Computation Method', required=True, help="Choose the method to use to compute the amount of depreciation lines.\n"\
- " * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n" \
- " * Degressive: Calculated on basis of: Residual Value * Degressive Factor"),
- 'method_number': fields.integer('Number of Depreciations', help="The number of depreciations needed to depreciate your asset"),
- 'method_period': fields.integer('Period Length', help="State here the time between 2 depreciations, in months", required=True),
- 'method_progress_factor': fields.float('Degressive Factor'),
- 'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True,
- help="Choose the method to use to compute the dates and number of depreciation lines.\n"\
- " * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
- " * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
- 'method_end': fields.date('Ending date'),
- 'prorata':fields.boolean('Prorata Temporis', help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'),
- 'open_asset': fields.boolean('Skip Draft State', help="Check this if you want to automatically confirm the assets of this category when created by invoices."),
- }
+ active = fields.Boolean(default=True)
+ name = fields.Char(required=True, index=True)
+ note = fields.Text()
+ account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account')
+ account_asset_id = fields.Many2one('account.account', string='Asset Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)])
+ account_income_recognition_id = fields.Many2one('account.account', string='Recognition Income Account', domain=[('internal_type','=','other'), ('deprecated', '=', False)], oldname='account_expense_depreciation_id')
+ account_depreciation_id = fields.Many2one('account.account', string='Depreciation Account', required=True, domain=[('internal_type','=','other'), ('deprecated', '=', False)])
+ journal_id = fields.Many2one('account.journal', string='Journal', required=True)
+ company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env['res.company']._company_default_get('account.asset.category'))
+ method = fields.Selection([('linear', 'Linear'), ('degressive', 'Degressive')], string='Computation Method', required=True, default='linear',
+ help="Choose the method to use to compute the amount of depreciation lines.\n"
+ " * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n"
+ " * Degressive: Calculated on basis of: Residual Value * Degressive Factor")
+ method_number = fields.Integer(string='Number of Depreciations', default=5, help="The number of depreciations needed to depreciate your asset")
+ method_period = fields.Integer(string='Period Length', default=1, help="State here the time between 2 depreciations, in months", required=True)
+ method_progress_factor = fields.Float('Degressive Factor', default=0.3)
+ method_time = fields.Selection([('number', 'Number of Depreciations'), ('end', 'Ending Date')], string='Time Method', required=True, default='number',
+ help="Choose the method to use to compute the dates and number of depreciation lines.\n"
+ " * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n"
+ " * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond.")
+ method_end = fields.Date('Ending date')
+ prorata = fields.Boolean(string='Prorata Temporis', help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first of January')
+ open_asset = fields.Boolean(string='Skip Draft State', help="Check this if you want to automatically confirm the assets of this category when created by invoices.")
+ type = fields.Selection([('sale', 'Sale: Revenue Recognition'), ('purchase', 'Purchase: Asset')], required=True, index=True, default='purchase')
- _defaults = {
- 'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.category', context=context),
- 'method': 'linear',
- 'method_number': 5,
- 'method_time': 'number',
- 'method_period': 12,
- 'method_progress_factor': 0.3,
- }
+ @api.onchange('account_asset_id')
+ def onchange_account_asset(self):
+ self.account_depreciation_id = self.account_asset_id
- def onchange_account_asset(self, cr, uid, ids, account_asset_id, context=None):
- res = {'value':{}}
- if account_asset_id:
- res['value'] = {'account_depreciation_id': account_asset_id}
- return res
+ @api.onchange('type')
+ def onchange_type(self):
+ if self.type == 'sale':
+ self.prorata = True
+ self.method_period = 1
+ else:
+ self.method_period = 12
-class account_asset_asset(osv.osv):
+class AccountAssetAsset(models.Model):
_name = 'account.asset.asset'
- _description = 'Asset'
+ _description = 'Asset/Revenue Recognition'
+ _inherit = ['mail.thread', 'ir.needaction_mixin']
- def unlink(self, cr, uid, ids, context=None):
- for asset in self.browse(cr, uid, ids, context=context):
- if asset.account_move_line_ids:
- raise UserError(_('You cannot delete an asset that contains posted depreciation lines.'))
- return super(account_asset_asset, self).unlink(cr, uid, ids, context=context)
+ account_move_line_ids = fields.One2many('account.move.line', 'asset_id', string='Entries', readonly=True, states={'draft': [('readonly', False)]})
+ entry_count = fields.Integer(compute='_entry_count', string='# Asset Entries')
+ name = fields.Char(string='Asset/Deferred Revenue Name', required=True, readonly=True, states={'draft': [('readonly', False)]})
+ code = fields.Char(string='Reference', size=32, readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env['ir.sequence'].next_by_code('account.asset.code'))
+ value = fields.Float(string='Gross Value', required=True, readonly=True, digits=0, states={'draft': [('readonly', False)]}, oldname='purchase_value')
+ currency_id = fields.Many2one('res.currency', string='Currency', required=True, readonly=True, states={'draft': [('readonly', False)]},
+ default=lambda self: self.env.user.company_id.currency_id.id)
+ company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, states={'draft': [('readonly', False)]},
+ default=lambda self: self.env['res.company']._company_default_get('account.asset.asset'))
+ note = fields.Text()
+ category_id = fields.Many2one('account.asset.category', string='Category', required=True, change_default=True, readonly=True, states={'draft': [('readonly', False)]})
+ date = fields.Date(string='Date', required=True, readonly=True, states={'draft': [('readonly', False)]}, default=fields.Date.context_today, oldname="purchase_date")
+ state = fields.Selection([('draft', 'Draft'), ('open', 'Running'), ('close', 'Close')], 'Status', required=True, copy=False, default='draft',
+ help="When an asset is created, the status is 'Draft'.\n"
+ "If the asset is confirmed, the status goes in 'Running' and the depreciation lines can be posted in the accounting.\n"
+ "You can manually close an asset when the depreciation is over. If the last line of depreciation is posted, the asset automatically goes in that status.")
+ active = fields.Boolean(default=True)
+ partner_id = fields.Many2one('res.partner', string='Partner', readonly=True, states={'draft': [('readonly', False)]})
+ method = fields.Selection([('linear', 'Linear'), ('degressive', 'Degressive')], string='Computation Method', required=True, readonly=True, states={'draft': [('readonly', False)]}, default='linear',
+ help="Choose the method to use to compute the amount of depreciation lines.\n * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n"
+ " * Degressive: Calculated on basis of: Residual Value * Degressive Factor")
+ method_number = fields.Integer(string='Number of Depreciations', readonly=True, states={'draft': [('readonly', False)]}, default=5, help="The number of depreciations needed to depreciate your asset")
+ method_period = fields.Integer(string='Number of Months in a Period', required=True, readonly=True, default=12, states={'draft': [('readonly', False)]},
+ help="The amount of time between two depreciations, in months")
+ method_end = fields.Date(string='Ending Date', readonly=True, states={'draft': [('readonly', False)]})
+ method_progress_factor = fields.Float(string='Degressive Factor', readonly=True, default=0.3, states={'draft': [('readonly', False)]})
+ value_residual = fields.Float(compute='_amount_residual', method=True, digits=0, string='Residual Value')
+ method_time = fields.Selection([('number', 'Number of Depreciations'), ('end', 'Ending Date')], string='Time Method', required=True, readonly=True, default='number', states={'draft': [('readonly', False)]},
+ help="Choose the method to use to compute the dates and number of depreciation lines.\n"
+ " * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n"
+ " * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond.")
+ prorata = fields.Boolean(string='Prorata Temporis', readonly=True, states={'draft': [('readonly', False)]},
+ help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January / Start date of fiscal year')
+ history_ids = fields.One2many('account.asset.history', 'asset_id', string='History', readonly=True)
+ depreciation_line_ids = fields.One2many('account.asset.depreciation.line', 'asset_id', string='Depreciation Lines', readonly=True, states={'draft': [('readonly', False)], 'open': [('readonly', False)]})
+ salvage_value = fields.Float(string='Salvage Value', digits=0, readonly=True, states={'draft': [('readonly', False)]},
+ help="It is the amount you plan to have that you cannot depreciate.")
+ invoice_id = fields.Many2one('account.invoice', string='Invoice', states={'draft': [('readonly', False)]}, copy=False)
+ type = fields.Selection(related="category_id.type", string='Type', required=True, default='purchase')
- def _get_last_depreciation_date(self, cr, uid, ids, context=None):
+ @api.multi
+ def unlink(self):
+ for asset in self:
+ if asset.state in ['open', 'close']:
+ raise UserError(_('You cannot delete a document is in %s state.') % (asset.state,))
+ if asset.account_move_line_ids:
+ raise UserError(_('You cannot delete a document that contains posted lines.'))
+ return super(AccountAssetAsset, self).unlink()
+ @api.multi
+ def _get_last_depreciation_date(self):
"""
@param id: ids of a account.asset.asset objects
@return: Returns a dictionary of the effective dates of the last depreciation entry made for given asset ids. If there isn't any, return the purchase date of this asset
"""
- cr.execute("""
- SELECT a.id as id, COALESCE(MAX(l.date),a.purchase_date) AS date
+ self.env.cr.execute("""
+ SELECT a.id as id, COALESCE(MAX(l.date),a.date) AS date
FROM account_asset_asset a
LEFT JOIN account_move_line l ON (l.asset_id = a.id)
WHERE a.id IN %s
- GROUP BY a.id, a.purchase_date """, (tuple(ids),))
- return dict(cr.fetchall())
+ GROUP BY a.id, a.date """, (tuple(self.ids),))
+ result = dict(self.env.cr.fetchall())
+ return result
- def _compute_board_amount(self, cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=None):
- #by default amount = 0
+ def _compute_board_amount(self, sequence, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date):
amount = 0
- if i == undone_dotation_number:
+ if sequence == undone_dotation_number:
amount = residual_amount
else:
- if asset.method == 'linear':
+ if self.method == 'linear':
amount = amount_to_depr / (undone_dotation_number - len(posted_depreciation_line_ids))
- if asset.prorata:
- amount = amount_to_depr / asset.method_number
+ if self.prorata and self.category_id.type == 'purchase':
+ amount = amount_to_depr / self.method_number
days = total_days - float(depreciation_date.strftime('%j'))
- if i == 1:
- amount = (amount_to_depr / asset.method_number) / total_days * days
- elif i == undone_dotation_number:
- amount = (amount_to_depr / asset.method_number) / total_days * (total_days - days)
- elif asset.method == 'degressive':
- amount = residual_amount * asset.method_progress_factor
- if asset.prorata:
+ if sequence == 1:
+ amount = (amount_to_depr / self.method_number) / total_days * days
+ elif sequence == undone_dotation_number:
+ amount = (amount_to_depr / self.method_number) / total_days * (total_days - days)
+ elif self.method == 'degressive':
+ amount = residual_amount * self.method_progress_factor
+ if self.prorata:
days = total_days - float(depreciation_date.strftime('%j'))
- if i == 1:
- amount = (residual_amount * asset.method_progress_factor) / total_days * days
- elif i == undone_dotation_number:
- amount = (residual_amount * asset.method_progress_factor) / total_days * (total_days - days)
+ if sequence == 1:
+ amount = (residual_amount * self.method_progress_factor) / total_days * days
+ elif sequence == undone_dotation_number:
+ amount = (residual_amount * self.method_progress_factor) / total_days * (total_days - days)
return amount
- def _compute_board_undone_dotation_nb(self, cr, uid, asset, depreciation_date, total_days, context=None):
- undone_dotation_number = asset.method_number
- if asset.method_time == 'end':
- end_date = datetime.strptime(asset.method_end, '%Y-%m-%d')
+ def _compute_board_undone_dotation_nb(self, depreciation_date, total_days):
+ undone_dotation_number = self.method_number
+ if self.method_time == 'end':
+ end_date = datetime.strptime(self.method_end, DF).date()
undone_dotation_number = 0
while depreciation_date <= end_date:
- depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period))
+ depreciation_date = date(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+self.method_period)
undone_dotation_number += 1
- if asset.prorata:
+ if self.prorata and self.category_id.type == 'purchase':
undone_dotation_number += 1
return undone_dotation_number
- def compute_depreciation_board(self, cr, uid, ids, context=None):
- depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
- currency_obj = self.pool.get('res.currency')
- for asset in self.browse(cr, uid, ids, context=context):
- if asset.value_residual == 0.0:
- continue
- posted_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_check', '=', True)],order='depreciation_date desc')
- old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)])
- if old_depreciation_line_ids:
- depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context)
+ @api.multi
+ def compute_depreciation_board(self):
+ self.ensure_one()
- amount_to_depr = residual_amount = asset.value_residual
- if asset.prorata:
- depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d')
+ posted_depreciation_line_ids = self.depreciation_line_ids.filtered(lambda x: x.move_check)
+ unposted_depreciation_line_ids = self.depreciation_line_ids.filtered(lambda x: not x.move_check)
+
+ # Remove old unposted depreciation lines. We cannot use unlink() with One2many field
+ commands = [(2, line_id.id, False) for line_id in unposted_depreciation_line_ids]
+
+ if self.value != 0.0:
+ amount_to_depr = residual_amount = self.value_residual
+ if self.prorata:
+ depreciation_date = datetime.strptime(self._get_last_depreciation_date()[self.id], DF).date()
else:
- # depreciation_date = 1st January of purchase year
- purchase_date = datetime.strptime(asset.purchase_date, '%Y-%m-%d')
- #if we already have some previous validated entries, starting date isn't 1st January but last entry + method period
- if (len(posted_depreciation_line_ids)>0):
- last_depreciation_date = datetime.strptime(depreciation_lin_obj.browse(cr,uid,posted_depreciation_line_ids[0],context=context).depreciation_date, '%Y-%m-%d')
- depreciation_date = (last_depreciation_date+relativedelta(months=+asset.method_period))
+ # depreciation_date = 1st of January of purchase year
+ asset_date = datetime.strptime(self.date, DF).date()
+ # if we already have some previous validated entries, starting date isn't 1st January but last entry + method period
+ if posted_depreciation_line_ids and posted_depreciation_line_ids[0].depreciation_date:
+ last_depreciation_date = datetime.strptime(posted_depreciation_line_ids[0].depreciation_date, DF).date()
+ depreciation_date = last_depreciation_date + relativedelta(months=+self.method_period)
else:
- depreciation_date = datetime(purchase_date.year, 1, 1)
+ depreciation_date = asset_date
day = depreciation_date.day
month = depreciation_date.month
year = depreciation_date.year
total_days = (year % 4) and 365 or 366
- undone_dotation_number = self._compute_board_undone_dotation_nb(cr, uid, asset, depreciation_date, total_days, context=context)
+ undone_dotation_number = self._compute_board_undone_dotation_nb(depreciation_date, total_days)
for x in range(len(posted_depreciation_line_ids), undone_dotation_number):
- i = x + 1
- amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context)
+ sequence = x + 1
+ amount = self._compute_board_amount(sequence, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date)
+ amount = self.currency_id.round(amount)
residual_amount -= amount
vals = {
- 'amount': amount,
- 'asset_id': asset.id,
- 'sequence': i,
- 'name': str(asset.id) +'/' + str(i),
- 'remaining_value': residual_amount,
- 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount),
- 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),
+ 'amount': amount,
+ 'asset_id': self.id,
+ 'sequence': sequence,
+ 'name': (self.code or str(self.id)) + '/' + str(sequence),
+ 'remaining_value': residual_amount,
+ 'depreciated_value': (self.value - self.salvage_value) - (residual_amount + amount),
+ 'depreciation_date': depreciation_date.strftime(DF),
}
- depreciation_lin_obj.create(cr, uid, vals, context=context)
+ commands.append((0, False, vals))
# Considering Depr. Period as months
- depreciation_date = (datetime(year, month, day) + relativedelta(months=+asset.method_period))
+ depreciation_date = date(year, month, day) + relativedelta(months=+self.method_period)
day = depreciation_date.day
month = depreciation_date.month
year = depreciation_date.year
+
+ self.write({'depreciation_line_ids': commands})
+
return True
- def validate(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- return self.write(cr, uid, ids, {
- 'state':'open'
- }, context)
+ @api.multi
+ def validate(self):
+ self.write({'state': 'open'})
- def set_to_close(self, cr, uid, ids, context=None):
- return self.write(cr, uid, ids, {'state': 'close'}, context=context)
+ @api.multi
+ def set_to_close(self):
+ unposted_dep_line = self.env['account.asset.depreciation.line'].search_count(
+ [('asset_id', 'in', self.ids), ('move_check', '=', False)])
+ if unposted_dep_line:
+ raise UserError(_('You cannot close a document which has unposted lines.'))
+ self.message_post(body=_("Document closed."))
+ self.write({'state': 'close'})
- def set_to_draft(self, cr, uid, ids, context=None):
- return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
+ @api.multi
+ def set_to_draft(self):
+ self.write({'state': 'draft'})
- def _amount_residual(self, cr, uid, ids, name, args, context=None):
- cr.execute("""SELECT
- l.asset_id as id, SUM(abs(l.debit-l.credit)) AS amount
- FROM
- account_move_line l
- WHERE
- l.asset_id IN %s GROUP BY l.asset_id """, (tuple(ids),))
- res=dict(cr.fetchall())
- for asset in self.browse(cr, uid, ids, context):
- company_currency = asset.company_id.currency_id.id
- current_currency = asset.currency_id.id
- amount = self.pool['res.currency'].compute(cr, uid, company_currency, current_currency, res.get(asset.id, 0.0), context=context)
- res[asset.id] = asset.purchase_value - amount - asset.salvage_value
- for id in ids:
- res.setdefault(id, 0.0)
- return res
+ @api.one
+ @api.depends('value', 'salvage_value', 'depreciation_line_ids')
+ def _amount_residual(self):
+ total_amount = 0.0
+ for line in self.depreciation_line_ids:
+ if line.move_check:
+ total_amount += line.amount
+ self.value_residual = self.value - total_amount - self.salvage_value
- def onchange_company_id(self, cr, uid, ids, company_id=False, context=None):
- val = {}
- if company_id:
- company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
- val['currency_id'] = company.currency_id.id
- return {'value': val}
-
- def onchange_purchase_salvage_value(self, cr, uid, ids, purchase_value, salvage_value, context=None):
- val = {}
- for asset in self.browse(cr, uid, ids, context=context):
- if purchase_value:
- val['value_residual'] = purchase_value - salvage_value
- if salvage_value:
- val['value_residual'] = purchase_value - salvage_value
- return {'value': val}
- def _entry_count(self, cr, uid, ids, field_name, arg, context=None):
- MoveLine = self.pool('account.move.line')
- return {
- asset_id: MoveLine.search_count(cr, uid, [('asset_id', '=', asset_id)], context=context)
- for asset_id in ids
- }
- _columns = {
- 'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
- 'entry_count': fields.function(_entry_count, string='# Asset Entries', type='integer'),
- 'name': fields.char('Asset Name', required=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'code': fields.char('Reference', size=32, readonly=True, states={'draft':[('readonly',False)]}),
- 'purchase_value': fields.float('Gross Value', required=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'currency_id': fields.many2one('res.currency','Currency',required=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'note': fields.text('Note'),
- 'category_id': fields.many2one('account.asset.category', 'Asset Category', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'purchase_date': fields.date('Purchase Date', required=True, readonly=True, states={'draft':[('readonly',False)]}),
- 'state': fields.selection([('draft','Draft'),('open','Running'),('close','Close')], 'Status', required=True, copy=False,
- help="When an asset is created, the status is 'Draft'.\n" \
- "If the asset is confirmed, the status goes in 'Running' and the depreciation lines can be posted in the accounting.\n" \
- "You can manually close an asset when the depreciation is over. If the last line of depreciation is posted, the asset automatically goes in that status."),
- 'active': fields.boolean('Active'),
- 'partner_id': fields.many2one('res.partner', 'Supplier', readonly=True, states={'draft':[('readonly',False)]}),
- 'method': fields.selection([('linear','Linear'),('degressive','Degressive')], 'Computation Method', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose the method to use to compute the amount of depreciation lines.\n"\
- " * Linear: Calculated on basis of: Gross Value / Number of Depreciations\n" \
- " * Degressive: Calculated on basis of: Residual Value * Degressive Factor"),
- 'method_number': fields.integer('Number of Depreciations', readonly=True, states={'draft':[('readonly',False)]}, help="The number of depreciations needed to depreciate your asset"),
- 'method_period': fields.integer('Number of Months in a Period', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="The amount of time between two depreciations, in months"),
- 'method_end': fields.date('Ending Date', readonly=True, states={'draft':[('readonly',False)]}),
- 'method_progress_factor': fields.float('Degressive Factor', readonly=True, states={'draft':[('readonly',False)]}),
- 'value_residual': fields.function(_amount_residual, method=True, digits=0, string='Residual Value'),
- 'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True, readonly=True, states={'draft':[('readonly',False)]},
- help="Choose the method to use to compute the dates and number of depreciation lines.\n"\
- " * Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
- " * Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
- 'prorata':fields.boolean('Prorata Temporis', readonly=True, states={'draft':[('readonly',False)]}, help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'),
- 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),
- 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),
- 'salvage_value': fields.float('Salvage Value', digits=0, help="It is the amount you plan to have that you cannot depreciate.", readonly=True, states={'draft':[('readonly',False)]}),
- }
- _defaults = {
- 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').next_by_code(cr, uid, 'account.asset.code'),
- 'purchase_date': lambda obj, cr, uid, context: time.strftime('%Y-%m-%d'),
- 'active': True,
- 'state': 'draft',
- 'method': 'linear',
- 'method_number': 5,
- 'method_time': 'number',
- 'method_period': 12,
- 'method_progress_factor': 0.3,
- 'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
- 'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.asset',context=context),
- }
+ @api.onchange('company_id')
+ def onchange_company_id(self):
+ self.currency_id = self.company_id.currency_id.id
- def _check_recursion(self, cr, uid, ids, context=None, parent=None):
- return super(account_asset_asset, self)._check_recursion(cr, uid, ids, context=context, parent=parent)
+ @api.multi
+ @api.depends('account_move_line_ids')
+ def _entry_count(self):
+ for asset in self:
+ asset.entry_count = self.env['account.move.line'].search_count([('asset_id', '=', asset.id)])
- def _check_prorata(self, cr, uid, ids, context=None):
- for asset in self.browse(cr, uid, ids, context=context):
- if asset.prorata and asset.method_time != 'number':
- return False
- return True
+ @api.one
+ @api.constrains('prorata', 'method_time')
+ def _check_prorata(self):
+ if self.prorata and self.method_time != 'number':
+ raise ValidationError(_('Prorata temporis can be applied only for time method "number of depreciations".'))
- _constraints = [
- (_check_prorata, 'Prorata temporis can be applied only for time method "number of depreciations".', ['prorata']),
- ]
+ @api.onchange('category_id')
+ def onchange_category_id(self):
+ vals = self.onchange_category_id_values(self.category_id.id)
+ # We cannot use 'write' on an object that doesn't exist yet
+ if vals:
+ for k, v in vals['value'].iteritems():
+ setattr(self, k, v)
- def onchange_category_id(self, cr, uid, ids, category_id, context=None):
- res = {'value':{}}
- asset_categ_obj = self.pool.get('account.asset.category')
+ def onchange_category_id_values(self, category_id):
if category_id:
- category_obj = asset_categ_obj.browse(cr, uid, category_id, context=context)
- res['value'] = {
- 'method': category_obj.method,
- 'method_number': category_obj.method_number,
- 'method_time': category_obj.method_time,
- 'method_period': category_obj.method_period,
- 'method_progress_factor': category_obj.method_progress_factor,
- 'method_end': category_obj.method_end,
- 'prorata': category_obj.prorata,
+ category = self.env['account.asset.category'].browse(category_id)
+ return {
+ 'value': {
+ 'method': category.method,
+ 'method_number': category.method_number,
+ 'method_time': category.method_time,
+ 'method_period': category.method_period,
+ 'method_progress_factor': category.method_progress_factor,
+ 'method_end': category.method_end,
+ 'prorata': category.prorata,
+ }
}
+
+ @api.onchange('method_time')
+ def onchange_method_time(self):
+ if self.method_time != 'number':
+ self.prorata = False
+
+ @api.multi
+ def copy_data(self, default=None):
+ if default is None:
+ default = {}
+ default['name'] = self.name + _(' (copy)')
+ return super(AccountAssetAsset, self).copy_data(default)[0]
+
+ @api.multi
+ def _compute_entries(self, date):
+ depreciation_ids = self.env['account.asset.depreciation.line'].search([
+ ('asset_id', 'in', self.ids), ('depreciation_date', '<=', date),
+ ('move_check', '=', False)])
+ return depreciation_ids.create_move()
+
+ @api.model
+ def create(self, vals):
+ asset = super(AccountAssetAsset, self.with_context(mail_create_nolog=True)).create(vals)
+ asset.compute_depreciation_board()
+ return asset
+
+ @api.multi
+ def write(self, vals):
+ res = super(AccountAssetAsset, self).write(vals)
+ if 'depreciation_line_ids' not in vals:
+ self.compute_depreciation_board()
return res
- def onchange_method_time(self, cr, uid, ids, method_time='number', context=None):
- res = {'value': {}}
- if method_time != 'number':
- res['value'] = {'prorata': False}
- return res
-
- def _compute_entries(self, cr, uid, ids, date, context=None):
- result = []
- depreciation_obj = self.pool.get('account.asset.depreciation.line')
- depreciation_ids = depreciation_obj.search(cr, uid, [('asset_id', 'in', ids), ('depreciation_date', '<=', date), ('move_check', '=', False)], context=context)
- context = dict(context or {}, depreciation_date=time.strftime('%Y-%m-%d'))
- return depreciation_obj.create_move(cr, uid, depreciation_ids, context=context)
-
- def create(self, cr, uid, vals, context=None):
- asset_id = super(account_asset_asset, self).create(cr, uid, vals, context=context)
- self.compute_depreciation_board(cr, uid, [asset_id], context=context)
- return asset_id
-
- def open_entries(self, cr, uid, ids, context=None):
- context = dict(context or {}, search_default_asset_id=ids, default_asset_id=ids)
+ @api.multi
+ def open_entries(self):
return {
'name': _('Journal Items'),
'view_type': 'form',
@@ -337,78 +315,74 @@ class account_asset_asset(osv.osv):
'res_model': 'account.move.line',
'view_id': False,
'type': 'ir.actions.act_window',
- 'context': context,
+ 'context': dict(self.env.context or {}, search_default_asset_id=self.id, default_asset_id=self.id),
}
-class account_asset_depreciation_line(osv.osv):
+class AccountAssetDepreciationLine(models.Model):
_name = 'account.asset.depreciation.line'
_description = 'Asset depreciation line'
- def _get_move_check(self, cr, uid, ids, name, args, context=None):
- res = {}
- for line in self.browse(cr, uid, ids, context=context):
- res[line.id] = bool(line.move_id)
- return res
+ name = fields.Char(string='Depreciation Name', required=True, index=True)
+ sequence = fields.Integer(required=True)
+ asset_id = fields.Many2one('account.asset.asset', string='Asset', required=True, ondelete='cascade')
+ parent_state = fields.Selection(related='asset_id.state', string='State of Asset')
+ amount = fields.Float(string='Current Depreciation', digits=0, required=True)
+ remaining_value = fields.Float(string='Next Period Depreciation', digits=0, required=True)
+ depreciated_value = fields.Float(string='Amount Already Depreciated', required=True)
+ depreciation_date = fields.Date('Depreciation Date', index=True)
+ move_id = fields.Many2one('account.move', string='Depreciation Entry')
+ move_check = fields.Boolean(compute='_get_move_check', string='Posted', track_visibility='always', store=True)
- _columns = {
- 'name': fields.char('Depreciation Name', required=True, select=1),
- 'sequence': fields.integer('Sequence', required=True),
- 'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True, ondelete='cascade'),
- 'parent_state': fields.related('asset_id', 'state', type='char', string='State of Asset'),
- 'amount': fields.float('Current Depreciation', digits=0, required=True),
- 'remaining_value': fields.float('Next Period Depreciation', digits=0, required=True),
- 'depreciated_value': fields.float('Amount Already Depreciated', required=True),
- 'depreciation_date': fields.date('Depreciation Date', select=1),
- 'move_id': fields.many2one('account.move', 'Depreciation Entry'),
- 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Posted', store=True)
- }
+ @api.one
+ @api.depends('move_id')
+ def _get_move_check(self):
+ self.move_check = bool(self.move_id)
- def create_move(self, cr, uid, ids, context=None):
- context = dict(context or {})
- can_close = False
- asset_obj = self.pool.get('account.asset.asset')
- move_obj = self.pool.get('account.move')
- move_line_obj = self.pool.get('account.move.line')
- currency_obj = self.pool.get('res.currency')
+ @api.multi
+ def create_move(self):
created_move_ids = []
asset_ids = []
- for line in self.browse(cr, uid, ids, context=context):
- depreciation_date = context.get('depreciation_date') or line.depreciation_date or time.strftime('%Y-%m-%d')
- company_currency = line.asset_id.company_id.currency_id.id
- current_currency = line.asset_id.currency_id.id
- context.update({'date': depreciation_date})
- amount = currency_obj.compute(cr, uid, current_currency, company_currency, line.amount, context=context)
- sign = (line.asset_id.category_id.journal_id.type == 'purchase' and 1) or -1
+ for line in self:
+ 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
+ current_currency = line.asset_id.currency_id
+ amount = company_currency.compute(line.amount, current_currency)
+ sign = (line.asset_id.category_id.journal_id.type == 'purchase' or line.asset_id.category_id.journal_id.type == 'sale' and 1) or -1
asset_name = line.asset_id.name
reference = line.name
journal_id = line.asset_id.category_id.journal_id.id
partner_id = line.asset_id.partner_id.id
+ categ_type = line.asset_id.category_id.type
+ debit_account = line.asset_id.category_id.account_asset_id.id
+ credit_account = line.asset_id.category_id.account_depreciation_id.id
move_line_1 = {
- 'name': asset_name,
+ 'name': asset_name or reference,
'ref': reference,
- 'account_id': line.asset_id.category_id.account_depreciation_id.id,
+ 'account_id': credit_account,
'debit': 0.0,
'credit': amount,
'journal_id': journal_id,
'partner_id': partner_id,
- 'currency_id': company_currency != current_currency and current_currency or False,
+ 'currency_id': company_currency != current_currency and current_currency or False,
'amount_currency': company_currency != current_currency and - sign * line.amount or 0.0,
+ 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id if categ_type == 'sale' else False,
'date': depreciation_date,
+ 'asset_id': line.asset_id.id if categ_type == 'sale' else False,
}
move_line_2 = {
- 'name': asset_name,
+ 'name': asset_name or reference,
'ref': reference,
- 'account_id': line.asset_id.category_id.account_expense_depreciation_id.id,
+ 'account_id': debit_account,
'credit': 0.0,
'debit': amount,
'journal_id': journal_id,
'partner_id': partner_id,
- 'currency_id': company_currency != current_currency and current_currency or False,
+ 'currency_id': company_currency != current_currency and current_currency or False,
'amount_currency': company_currency != current_currency and sign * line.amount or 0.0,
- 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id,
+ 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id if categ_type == 'purchase' else False,
'date': depreciation_date,
- 'asset_id': line.asset_id.id
+ 'asset_id': line.asset_id.id if categ_type == 'purchase' else False
}
move_vals = {
'name': asset_name,
@@ -417,43 +391,67 @@ class account_asset_depreciation_line(osv.osv):
'journal_id': line.asset_id.category_id.journal_id.id,
'line_ids': [(0, 0, move_line_1), (0, 0, move_line_2)],
}
- move_id = move_obj.create(cr, uid, move_vals, context=context)
- self.write(cr, uid, line.id, {'move_id': move_id}, context=context)
- created_move_ids.append(move_id)
- move_obj.post(cr, uid, [move_id], context=context)
- asset_ids.append(line.asset_id.id)
+ move = self.env['account.move'].create(move_vals)
+ line.write({'move_id': move.id, 'move_check': True})
+ created_move_ids.append(move.id)
+ move.post()
+ asset_ids.append(line.asset_id)
+ partner_name = line.asset_id.partner_id.name
+ currency_name = line.asset_id.currency_id.name
+
+ def _format_message(message_description, tracked_values):
+ message = ''
+ if message_description:
+ message = '%s' % message_description
+ for name, values in tracked_values.iteritems():
+ message += '
• %s: ' % name
+ message += '%s
' % values
+ return message
+
+ msg_values = {_('Currency'): currency_name, _('Amount'): line.amount}
+ if partner_name:
+ msg_values[_('Partner')] = partner_name
+ msg = _format_message(_('Depreciation line posted.'), msg_values)
+ line.asset_id.message_post(body=msg)
# we re-evaluate the assets to determine whether we can close them
- for asset in asset_obj.browse(cr, uid, list(set(asset_ids)), context=context):
- if currency_obj.is_zero(cr, uid, asset.currency_id, asset.value_residual):
+ for asset in asset_ids:
+ if asset.currency_id.is_zero(asset.value_residual):
+ asset.message_post(body=_("Document closed."))
asset.write({'state': 'close'})
+ asset.compute_depreciation_board()
return created_move_ids
+ @api.multi
+ def unlink(self):
+ for record in self:
+ if record.move_check:
+ if record.asset_id.category_id.type == 'purchase':
+ msg = _("You cannot delete posted depreciation lines.")
+ else:
+ msg = _("You cannot delete posted installment lines.")
+ raise UserError(msg)
+ return super(AccountAssetDepreciationLine, self).unlink()
-class account_move_line(osv.osv):
+
+class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
- _columns = {
- 'asset_id': fields.many2one('account.asset.asset', 'Asset', ondelete="restrict"),
- }
+ asset_id = fields.Many2one('account.asset.asset', string='Asset', ondelete="restrict")
-class account_asset_history(osv.osv):
+
+class AccountAssetHistory(models.Model):
_name = 'account.asset.history'
_description = 'Asset history'
- _columns = {
- 'name': fields.char('History name', select=1),
- 'user_id': fields.many2one('res.users', 'User', required=True),
- 'date': fields.date('Date', required=True),
- 'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True),
- 'method_time': fields.selection([('number','Number of Depreciations'),('end','Ending Date')], 'Time Method', required=True,
- help="The method to use to compute the dates and number of depreciation lines.\n"\
- "Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n" \
- "Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond."),
- 'method_number': fields.integer('Number of Depreciations', help="The number of depreciations needed to depreciate your asset"),
- 'method_period': fields.integer('Period Length', help="Time in month between two depreciations"),
- 'method_end': fields.date('Ending date'),
- 'note': fields.text('Note'),
- }
_order = 'date desc'
- _defaults = {
- 'date': lambda *args: time.strftime('%Y-%m-%d'),
- 'user_id': lambda self, cr, uid, ctx: uid
- }
+
+ name = fields.Char(string='History name', index=True)
+ user_id = fields.Many2one('res.users', string='User', required=True, default=lambda self: self.env.user)
+ date = fields.Date(required=True, default=fields.Date.context_today)
+ asset_id = fields.Many2one('account.asset.asset', string='Asset', required=True)
+ method_time = fields.Selection([('number', 'Number of Depreciations'), ('end', 'Ending Date')], string='Time Method', required=True,
+ help="The method to use to compute the dates and number of depreciation lines.\n"
+ "Number of Depreciations: Fix the number of depreciation lines and the time between 2 depreciations.\n"
+ "Ending Date: Choose the time between 2 depreciations and the date the depreciations won't go beyond.")
+ method_number = fields.Integer(string='Number of Depreciations', help="The number of depreciations needed to depreciate your asset")
+ method_period = fields.Integer(string='Period Length', help="Time in months between two depreciations")
+ method_end = fields.Date(string='Ending date')
+ note = fields.Text()
diff --git a/addons/account_asset/account_asset_demo.yml b/addons/account_asset/account_asset_demo.yml
index cdfdfbbbd46..c1bcfd0257c 100644
--- a/addons/account_asset/account_asset_demo.yml
+++ b/addons/account_asset/account_asset_demo.yml
@@ -14,7 +14,7 @@
'method_number': 3,
'account_asset_id': xfa_account_id[0],
'account_depreciation_id': xfa_account_id[0],
- 'account_expense_depreciation_id': expense_account_id[0],
+ 'account_income_recognition_id': expense_account_id[0],
}
self._update(cr, uid, 'account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets0')
vals = {
@@ -23,7 +23,7 @@
'method_number': 5,
'account_asset_id': xfa_account_id[0],
'account_depreciation_id': xfa_account_id[0],
- 'account_expense_depreciation_id': expense_account_id[0],
+ 'account_income_recognition_id': expense_account_id[0],
}
self._update(cr, uid, 'account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets1')
vals = {
@@ -32,7 +32,7 @@
'method_period': 12,
'method_number': 5,
'name': "CEO's car",
- 'purchase_value': 12000.0,
+ 'value': 12000.0,
'category_id': ref('account_asset_category_fixedassets0'),
}
self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_vehicles0')
@@ -41,7 +41,7 @@
'salvage_value': 0.0,
'method_time': 'end',
'name': 'V6 Engine and 10 inches tires',
- 'purchase_value': 2800.0,
+ 'value': 2800.0,
'category_id': ref('account_asset_category_fixedassets0'),
}
self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_cab0')
@@ -51,9 +51,9 @@
'state': 'open',
'method_period': 12,
'method_number': 20,
- 'purchase_date': time.strftime('%Y-01-01'),
+ 'date': time.strftime('%Y-01-01'),
'name': 'Office',
- 'purchase_value': 500000.0,
+ 'value': 500000.0,
'category_id': ref('account_asset_category_fixedassets0'),
}
self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_office0')
@@ -67,6 +67,6 @@
'method_number': 6,
'account_asset_id': xfa_account_id[0],
'account_depreciation_id': xfa_account_id[0],
- 'account_expense_depreciation_id': sale_account_id[0],
+ 'account_income_recognition_id': sale_account_id[0],
}
self._update(cr, uid, 'account.asset.category', 'account_asset', vals, 'account_asset_category_sale')
diff --git a/addons/account_asset/account_asset_invoice.py b/addons/account_asset/account_asset_invoice.py
index 4f49018cfa1..b9b58171745 100644
--- a/addons/account_asset/account_asset_invoice.py
+++ b/addons/account_asset/account_asset_invoice.py
@@ -1,66 +1,97 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
-from openerp.osv import fields, osv
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+from openerp import api, fields, models
+import openerp.addons.decimal_precision as dp
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DF
-class account_invoice(osv.osv):
+class AccountInvoice(models.Model):
_inherit = 'account.invoice'
- def action_number(self, cr, uid, ids, *args):
- result = super(account_invoice, self).action_number(cr, uid, ids, *args)
- for inv in self.browse(cr, uid, ids):
- self.pool.get('account.invoice.line').asset_create(cr, uid, inv.invoice_line_ids)
+
+ @api.multi
+ def action_move_create(self):
+ result = super(AccountInvoice, self).action_move_create()
+ for inv in self:
+ inv.invoice_line_ids.asset_create()
return result
- def line_get_convert(self, cr, uid, x, part, context=None):
- res = super(account_invoice, self).line_get_convert(cr, uid, x, part, context=context)
- res['asset_id'] = x.get('asset_id', False)
+ @api.model
+ def line_get_convert(self, line, part):
+ res = super(AccountInvoice, self).line_get_convert(line, part)
+ res['asset_id'] = line.get('asset_id', False)
return res
-class account_invoice_line(osv.osv):
-
+class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
- _columns = {
- 'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'),
- }
- def asset_create(self, cr, uid, lines, context=None):
- context = context or {}
- asset_obj = self.pool.get('account.asset.asset')
- for line in lines:
- if line.asset_category_id:
- vals = {
- 'name': line.name,
- 'code': line.invoice_id.number or False,
- 'category_id': line.asset_category_id.id,
- 'purchase_value': line.price_subtotal,
- 'date': line.invoice_id.date,
- 'partner_id': line.invoice_id.partner_id.id,
- 'company_id': line.invoice_id.company_id.id,
- 'currency_id': line.invoice_id.currency_id.id,
- 'purchase_date' : line.invoice_id.date_invoice,
- }
- changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context)
- vals.update(changed_vals['value'])
- asset_id = asset_obj.create(cr, uid, vals, context=context)
- if line.asset_category_id.open_asset:
- asset_obj.validate(cr, uid, [asset_id], context=context)
+
+ asset_category_id = fields.Many2one('account.asset.category', string='Asset Category')
+ asset_start_date = fields.Date(string='Asset End Date', compute='_get_asset_date', readonly=True, store=True)
+ asset_end_date = fields.Date(string='Asset Start Date', compute='_get_asset_date', readonly=True, store=True)
+ asset_mrr = fields.Float(string='Monthly Recurring Revenue', compute='_get_asset_date', readonly=True, digits=dp.get_precision('Account'), store=True)
+
+ @api.one
+ @api.depends('asset_category_id', 'invoice_id.date_invoice')
+ def _get_asset_date(self):
+ self.asset_mrr = 0
+ self.asset_start_date = False
+ self.asset_end_date = False
+ cat = self.asset_category_id
+ if cat:
+ months = cat.method_number * cat.method_period
+ if self.invoice_id.type in ['out_invoice', 'out_refund']:
+ self.asset_mrr = self.price_subtotal_signed / months
+ if self.invoice_id.date_invoice:
+ start_date = datetime.strptime(self.invoice_id.date_invoice, DF).replace(day=1)
+ end_date = (start_date + relativedelta(months=months, days=-1))
+ self.asset_start_date = start_date.strftime(DF)
+ self.asset_end_date = end_date.strftime(DF)
+
+ @api.one
+ def asset_create(self):
+ if self.asset_category_id and self.asset_category_id.method_number > 1:
+ vals = {
+ 'name': self.name,
+ 'code': self.invoice_id.number or False,
+ 'category_id': self.asset_category_id.id,
+ 'value': self.price_subtotal,
+ 'partner_id': self.invoice_id.partner_id.id,
+ 'company_id': self.invoice_id.company_id.id,
+ 'currency_id': self.invoice_id.currency_id.id,
+ 'date': self.asset_start_date or self.invoice_id.date_invoice,
+ 'invoice_id': self.invoice_id.id,
+ }
+ changed_vals = self.env['account.asset.asset'].onchange_category_id_values(vals['category_id'])
+ vals.update(changed_vals['value'])
+ asset = self.env['account.asset.asset'].create(vals)
+ if self.asset_category_id.open_asset:
+ asset.validate()
return True
+
+
+ @api.multi
+ def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',
+ partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
+ company_id=None, date_invoice=None):
+ res = super(AccountInvoiceLine, self).product_id_change(
+ product, uom_id, qty=qty, name=name, type=type, partner_id=partner_id,
+ fposition_id=fposition_id, price_unit=price_unit, currency_id=currency_id,
+ company_id=company_id, date_invoice=date_invoice
+ )
+ if product and res['value']:
+ product_obj = self.env['product.product'].browse(product)
+ if type == 'out_invoice':
+ res['value']['asset_category_id'] = product_obj.product_tmpl_id.deferred_revenue_category_id
+ elif type == 'in_invoice':
+ res['value']['asset_category_id'] = product_obj.product_tmpl_id.asset_category_id
+
+ return res
+
+
+class ProductTemplate(models.Model):
+ _inherit = 'product.template'
+ asset_category_id = fields.Many2one('account.asset.category', string='Asset Type', ondelete="restrict")
+ deferred_revenue_category_id = fields.Many2one('account.asset.category', string='Deferred Revenue Type', ondelete="restrict")
+
diff --git a/addons/account_asset/account_asset_invoice_view.xml b/addons/account_asset/account_asset_invoice_view.xml
deleted file mode 100644
index c44d0743e70..00000000000
--- a/addons/account_asset/account_asset_invoice_view.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
- account.invoice.line.form
- account.invoice.line
-
-
-
-
-
-
-
-
-
- account.invoice.supplier.form
- account.invoice
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/account_asset/report/__init__.py b/addons/account_asset/report/__init__.py
index 5d59693a7fd..c60e4c9e043 100644
--- a/addons/account_asset/report/__init__.py
+++ b/addons/account_asset/report/__init__.py
@@ -1,22 +1,3 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
import account_asset_report
diff --git a/addons/account_asset/report/account_asset_report.py b/addons/account_asset/report/account_asset_report.py
index 20bce5b17d3..938da73efd5 100644
--- a/addons/account_asset/report/account_asset_report.py
+++ b/addons/account_asset/report/account_asset_report.py
@@ -1,64 +1,46 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
+from openerp import fields, models, tools
-from openerp import tools
-from openerp.osv import fields, osv
-class asset_asset_report(osv.osv):
+class AssetAssetReport(models.Model):
_name = "asset.asset.report"
_description = "Assets Analysis"
_auto = False
- _columns = {
- 'name': fields.char('Year', required=False, readonly=True),
- 'purchase_date': fields.date('Purchase Date', readonly=True),
- 'depreciation_date': fields.date('Depreciation Date', readonly=True),
- 'asset_id': fields.many2one('account.asset.asset', string='Asset', readonly=True),
- 'asset_category_id': fields.many2one('account.asset.category',string='Asset category'),
- 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
- 'state': fields.selection([('draft','Draft'),('open','Running'),('close','Close')], 'Status', readonly=True),
- 'depreciation_value': fields.float('Amount of Depreciation Lines', readonly=True),
- 'move_check': fields.boolean('Posted', readonly=True),
- 'nbr': fields.integer('# of Depreciation Lines', readonly=True),
- 'gross_value': fields.float('Gross Amount', readonly=True),
- 'posted_value': fields.float('Posted Amount', readonly=True),
- 'unposted_value': fields.float('Unposted Amount', readonly=True),
- 'company_id': fields.many2one('res.company', 'Company', readonly=True),
- }
-
+
+ name = fields.Char(string='Year', required=False, readonly=True)
+ date = fields.Date(readonly=True)
+ depreciation_date = fields.Date(string='Depreciation Date', readonly=True)
+ asset_id = fields.Many2one('account.asset.asset', string='Asset', readonly=True)
+ asset_category_id = fields.Many2one('account.asset.category', string='Asset category', readonly=True)
+ partner_id = fields.Many2one('res.partner', string='Partner', readonly=True)
+ state = fields.Selection([('draft', 'Draft'), ('open', 'Running'), ('close', 'Close')], string='Status', readonly=True)
+ depreciation_value = fields.Float(string='Amount of Depreciation Lines', readonly=True)
+ installment_value = fields.Float(string='Amount of Installment Lines', readonly=True)
+ move_check = fields.Boolean(string='Posted', readonly=True)
+ installment_nbr = fields.Integer(string='# of Installment Lines', readonly=True)
+ depreciation_nbr = fields.Integer(string='# of Depreciation Lines', readonly=True)
+ gross_value = fields.Float(string='Gross Amount', readonly=True)
+ posted_value = fields.Float(string='Posted Amount', readonly=True)
+ unposted_value = fields.Float(string='Unposted Amount', readonly=True)
+ company_id = fields.Many2one('res.company', string='Company', readonly=True)
+
def init(self, cr):
- tools.drop_view_if_exists(cr, 'asset_asset_report')
- cr.execute("""
- create or replace view asset_asset_report as (
- select
+ tools.drop_view_if_exists(cr, 'asset_asset_report')
+ cr.execute("""
+ create or replace view asset_asset_report as (
+ select
min(dl.id) as id,
dl.name as name,
dl.depreciation_date as depreciation_date,
- a.purchase_date as purchase_date,
+ a.date as date,
(CASE WHEN (select min(d.id) from account_asset_depreciation_line as d
left join account_asset_asset as ac ON (ac.id=d.asset_id)
where a.id=ac.id) = min(dl.id)
- THEN a.purchase_value
+ THEN a.value
ELSE 0
END) as gross_value,
- dl.amount as depreciation_value,
+ dl.amount as depreciation_value,
+ dl.amount as installment_value,
(CASE WHEN dl.move_check
THEN dl.amount
ELSE 0
@@ -72,13 +54,13 @@ class asset_asset_report(osv.osv):
a.category_id as asset_category_id,
a.partner_id as partner_id,
a.state as state,
- count(dl.*) as nbr,
+ count(dl.*) as installment_nbr,
+ count(dl.*) as depreciation_nbr,
a.company_id as company_id
from account_asset_depreciation_line dl
left join account_asset_asset a on (dl.asset_id=a.id)
- group by
+ group by
dl.amount,dl.asset_id,dl.depreciation_date,dl.name,
- a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
- a.purchase_value, a.id, a.salvage_value
+ a.date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
+ a.value, a.id, a.salvage_value
)""")
-
diff --git a/addons/account_asset/report/account_asset_report_view.xml b/addons/account_asset/report/account_asset_report_view.xml
index 5b4b6d2bf8d..19f95375620 100644
--- a/addons/account_asset/report/account_asset_report_view.xml
+++ b/addons/account_asset/report/account_asset_report_view.xml
@@ -1,6 +1,5 @@
-
-
+asset.asset.report.pivot
@@ -8,7 +7,7 @@
-
+
@@ -21,18 +20,46 @@
-
+
-
+
+
+
+ asset.asset.report.pivot
+ asset.asset.report
+
+
+
+
+
+
+
+
+
+ asset.revenue.report.graph
+ asset.asset.report
+
+
+
+
+
+
+
+
+
+
+
asset.asset.report.searchasset.asset.report
-
+
@@ -50,13 +77,46 @@
+ context="{'group_by':'date:month'}"/>
+
+
+
+
+ asset.revenue.report.search
+ asset.asset.report
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Assets Analysis
@@ -64,18 +124,45 @@
formpivot,graph
+ [('asset_category_id.type', '=', 'purchase')]{}
- From this report, you can have an overview on all depreciation. The
- tool search can also be used to personalise your Assets reports and
- so, match this analysis to your needs;
+ From this report, you can have an overview on all depreciations. The
+ search bar can also be used to personalize your assets depreciation reporting.
+ From this report, you can have an overview of your deferred revenue. The
+ search bar can also be used to personalize your revenue recognition reporting.
+
+
+
+
-
-
+ parent="account.menu_finance_reports" sequence="21"/>
+
+
+
+
+
diff --git a/addons/account_asset/security/account_asset_security.xml b/addons/account_asset/security/account_asset_security.xml
index 77f218d13b9..02320b922dd 100644
--- a/addons/account_asset/security/account_asset_security.xml
+++ b/addons/account_asset/security/account_asset_security.xml
@@ -1,5 +1,5 @@
-
+Account Asset Category multi-company
@@ -16,4 +16,4 @@
-
+
diff --git a/addons/account_asset/static/src/js/account_asset.js b/addons/account_asset/static/src/js/account_asset.js
new file mode 100644
index 00000000000..accd57ed3f5
--- /dev/null
+++ b/addons/account_asset/static/src/js/account_asset.js
@@ -0,0 +1,39 @@
+/*
+Purpose : show toggle button on depreciation/installment lines for posted/unposted line.
+Details : called in list view with "",
+ this will call the method create_move on the object account.asset.depreciation.line
+*/
+
+odoo.define('account_asset.widget', function(require) {
+"use strict";
+
+// openerp.account_asset = function (instance) {
+ // var _t = instance.web._t,
+ // _lt = instance.web._lt;
+ // var QWeb = instance.web.qweb;
+ // instance.web.account_asset = instance.web.account_asset || {};
+
+var core = require('web.core');
+var QWeb = core.qweb;
+var list_widget_registry = core.list_widget_registry;
+var Column = list_widget_registry.get('field');
+
+var WidgetOnButton = Column.extend({
+ format: function (row_data, options) {
+ this._super(row_data, options);
+ this.has_value = !!row_data.move_check.value;
+ this.parent_state = row_data.parent_state.value;
+ this.icon = this.has_value ? 'gtk-yes' : 'gtk-no'; // or STOCK_YES and STOCK_NO
+ this.string = this.has_value ? 'Posted' : 'Unposted';
+ var template = this.icon && 'ListView.row.buttonwidget';
+ return QWeb.render(template, {
+ widget: this,
+ prefix: instance.session.prefix,
+ disabled: this.has_value,
+ invisible : true ? this.parent_state !== 'open' : false
+ });
+ },
+});
+
+list_widget_registry.add("button.widgetonbutton", WidgetOnButton);
+});
diff --git a/addons/account_asset/static/src/xml/account_asset_template.xml b/addons/account_asset/static/src/xml/account_asset_template.xml
new file mode 100644
index 00000000000..ed33ee35f87
--- /dev/null
+++ b/addons/account_asset/static/src/xml/account_asset_template.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml
deleted file mode 100644
index 708f16786a8..00000000000
--- a/addons/account_asset/test/account_asset.yml
+++ /dev/null
@@ -1,35 +0,0 @@
--
- In order to test the process of Account Asset, I perform a action to confirm Account Asset.
--
- !python {model: account.asset.asset}: |
- self.validate(cr, uid, [ref("account_asset_asset_vehicles_test0")])
--
- I check Asset is now in Open state.
--
- !assert {model: account.asset.asset, id: account_asset_asset_vehicles_test0, severity: error, string: Asset should be in Open state}:
- - state == 'open'
--
- I compute depreciation lines for asset of CEO's Car .
--
- !python {model: account.asset.asset}: |
- self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_vehicles_test0")])
- # pressing computation button can be remove if creation of depreciation lines while asset is created
- value = self.browse(cr, uid, [ref("account_asset_asset_vehicles_test0")])[0]
- assert value.method_number == len(value.depreciation_line_ids), 'Depreciation lines not created correctly'
--
- I create account move for all depreciation lines.
--
- !python {model: account.asset.depreciation.line}: |
- ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_vehicles_test0'))])
- self.create_move(cr, uid, ids)
--
- I check the move line is created.
--
- !python {model: account.asset.asset}: |
- asset = self.browse(cr, uid, [ref("account_asset_asset_vehicles_test0")])[0]
- assert len(asset.depreciation_line_ids) == len(asset.account_move_line_ids), 'Move lines not created correctly'
--
- I Check that After creating all the moves of depreciation lines the state "Close".
--
- !assert {model: account.asset.asset, id: account_asset_asset_vehicles_test0}:
- - state == 'close'
diff --git a/addons/account_asset/test/account_asset_demo.yml b/addons/account_asset/test/account_asset_demo.yml
deleted file mode 100644
index 8e8813574a5..00000000000
--- a/addons/account_asset/test/account_asset_demo.yml
+++ /dev/null
@@ -1,9 +0,0 @@
--
- !record {model: account.asset.category, id: account_asset_category_fixedassets_test0}:
- account_asset_id: xfa
--
- !record {model: account.asset.asset, id: account_asset_asset_vehicles_test0}:
- category_id: account_asset_category_sale_test0
--
- !record {model: account.asset.asset, id: account_asset_asset_vehicles_test0}:
- method_number: 5
diff --git a/addons/account_asset/test/account_asset_demo_test.xml b/addons/account_asset/test/account_asset_demo_test.xml
index 4fbfd8e4a44..47af3b0d0cf 100644
--- a/addons/account_asset/test/account_asset_demo_test.xml
+++ b/addons/account_asset/test/account_asset_demo_test.xml
@@ -1,36 +1,49 @@
-
+
-
+
- Hardware - 3 Years3
+ 12
-
+
- Cars - 5 Years5
+ 12
-
+
-
-
- Revenue Recognition Maintenance Contract - 3 Years
+
+ Maintenance Contract - 3 Years3
+ 12
+
+ sale
+
+
+
+
+
+
+ Maintenance Contract - 1 Year
+ 12
+ 1
+
+ sale
+
-
\ No newline at end of file
+
diff --git a/addons/account_asset/test/account_asset_wizard.yml b/addons/account_asset/test/account_asset_wizard.yml
deleted file mode 100644
index 91a85218406..00000000000
--- a/addons/account_asset/test/account_asset_wizard.yml
+++ /dev/null
@@ -1,27 +0,0 @@
--
- I create a record to change the duration of asset for calculating depreciation.
--
- !record {model: asset.modify, id: asset_modify_number_0, context: "{'active_id': ref('account_asset_asset_office_test0')}"}:
- method_number: 10.0
--
- I change the duration.
--
- !python {model: asset.modify}: |
- context = {"active_id":ref('account_asset_asset_office_test0')}
- self.modify(cr, uid, [ref("asset_modify_number_0")], context=context)
--
- I check the proper depreciation lines created.
--
- !assert {model: account.asset.asset, id: account_asset.account_asset_asset_office_test0}:
- - method_number == len(depreciation_line_ids) -1
--
- I create a period to compute a asset on period.
--
- !record {model: asset.depreciation.confirmation.wizard, id: asset_compute_period_0}:
- {}
--
- I compute a asset on period.
--
- !python {model: asset.depreciation.confirmation.wizard}: |
- context = {"active_ids": [ref("account_asset.account_asset_asset_office_test0")], "active_id":ref('account_asset.account_asset_asset_office_test0')}
- self.asset_compute(cr, uid, [ref("asset_compute_period_0")], context=context)
diff --git a/addons/account_asset/tests/__init__.py b/addons/account_asset/tests/__init__.py
new file mode 100644
index 00000000000..054eb7df4fe
--- /dev/null
+++ b/addons/account_asset/tests/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+
+from . import test_account_asset
diff --git a/addons/account_asset/tests/test_account_asset.py b/addons/account_asset/tests/test_account_asset.py
new file mode 100644
index 00000000000..c3c582e9507
--- /dev/null
+++ b/addons/account_asset/tests/test_account_asset.py
@@ -0,0 +1,128 @@
+# -*- coding: utf-8 -*-
+
+from openerp import tools
+from openerp.tests import common
+from openerp.modules.module import get_module_resource
+
+
+class TestAccountAsset(common.TransactionCase):
+
+ def _load(self, module, *args):
+ tools.convert_file(self.cr, 'account_asset',
+ get_module_resource(module, *args),
+ {}, 'init', False, 'test', self.registry._assertion_report)
+
+ def test_00_account_asset_asset(self):
+ self._load('account', 'test', 'account_minimal_test.xml')
+ self._load('account_asset', 'test', 'account_asset_demo_test.xml')
+
+ # self.browse_ref("account_asset.data_fiscalyear_plus1").create_period()
+ # self.browse_ref("account_asset.data_fiscalyear_plus2").create_period()
+ # self.browse_ref("account_asset.data_fiscalyear_plus3").create_period()
+ # self.browse_ref("account_asset.data_fiscalyear_plus4").create_period()
+ # self.browse_ref("account_asset.data_fiscalyear_plus5").create_period()
+
+ # In order to test the process of Account Asset, I perform a action to confirm Account Asset.
+ self.browse_ref("account_asset.account_asset_asset_vehicles0").validate()
+
+ # I check Asset is now in Open state.
+ self.assertEqual(self.browse_ref("account_asset.account_asset_asset_vehicles0").state, 'open',
+ 'Asset should be in Open state')
+
+ # I compute depreciation lines for asset of CEOs Car.
+ self.browse_ref("account_asset.account_asset_asset_vehicles0").compute_depreciation_board()
+ value = self.browse_ref("account_asset.account_asset_asset_vehicles0")
+ self.assertEqual(value.method_number, len(value.depreciation_line_ids),
+ 'Depreciation lines not created correctly')
+
+ # I create account move for all depreciation lines.
+ ids = self.env['account.asset.depreciation.line'].search([('asset_id', '=', self.ref('account_asset.account_asset_asset_vehicles0'))])
+ for line in ids:
+ line.create_move()
+
+ # I check the move line is created.
+ asset = self.env['account.asset.asset'].browse([self.ref("account_asset.account_asset_asset_vehicles0")])[0]
+ self.assertEqual(len(asset.depreciation_line_ids), len(asset.account_move_line_ids),
+ 'Move lines not created correctly')
+
+ # I Check that After creating all the moves of depreciation lines the state "Close".
+ self.assertEqual(self.browse_ref("account_asset.account_asset_asset_vehicles0").state, 'close',
+ 'State of asset should be close')
+
+ invoice = self.env['account.invoice'].create({
+ 'partner_id': self.ref("base.res_partner_12"),
+ 'account_id': self.ref("account_asset.a_sale"),
+ })
+ self.env['account.invoice.line'].create({
+ 'invoice_id': invoice.id,
+ 'account_id': self.ref("account_asset.a_sale"),
+ 'name': 'Insurance claim',
+ 'price_unit': 450,
+ 'quantity': 1,
+ 'asset_category_id': self.ref("account_asset.account_asset_category_sale1"),
+ })
+ invoice.signal_workflow('invoice_open')
+
+ from datetime import datetime
+ from dateutil.relativedelta import relativedelta
+ line_obj = self.env['account.asset.depreciation.line']
+ recognition_ids = self.env['account.asset.asset'].search([('code', '=', invoice.number)])
+ self.assertTrue(recognition_ids,
+ 'Revenue recognition has been not created from invoice.')
+
+ # I confirm revenue recognition.
+ for asset in recognition_ids:
+ asset.validate()
+ recognition = recognition_ids[0]
+ first_invoice_line = invoice.invoice_line_ids[0]
+ self.assertTrue(recognition.state == 'open',
+ 'Recognition should be in Open state')
+ self.assertEqual(recognition.value, first_invoice_line.price_subtotal,
+ 'Recognition value is not same as invoice line.')
+
+ # I post installment lines.
+ line_ids = [rec for rec in recognition.depreciation_line_ids]
+ for line in line_ids:
+ line.create_move()
+
+ # I check that move line is created from posted installment lines.
+ self.assertEqual(len(recognition.depreciation_line_ids), len(recognition.account_move_line_ids),
+ 'Move lines not created correctly.')
+
+ # I check data in move line and installment line.
+ first_installment_line = recognition.depreciation_line_ids[0]
+ first_move_line = recognition.account_move_line_ids[0]
+ self.assertEqual(first_installment_line.amount, first_move_line.credit,
+ 'First installment line amount is incorrect.')
+ remaining_value = recognition.value - first_installment_line.amount
+ self.assertEqual(first_installment_line.remaining_value, recognition.value - first_installment_line.amount,
+ 'Remaining value is incorrect.')
+
+ # I check next installment date.
+ last_installment_date = datetime.strptime(first_installment_line.depreciation_date, '%Y-%m-%d')
+ installment_date = (last_installment_date+relativedelta(months=+recognition.method_period))
+ self.assertEqual(recognition.depreciation_line_ids[1].depreciation_date, str(installment_date.date()),
+ 'Installment date is incorrect.')
+
+ # WIZARD
+ # I create a record to change the duration of asset for calculating depreciation.
+
+ account_asset_asset_office0 = self.browse_ref('account_asset.account_asset_asset_office0')
+ asset_modify_number_0 = self.env['asset.modify'].create({
+ 'name': 'Test reason',
+ 'method_number': 10.0,
+ }).with_context({'active_id': account_asset_asset_office0.id})
+ # I change the duration.
+ asset_modify_number_0.with_context({'active_id': account_asset_asset_office0.id}).modify()
+
+ # I check the proper depreciation lines created.
+ self.assertEqual(account_asset_asset_office0.method_number, len(account_asset_asset_office0.depreciation_line_ids) - 1)
+ # I compute a asset on period.
+
+ context = {
+ "active_ids": [self.ref("account_asset.menu_asset_depreciation_confirmation_wizard")],
+ "active_id": self.ref('account_asset.menu_asset_depreciation_confirmation_wizard'),
+ 'type': 'sale'
+ }
+ asset_compute_period_0 = self.env['asset.depreciation.confirmation.wizard'].create({})
+ asset_compute_period_0.with_context(context).asset_compute()
diff --git a/addons/account_asset/views/account_asset.xml b/addons/account_asset/views/account_asset.xml
new file mode 100644
index 00000000000..198e95172d4
--- /dev/null
+++ b/addons/account_asset/views/account_asset.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/account_asset/views/account_asset_invoice_view.xml b/addons/account_asset/views/account_asset_invoice_view.xml
new file mode 100644
index 00000000000..b4207df4dd6
--- /dev/null
+++ b/addons/account_asset/views/account_asset_invoice_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+ account.invoice.line.form
+ account.invoice.line
+
+
+
+
+
+
+
+
+
+
+ account.invoice.supplier.form
+ account.invoice
+
+
+
+
+
+
+
+
+
+
+ account.invoice.form
+ account.invoice
+
+
+
+
+
+
+
+
+
diff --git a/addons/account_asset/account_asset_view.xml b/addons/account_asset/views/account_asset_view.xml
similarity index 55%
rename from addons/account_asset/account_asset_view.xml
rename to addons/account_asset/views/account_asset_view.xml
index d5a9f609329..854e77a38e6 100644
--- a/addons/account_asset/account_asset_view.xml
+++ b/addons/account_asset/views/account_asset_view.xml
@@ -1,5 +1,4 @@
-
-
+
-
account.asset.asset.formaccount.asset.asset
@@ -182,27 +197,9 @@
-
+
-
-
-
-
-
-
-
-
-
-
- account.asset.asset.hierarchy
- account.asset.asset
-
-
-
-
-
-
-
+
@@ -217,15 +214,34 @@
-
-
-
+
+
+
+
+
+
+
+
+
+ Product Template (form)
+ product.template
+
+
+
+
+
+
+
+
+
+
+
@@ -269,15 +285,7 @@
-
-
- Asset Hierarchy
- account.asset.asset
- tree
- []
-
-
-
+
Journal Items (form)account.move.line
@@ -300,26 +308,51 @@
+
Assetsaccount.asset.asset
- form
-
-
+ [('category_id.type', '=', 'purchase')]
+ {'default_type': 'purchase', 'default_category_id_type': 'purchase'}
-
+
-
+
+ Deferred Revenues
+ account.asset.asset
+ form
+ [('category_id.type', '=', 'sale')]
+ {'default_type': 'sale', 'default_category_id_type': 'sale'}
+
-
- Asset Categories
+
+
+
+
+
+
+
+
+
+
+ Asset Typesaccount.asset.category
+ [('type', '=', 'purchase')]formtree,form
+ {'default_type': 'purchase'}
+
+
+ Deferred Revenues Types
+ account.asset.category
+ [('type', '=', 'sale')]
+ form
+ tree,form
+ {'default_type': 'sale'}
-
+
+
-
-
+
diff --git a/addons/account_asset/wizard/__init__.py b/addons/account_asset/wizard/__init__.py
index e1ee90f90c2..0425aadb5d8 100644
--- a/addons/account_asset/wizard/__init__.py
+++ b/addons/account_asset/wizard/__init__.py
@@ -1,23 +1,4 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
import account_asset_change_duration
import wizard_asset_compute
diff --git a/addons/account_asset/wizard/account_asset_change_duration.py b/addons/account_asset/wizard/account_asset_change_duration.py
index 35160c026ff..55c1b3d3f7e 100644
--- a/addons/account_asset/wizard/account_asset_change_duration.py
+++ b/addons/account_asset/wizard/account_asset_change_duration.py
@@ -1,63 +1,51 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-import time
+# -*- coding: utf-8 -*-
from lxml import etree
-from openerp.osv import fields, osv
+from openerp import api, fields, models
+from openerp.osv.orm import setup_modifiers
-class asset_modify(osv.osv_memory):
+
+class AssetModify(models.TransientModel):
_name = 'asset.modify'
_description = 'Modify Asset'
- def _get_asset_method_time(self, cr, uid, ids, field_name, arg, context=None):
- if ids and len(ids) == 1 and context.get('active_id'):
- asset = self.pool['account.asset.asset'].browse(cr, uid, context.get('active_id'), context=context)
- return {ids[0]: asset.method_time}
- else:
- return dict.fromkeys(ids, False)
+ name = fields.Char(string='Reason', required=True)
+ method_number = fields.Integer(string='Number of Depreciations', required=True)
+ method_period = fields.Integer(string='Period Length')
+ method_end = fields.Date(string='Ending date')
+ note = fields.Text(string='Notes')
+ asset_method_time = fields.Char(compute='_get_asset_method_time', string='Asset Method Time', readonly=True)
- _columns = {
- 'name': fields.char('Reason', required=True),
- 'method_number': fields.integer('Number of Depreciations', required=True),
- 'method_period': fields.integer('Period Length'),
- 'method_end': fields.date('Ending date'),
- 'note': fields.text('Notes'),
- 'asset_method_time': fields.function(_get_asset_method_time, type='char', string='Asset Method Time', readonly=True),
- }
+ @api.one
+ def _get_asset_method_time(self):
+ if self.env.context.get('active_id'):
+ asset = self.env['account.asset.asset'].browse(self.env.context.get('active_id'))
+ self.asset_method_time = asset.method_time
- def default_get(self, cr, uid, fields, context=None):
- """ To get default values for the object.
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param fields: List of fields for which we want default values
- @param context: A standard dictionary
- @return: A dictionary which of fields with values.
- """
- if not context:
- context = {}
- asset_obj = self.pool.get('account.asset.asset')
- res = super(asset_modify, self).default_get(cr, uid, fields, context=context)
- asset_id = context.get('active_id', False)
- asset = asset_obj.browse(cr, uid, asset_id, context=context)
+ @api.model
+ def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
+ result = super(AssetModify, self).fields_view_get(view_id, view_type, toolbar=toolbar, submenu=submenu)
+ asset_id = self.env.context.get('active_id')
+ active_model = self.env.context.get('active_model')
+ if active_model == 'account.asset.asset' and asset_id:
+ asset = self.env['account.asset.asset'].browse(asset_id)
+ doc = etree.XML(result['arch'])
+ if asset.method_time == 'number' and doc.xpath("//field[@name='method_end']"):
+ node = doc.xpath("//field[@name='method_end']")[0]
+ node.set('invisible', '1')
+ setup_modifiers(node, result['fields']['method_end'])
+ elif asset.method_time == 'end' and doc.xpath("//field[@name='method_number']"):
+ node = doc.xpath("//field[@name='method_number']")[0]
+ node.set('invisible', '1')
+ setup_modifiers(node, result['fields']['method_number'])
+ result['arch'] = etree.tostring(doc)
+ return result
+
+ @api.model
+ def default_get(self, fields):
+ res = super(AssetModify, self).default_get(fields)
+ asset_id = self.env.context.get('active_id')
+ asset = self.env['account.asset.asset'].browse(asset_id)
if 'name' in fields:
res.update({'name': asset.name})
if 'method_number' in fields and asset.method_time == 'number':
@@ -66,44 +54,34 @@ class asset_modify(osv.osv_memory):
res.update({'method_period': asset.method_period})
if 'method_end' in fields and asset.method_time == 'end':
res.update({'method_end': asset.method_end})
- if context.get('active_id'):
- res['asset_method_time'] = self._get_asset_method_time(cr, uid, [0], 'asset_method_time', [], context=context)[0]
+ if self.env.context.get('active_id'):
+ res['asset_method_time'] = self._get_asset_method_time()
return res
-
- def modify(self, cr, uid, ids, context=None):
+
+ @api.multi
+ def modify(self):
""" Modifies the duration of asset for calculating depreciation
and maintains the history of old values.
- @param self: The object pointer.
- @param cr: A database cursor
- @param uid: ID of the user currently logged in
- @param ids: List of Ids
- @param context: A standard dictionary
- @return: Close the wizard.
- """
- if not context:
- context = {}
- asset_obj = self.pool.get('account.asset.asset')
- history_obj = self.pool.get('account.asset.history')
- asset_id = context.get('active_id', False)
- asset = asset_obj.browse(cr, uid, asset_id, context=context)
- data = self.browse(cr, uid, ids[0], context=context)
+ """
+ asset_id = self.env.context.get('active_id', False)
+ asset = self.env['account.asset.asset'].browse(asset_id)
history_vals = {
'asset_id': asset_id,
- 'name': data.name,
+ 'name': self.name,
'method_time': asset.method_time,
'method_number': asset.method_number,
'method_period': asset.method_period,
'method_end': asset.method_end,
- 'user_id': uid,
- 'date': time.strftime('%Y-%m-%d'),
- 'note': data.note,
+ 'user_id': self.env.uid,
+ 'date': fields.Date.context_today(self),
+ 'note': self.note,
}
- history_obj.create(cr, uid, history_vals, context=context)
+ self.env['account.asset.history'].create(history_vals)
asset_vals = {
- 'method_number': data.method_number,
- 'method_period': data.method_period,
- 'method_end': data.method_end,
+ 'method_number': self.method_number,
+ 'method_period': self.method_period,
+ 'method_end': self.method_end,
}
- asset_obj.write(cr, uid, [asset_id], asset_vals, context=context)
- asset_obj.compute_depreciation_board(cr, uid, [asset_id], context=context)
+ asset.write(asset_vals)
+ asset.compute_depreciation_board()
return {'type': 'ir.actions.act_window_close'}
diff --git a/addons/account_asset/wizard/account_asset_change_duration_view.xml b/addons/account_asset/wizard/account_asset_change_duration_view.xml
index daa736fb804..46ebac2a8e1 100644
--- a/addons/account_asset/wizard/account_asset_change_duration_view.xml
+++ b/addons/account_asset/wizard/account_asset_change_duration_view.xml
@@ -1,46 +1,44 @@
-
-
+
-
- wizard.asset.modify.form
- asset.modify
-
-
+
+
-
-
+
+ Modify Asset
+ asset.modify
+ ir.actions.act_window
+ form
+ tree,form
+
+ new
+
+
+
diff --git a/addons/account_asset/wizard/wizard_asset_compute.py b/addons/account_asset/wizard/wizard_asset_compute.py
index 0a16f8bc2df..0a3711a7f76 100644
--- a/addons/account_asset/wizard/wizard_asset_compute.py
+++ b/addons/account_asset/wizard/wizard_asset_compute.py
@@ -1,50 +1,29 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# -*- coding: utf-8 -*-
+from openerp import api, fields, models, _
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
-class asset_depreciation_confirmation_wizard(osv.osv_memory):
+class AssetDepreciationConfirmationWizard(models.TransientModel):
_name = "asset.depreciation.confirmation.wizard"
_description = "asset.depreciation.confirmation.wizard"
- _columns = {
- 'date': fields.date('Account Date', required=True, help="Choose the period for which you want to automatically post the depreciation lines of running assets"),
- }
-
- _defaults = {
- 'date': fields.date.context_today,
- }
- def asset_compute(self, cr, uid, ids, context):
- ass_obj = self.pool.get('account.asset.asset')
- asset_ids = context.get('active_ids', False)
- data = self.browse(cr, uid, ids, context=context)
- date = data[0].date
- created_move_ids = ass_obj._compute_entries(cr, uid, asset_ids, date, context=context)
+ date = fields.Date('Account Date', required=True, help="Choose the period for which you want to automatically post the depreciation lines of running assets", default=fields.Date.context_today)
+
+ @api.multi
+ def asset_compute(self):
+ self.ensure_one()
+ context = self._context
+ assets = self.env['account.asset.asset'].search([('state', '=', 'open'), ('category_id.type', '=', context.get('asset_type'))])
+ created_move_ids = assets._compute_entries(self.date)
+ if context.get('asset_type') == 'purchase':
+ title = _('Created Asset Moves')
+ else:
+ title = _('Created Revenue Moves')
return {
- 'name': _('Created Asset Moves'),
+ 'name': title,
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move',
'view_id': False,
- 'domain': "[('id','in',["+','.join(map(str,created_move_ids))+"])]",
+ 'domain': "[('id','in',["+','.join(map(str, created_move_ids))+"])]",
'type': 'ir.actions.act_window',
}
diff --git a/addons/account_asset/wizard/wizard_asset_compute_view.xml b/addons/account_asset/wizard/wizard_asset_compute_view.xml
index a76719ebf8a..8e31c102bd7 100644
--- a/addons/account_asset/wizard/wizard_asset_compute_view.xml
+++ b/addons/account_asset/wizard/wizard_asset_compute_view.xml
@@ -1,40 +1,54 @@
-
-
-
- asset.depreciation.confirmation.wizard
- asset.depreciation.confirmation.wizard
-
-
+ This wizard will post installment/depreciation lines for the selected month.
+ This will generate journal entries for all related installment lines on this period of asset/revenue recognition as well.
+
+
+
+
+
+
+
+
+
-
- Generate Depreciation Entries
- asset.depreciation.confirmation.wizard
- form
- tree,form
-
- new
-
+
+ Post Depreciation Lines
+ asset.depreciation.confirmation.wizard
+ form
+ tree,form
+
+ new
+ {'asset_type': 'purchase'}
+
-
-
- Generate Depreciation Entries
- client_action_multi
-
- action
- account.asset.asset
-
+
+ Post Installment Lines
+ asset.depreciation.confirmation.wizard
+ form
+ tree,form
+
+ new
+ {'asset_type': 'sale'}
+
-
-
+
+
+
+
+
diff --git a/addons/account_cancel/account_cancel_view.xml b/addons/account_cancel/account_cancel_view.xml
index 668c1053e08..d64d3101c64 100644
--- a/addons/account_cancel/account_cancel_view.xml
+++ b/addons/account_cancel/account_cancel_view.xml
@@ -39,6 +39,9 @@
account.bank.statement
+
+ {'reload_on_button': true}
+
diff --git a/addons/account_test/report/account_test_report.py b/addons/account_test/report/account_test_report.py
index a19e2f398af..208fec8152a 100644
--- a/addons/account_test/report/account_test_report.py
+++ b/addons/account_test/report/account_test_report.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
from openerp import api, models, _
+from openerp.tools.safe_eval import safe_eval as eval
#
# Use period and Journal for selection or resources
#
@@ -38,7 +39,7 @@ class ReportAssertAccount(models.AbstractModel):
'result': None, # used to store the result of the test
'column_order': None, # used to choose the display order of columns (in case you are returning a list of dict)
}
- exec code_exec in localdict
+ eval(code_exec, localdict, mode="exec", nocopy=True)
result = localdict['result']
column_order = localdict.get('column_order', None)
diff --git a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py
index a9047db017a..4254e605441 100644
--- a/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py
+++ b/addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py
@@ -114,8 +114,8 @@ class account_analytic_account(osv.osv):
digits=0),
}
- def on_change_template(self, cr, uid, id, template_id, date_start=False, context=None):
- res = super(account_analytic_account, self).on_change_template(cr, uid, id, template_id, date_start=date_start, context=context)
+ def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None):
+ res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context)
if template_id and 'value' in res:
template = self.browse(cr, uid, template_id, context=context)
res['value']['charge_expenses'] = template.charge_expenses
diff --git a/addons/anonymization/anonymization.py b/addons/anonymization/anonymization.py
index 35c6f98d06e..a114c7712ff 100644
--- a/addons/anonymization/anonymization.py
+++ b/addons/anonymization/anonymization.py
@@ -31,6 +31,7 @@ import random
import datetime
from openerp.osv import fields, osv
from openerp.tools.translate import _
+from openerp.tools.safe_eval import safe_eval as eval
from itertools import groupby
from operator import itemgetter
diff --git a/addons/auth_ldap/users_ldap.py b/addons/auth_ldap/users_ldap.py
index 937e672ef89..6d2040d83c4 100644
--- a/addons/auth_ldap/users_ldap.py
+++ b/addons/auth_ldap/users_ldap.py
@@ -140,8 +140,8 @@ class CompanyLDAP(osv.osv):
results = []
try:
conn = self.connect(conf)
- conn.simple_bind_s(conf['ldap_binddn'] or '',
- conf['ldap_password'].encode('utf-8') or '')
+ ldap_password = conf['ldap_password'] or ''
+ conn.simple_bind_s(conf['ldap_binddn'] or '', ldap_password.encode('utf-8'))
results = conn.search_st(conf['ldap_base'], ldap.SCOPE_SUBTREE,
filter, retrieve_attributes, timeout=60)
conn.unbind()
diff --git a/addons/barcodes/static/src/js/barcode_parser.js b/addons/barcodes/static/src/js/barcode_parser.js
index e1703ae62b4..970019fb1f4 100644
--- a/addons/barcodes/static/src/js/barcode_parser.js
+++ b/addons/barcodes/static/src/js/barcode_parser.js
@@ -158,7 +158,14 @@ var BarcodeParser = Class.extend({
.replace("\.",".");
}
- match['match'] = match['base_code'].substr(0,base_pattern.length).match(base_pattern);
+ if (base_pattern[0] !== '^') {
+ base_pattern = "^" + base_pattern;
+ }
+ if (base_pattern[base_pattern.length -1] !== '$') {
+ base_pattern = base_pattern + ".*$";
+ }
+ match.match = match.base_code.match(base_pattern);
+
return match;
},
diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py
index dae5d0e7396..3e3a57ef369 100644
--- a/addons/base_action_rule/base_action_rule.py
+++ b/addons/base_action_rule/base_action_rule.py
@@ -27,6 +27,7 @@ import openerp
from openerp import SUPERUSER_ID
from openerp.osv import fields, osv
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
+from openerp.tools.safe_eval import safe_eval as eval
_logger = logging.getLogger(__name__)
diff --git a/addons/base_import/models.py b/addons/base_import/models.py
index 9778391521a..784ae7f49f1 100644
--- a/addons/base_import/models.py
+++ b/addons/base_import/models.py
@@ -158,12 +158,19 @@ class ir_import(orm.TransientModel):
all the fields to traverse
:rtype: list(Field)
"""
+ string_match = None
for field in fields:
# FIXME: should match all translations & original
# TODO: use string distance (levenshtein? hamming?)
- if header.lower() == field['name'].lower() \
- or header.lower() == field['string'].lower():
+ if header.lower() == field['name'].lower():
return [field]
+ if header.lower() == field['string'].lower():
+ # matching string are not reliable way because
+ # strings have no unique constraint
+ string_match = field
+ if string_match:
+ # this behavior is only applied if there is no matching field['name']
+ return [string_match]
if '/' not in header:
return []
diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py
index 74157cfb226..84fd9a24f58 100644
--- a/addons/calendar/calendar.py
+++ b/addons/calendar/calendar.py
@@ -480,13 +480,13 @@ class calendar_alarm_manager(osv.AbstractModel):
def get_next_notif(self, cr, uid, context=None):
ajax_check_every_seconds = 300
- partner = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id
+ partner = self.pool['res.users'].read(cr, SUPERUSER_ID, uid, ['partner_id', 'calendar_last_notif_ack'], context=context)
all_notif = []
if not partner:
return []
- all_events = self.get_next_potential_limit_alarm(cr, uid, ajax_check_every_seconds, partner_id=partner.id, mail=False, context=context)
+ all_events = self.get_next_potential_limit_alarm(cr, uid, ajax_check_every_seconds, partner_id=partner['partner_id'][0], mail=False, context=context)
for event in all_events: # .values()
max_delta = all_events[event]['max_duration']
@@ -496,7 +496,7 @@ class calendar_alarm_manager(osv.AbstractModel):
LastFound = False
for one_date in self.pool.get("calendar.event").get_recurrent_date_by_event(cr, uid, curEvent, context=context):
in_date_format = one_date.replace(tzinfo=None)
- LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner.calendar_last_notif_ack, mail=False, context=context)
+ LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner['calendar_last_notif_ack'], mail=False, context=context)
if LastFound:
for alert in LastFound:
all_notif.append(self.do_notif_reminder(cr, uid, alert, context=context))
@@ -506,7 +506,7 @@ class calendar_alarm_manager(osv.AbstractModel):
break
else:
in_date_format = datetime.strptime(curEvent.start, DEFAULT_SERVER_DATETIME_FORMAT)
- LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner.calendar_last_notif_ack, mail=False, context=context)
+ LastFound = self.do_check_alarm_for_one_date(cr, uid, in_date_format, curEvent, max_delta, ajax_check_every_seconds, after=partner['calendar_last_notif_ack'], mail=False, context=context)
if LastFound:
for alert in LastFound:
all_notif.append(self.do_notif_reminder(cr, uid, alert, context=context))
@@ -586,7 +586,7 @@ class calendar_alarm(osv.Model):
def _update_cron(self, cr, uid, context=None):
try:
cron = self.pool['ir.model.data'].get_object(
- cr, uid, 'calendar', 'ir_cron_scheduler_alarm', context=context)
+ cr, SUPERUSER_ID, 'calendar', 'ir_cron_scheduler_alarm', context=context)
except ValueError:
return False
return cron.toggle(model=self._name, domain=[('type', '=', 'email')])
@@ -702,6 +702,9 @@ class calendar_event(osv.Model):
val = pytz.UTC.localize(val)
return val.astimezone(timezone)
+ if context is None:
+ context = {}
+
timezone = pytz.timezone(context.get('tz') or 'UTC')
startdate = pytz.UTC.localize(datetime.strptime(event.start, DEFAULT_SERVER_DATETIME_FORMAT)) # Add "+hh:mm" timezone
if not startdate:
diff --git a/addons/crm/calendar_event_menu.xml b/addons/crm/calendar_event_menu.xml
index aec88a5748e..eb3889f0857 100644
--- a/addons/crm/calendar_event_menu.xml
+++ b/addons/crm/calendar_event_menu.xml
@@ -5,5 +5,16 @@
+
+ CRM - Meetings Search
+ calendar.event
+
+
+
+
+
+
+
+
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 67331b71ab7..432df5b4bee 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -82,31 +82,11 @@ class crm_lead(format_address, osv.osv):
context['empty_list_help_document_name'] = _("leads")
return super(crm_lead, self).get_empty_list_help(cr, uid, help, context=context)
- def _get_default_team_id(self, cr, uid, user_id=False, context=None):
- """ Gives default team by checking if present in the context """
- team_id = self._resolve_team_id_from_context(cr, uid, context=context) or False
- return team_id
-
def _get_default_stage_id(self, cr, uid, context=None):
""" Gives default stage_id """
- team_id = self._get_default_team_id(cr, uid, context=context)
+ team_id = self.pool['crm.team']._get_default_team_id(cr, uid, context=context)
return self.stage_find(cr, uid, [], team_id, [('fold', '=', False)], context=context)
- def _resolve_team_id_from_context(self, cr, uid, context=None):
- """ Returns ID of team based on the value of 'team_id'
- context key, or None if it cannot be resolved to a single
- Sales Team.
- """
- if context is None:
- context = {}
- if type(context.get('default_team_id')) in (int, long):
- return context.get('default_team_id')
- if isinstance(context.get('default_team_id'), basestring):
- team_ids = self.pool.get('crm.team').name_search(cr, uid, name=context['default_team_id'], context=context)
- if len(team_ids) == 1:
- return int(team_ids[0][0])
- return None
-
def _resolve_type_from_context(self, cr, uid, context=None):
""" Returns the type (lead or opportunity) from the type context
key. Returns None if it cannot be resolved.
@@ -127,7 +107,7 @@ class crm_lead(format_address, osv.osv):
# - OR ('case_default', '=', True), ('fold', '=', False): add default columns that are not folded
# - OR ('team_ids', '=', team_id), ('fold', '=', False) if team_id: add team columns that are not folded
search_domain = []
- team_id = self._resolve_team_id_from_context(cr, uid, context=context)
+ team_id = self.pool['crm.team']._resolve_team_id_from_context(cr, uid, context=context)
if team_id:
search_domain += ['|', ('team_ids', '=', team_id)]
search_domain += [('id', 'in', ids)]
@@ -282,7 +262,7 @@ class crm_lead(format_address, osv.osv):
'type': 'lead',
'user_id': lambda s, cr, uid, c: uid,
'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c),
- 'team_id': lambda s, cr, uid, c: s._get_default_team_id(cr, uid, context=c),
+ 'team_id': lambda s, cr, uid, c: s.pool['crm.team']._get_default_team_id(cr, uid, context=c),
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[0][0],
'color': 0,
@@ -329,7 +309,7 @@ class crm_lead(format_address, osv.osv):
def on_change_user(self, cr, uid, ids, user_id, context=None):
""" When changing the user, also set a team_id or restrict team id
to the ones user_id is member of. """
- team_id = self._get_default_team_id(cr, uid, context=context)
+ team_id = self.pool['crm.team']._get_default_team_id(cr, uid, user_id=user_id, context=context)
if user_id and not team_id and self.pool['res.users'].has_group(cr, uid, 'base.group_multi_salesteams'):
team_ids = self.pool.get('crm.team').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
if team_ids:
@@ -910,6 +890,7 @@ class crm_lead(format_address, osv.osv):
if lead.partner_id:
partner_ids.append(lead.partner_id.id)
res['context'] = {
+ 'search_default_opportunity_id': lead.type == 'opportunity' and lead.id or False,
'default_opportunity_id': lead.type == 'opportunity' and lead.id or False,
'default_partner_id': lead.partner_id and lead.partner_id.id or False,
'default_partner_ids': partner_ids,
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 9f30510a461..e419e181f14 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -410,8 +410,8 @@
-
-
+
+
diff --git a/addons/crm/crm_phonecall.py b/addons/crm/crm_phonecall.py
index f7e964aee12..b7885bf190b 100644
--- a/addons/crm/crm_phonecall.py
+++ b/addons/crm/crm_phonecall.py
@@ -77,6 +77,7 @@ class crm_phonecall(osv.osv):
'priority': '1',
'state': _get_default_state,
'user_id': lambda self, cr, uid, ctx: uid,
+ 'team_id': lambda s, cr, uid, c: s.pool['crm.team']._get_default_team_id(cr, uid, context=c),
'active': 1
}
diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv
index 5030138ae9a..6330d405714 100644
--- a/addons/crm/security/ir.model.access.csv
+++ b/addons/crm/security/ir.model.access.csv
@@ -7,6 +7,8 @@ access_crm_stage,crm.stage,model_crm_stage,,1,0,0,0
access_crm_stage_manager,crm.stage,model_crm_stage,base.group_sale_manager,1,1,1,1
access_crm_phonecall_report_user,crm.phonecall.report.user,model_crm_phonecall_report,base.group_sale_salesman,1,0,0,0
access_crm_phonecall_report_manager,crm.phonecall.report,model_crm_phonecall_report,base.group_sale_manager,1,1,1,1
+access_crm_opportunity_report_user,crm.opportunity.report,model_crm_opportunity_report,base.group_sale_salesman,1,0,0,0
+access_crm_opportunity_report_manager,crm.opportunity.report,model_crm_opportunity_report,base.group_sale_manager,1,1,1,1
access_res_partner_manager,res.partner.crm.manager,base.model_res_partner,base.group_sale_manager,1,0,0,0
access_res_partner_category_manager,res.partner.category.crm.manager,base.model_res_partner_category,base.group_sale_manager,1,0,0,0
access_res_partner,res.partner.crm.user,base.model_res_partner,base.group_sale_salesman,1,1,1,0
diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py
index 286d97d996f..d417d8a1cac 100644
--- a/addons/crm_claim/crm_claim.py
+++ b/addons/crm_claim/crm_claim.py
@@ -59,13 +59,9 @@ class crm_claim(osv.osv):
_order = "priority,date desc"
_inherit = ['mail.thread']
- def _get_default_team_id(self, cr, uid, context=None):
- """ Gives default team by checking if present in the context """
- return self.pool.get('crm.lead')._resolve_team_id_from_context(cr, uid, context=context) or False
-
def _get_default_stage_id(self, cr, uid, context=None):
""" Gives default stage_id """
- team_id = self._get_default_team_id(cr, uid, context=context)
+ team_id = self.pool['crm.team']._get_default_team_id(cr, uid, context=context)
return self.stage_find(cr, uid, [], team_id, [('sequence', '=', '1')], context=context)
_columns = {
@@ -103,7 +99,7 @@ class crm_claim(osv.osv):
_defaults = {
'user_id': lambda s, cr, uid, c: uid,
- 'team_id': lambda s, cr, uid, c: s._get_default_team_id(cr, uid, c),
+ 'team_id': lambda s, cr, uid, c: s.pool['crm.team']._get_default_team_id(cr, uid, context=c),
'date': fields.datetime.now,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.case', context=c),
'priority': '1',
diff --git a/addons/crm_claim/test/process/claim.yml b/addons/crm_claim/test/process/claim.yml
index f6c6f6d315c..1a68de8ea04 100644
--- a/addons/crm_claim/test/process/claim.yml
+++ b/addons/crm_claim/test/process/claim.yml
@@ -15,7 +15,7 @@
claim_ids = self.search(cr, uid, [('email_from','=', 'Mr. John Right ')])
assert claim_ids and len(claim_ids), "Claim is not created after getting request"
claim = self.browse(cr, uid, claim_ids[0], context=context)
- assert claim.name == tools.ustr("demande derèglement de votre produit."), "Subject does not match"
+ assert claim.name == tools.ustr("demande de règlement de votre produit."), "Subject does not match"
-
I open customer claim.
-
diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py
index c622d45da3a..8d7c85bf7a7 100644
--- a/addons/crm_helpdesk/crm_helpdesk.py
+++ b/addons/crm_helpdesk/crm_helpdesk.py
@@ -81,6 +81,7 @@ class crm_helpdesk(osv.osv):
'user_id': lambda s, cr, uid, c: uid,
'state': lambda *a: 'draft',
'date': fields.datetime.now,
+ 'team_id': lambda s, cr, uid, c: s.pool['crm.team']._get_default_team_id(cr, uid, context=c),
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
'priority': '1',
}
diff --git a/addons/crm_partner_assign/crm_lead.py b/addons/crm_partner_assign/crm_lead.py
index c37cfdfd72f..ab7faab28ea 100644
--- a/addons/crm_partner_assign/crm_lead.py
+++ b/addons/crm_partner_assign/crm_lead.py
@@ -21,6 +21,7 @@
from openerp.osv import osv
from openerp.tools.translate import _
+from openerp.tools.safe_eval import safe_eval as eval
from openerp.exceptions import UserError
diff --git a/addons/delivery/__openerp__.py b/addons/delivery/__openerp__.py
index dc5878424a5..aa1906e32f5 100644
--- a/addons/delivery/__openerp__.py
+++ b/addons/delivery/__openerp__.py
@@ -43,7 +43,8 @@ invoices from picking, OpenERP is able to add and compute the shipping line.
'demo': ['delivery_demo.xml'],
'test': [
'../account/test/account_minimal_test.xml',
- 'test/delivery_cost.yml'
+ 'test/delivery_cost.yml',
+ 'test/stock_move_values_with_invoice_before_delivery.yml',
],
'installable': True,
'auto_install': False,
diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py
index 81f88ca36dd..09d4e13b5fc 100644
--- a/addons/delivery/delivery.py
+++ b/addons/delivery/delivery.py
@@ -24,6 +24,7 @@ import time
from openerp.osv import fields,osv
from openerp.tools.translate import _
import openerp.addons.decimal_precision as dp
+from openerp.tools.safe_eval import safe_eval as eval
from openerp.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -215,6 +216,8 @@ class delivery_grid(osv.osv):
total_delivery = 0.0
product_uom_obj = self.pool.get('product.uom')
for line in order.order_line:
+ if line.state == 'cancel':
+ continue
if line.is_delivery:
total_delivery += line.price_subtotal + self.pool['sale.order']._amount_line_tax(cr, uid, line, context=context)
if not line.product_id or line.is_delivery:
diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py
index 6de57a21fff..f4855769d5d 100644
--- a/addons/delivery/sale.py
+++ b/addons/delivery/sale.py
@@ -66,6 +66,7 @@ class sale_order(osv.Model):
carrier_obj = self.pool.get('delivery.carrier')
acc_fp_obj = self.pool.get('account.fiscal.position')
self._delivery_unset(cr, uid, ids, context=context)
+ currency_obj = self.pool.get('res.currency')
for order in self.browse(cr, uid, ids, context=context):
grid_id = carrier_obj.grid_get(cr, uid, [order.carrier_id.id], order.partner_shipping_id.id)
if not grid_id:
@@ -79,6 +80,10 @@ class sale_order(osv.Model):
taxes = grid.carrier_id.product_id.taxes_id
fpos = order.fiscal_position_id or False
taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
+ price_unit = grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context)
+ if order.company_id.currency_id.id != order.pricelist_id.currency_id.id:
+ price_unit = currency_obj.compute(cr, uid, order.company_id.currency_id.id, order.pricelist_id.currency_id.id,
+ price_unit, context=dict(context or {}, date=order.date_order))
#create the sale order line
line_obj.create(cr, uid, {
'order_id': order.id,
@@ -86,7 +91,7 @@ class sale_order(osv.Model):
'product_uom_qty': 1,
'product_uom': grid.carrier_id.product_id.uom_id.id,
'product_id': grid.carrier_id.product_id.id,
- 'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
+ 'price_unit': price_unit,
'tax_id': [(6, 0, taxes_ids)],
'is_delivery': True
}, context=context)
diff --git a/addons/delivery/test/stock_move_values_with_invoice_before_delivery.yml b/addons/delivery/test/stock_move_values_with_invoice_before_delivery.yml
new file mode 100644
index 00000000000..61fa086c5c2
--- /dev/null
+++ b/addons/delivery/test/stock_move_values_with_invoice_before_delivery.yml
@@ -0,0 +1,79 @@
+-
+ test that the store fields of stock moves are computed with invoice before delivery flow
+-
+ set a weight on ipod 16GB
+-
+ !python {model: product.product, id: product.product_product_11}: |
+ self.write({'weight': 0.25, 'weight_net': 0.2})
+-
+ create a SO with invoice before delivery
+-
+ !record {model: sale.order, id: sale_prepaid}:
+ partner_id: base.res_partner_18
+ partner_invoice_id: base.res_partner_18
+ partner_shipping_id: base.res_partner_18
+ pricelist_id: product.list0
+ order_policy: 'prepaid'
+ order_line:
+ - name: 'Ipod'
+ product_id: product.product_product_11
+ product_uom_qty: 2
+ product_uos_qty: 2
+ product_uom: product.product_uom_unit
+ price_unit: 750.00
+ carrier_id: normal_delivery_carrier
+-
+ I add delivery cost in Sale order.
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ self.delivery_set()
+-
+ I confirm the SO.
+-
+ !workflow {model: sale.order, action: order_confirm, ref: sale_prepaid}
+-
+ I check that the invoice was created
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ assert len(self.invoice_ids) == 1, "Invoice not created."
+-
+ I confirm the invoice
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ invoice = self.invoice_ids[0]
+ invoice.signal_workflow('invoice_open')
+-
+ I pay the invoice.
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ invoice = self.invoice_ids[0]
+ invoice.signal_workflow('invoice_open')
+ journal = self.env['account.journal'].search([('type', '=', 'cash'),
+ ('company_id', '=', self.company_id.id)],
+ limit=1)
+ invoice.pay_and_reconcile(journal, invoice.amount_total)
+-
+ Check the SO after paying the invoice
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ assert self.invoice_count != 0, 'order not invoiced'
+ assert self.invoiced, 'order is not paid'
+ assert len(self.picking_ids) == 1, 'pickings not generated'
+-
+ check the stock moves
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ move = self.picking_ids.move_lines
+ assert move.product_qty == 2, 'wrong product_qty'
+ assert move.weight == 0.5, 'wrong move weight'
+ assert move.weight_net == 0.4, 'wrong move weight_net'
+-
+ ship
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ picking = self.picking_ids.action_done()
+-
+ Check the SO after shipping
+-
+ !python {model: sale.order, id: sale_prepaid}: |
+ assert self.state == 'done'
diff --git a/addons/document/document.py b/addons/document/document.py
index 0d08d54e7fb..de9f03c773c 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -115,8 +115,11 @@ class document_file(osv.osv):
ids.extend(parents[parent_id])
# sort result according to the original sort ordering
- ids = [id for id in orig_ids if id in ids]
- return len(ids) if count else ids
+ if count:
+ return len(ids)
+ else:
+ set_ids = set(ids)
+ return [id for id in orig_ids if id in set_ids]
def copy(self, cr, uid, id, default=None, context=None):
if not default:
diff --git a/addons/event/event.py b/addons/event/event.py
index f9915ff38fc..2293d192366 100644
--- a/addons/event/event.py
+++ b/addons/event/event.py
@@ -250,7 +250,7 @@ class event_event(models.Model):
return res
@api.one
- def mail_attendees(self, template_id, force_send=False, filter_func=lambda self: True):
+ def mail_attendees(self, template_id, force_send=True, filter_func=lambda self: True):
for attendee in self.registration_ids.filtered(filter_func):
self.env['mail.template'].browse(template_id).send_mail(attendee.id, force_send=force_send)
@@ -336,6 +336,7 @@ class event_registration(models.Model):
body=_('New registration confirmed: %s.') % (self.name or ''),
subtype="event.mt_event_registration")
self.state = 'open'
+ self.env['event.mail'].run()
@api.one
def button_reg_close(self):
diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml
index 6ec68c6b479..eed24fd3234 100644
--- a/addons/event/event_view.xml
+++ b/addons/event/event_view.xml
@@ -235,7 +235,7 @@
-
+
diff --git a/addons/event/tests/test_mail_schedule.py b/addons/event/tests/test_mail_schedule.py
index 752403ed22b..c712e48919f 100644
--- a/addons/event/tests/test_mail_schedule.py
+++ b/addons/event/tests/test_mail_schedule.py
@@ -60,7 +60,7 @@ class TestMailSchedule(TestEventCommon):
self.assertTrue(schedulers[0].done, 'event: reminder scheduler should be done')
mails = self.env['mail.mail'].search([('subject', 'ilike', 'reminder'), ('date', '>=', datetime.datetime.strftime(now, tools.DEFAULT_SERVER_DATETIME_FORMAT))], order='date DESC', limit=3)
- self.assertEqual(len(mails), 2, 'event: wrong number of reminder mail sent')
+ self.assertEqual(len(mails), 0, 'event: reminder to sent is not empty')
# check subscription scheduler
schedulers = self.EventMail.search([('event_id', '=', test_event.id), ('interval_type', '=', 'after_sub')])
diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py
index d4743f22bac..df90f78f5d1 100644
--- a/addons/google_calendar/google_calendar.py
+++ b/addons/google_calendar/google_calendar.py
@@ -414,7 +414,7 @@ class google_calendar(osv.AbstractModel):
user_obj = self.pool['res.users']
myPartnerID = user_obj.browse(cr, uid, uid, context).partner_id.id
attendee_record = []
- alarm_record = []
+ alarm_record = set()
partner_record = [(4, myPartnerID)]
result = {}
@@ -461,7 +461,7 @@ class google_calendar(osv.AbstractModel):
'name': "%s minutes - %s" % (google_alarm['minutes'], google_alarm['method'])
}
alarm_id = [calendar_alarm_obj.create(cr, uid, data, context=context)]
- alarm_record.append(alarm_id[0])
+ alarm_record.add(alarm_id[0])
UTC = pytz.timezone('UTC')
if single_event_dict.get('start') and single_event_dict.get('end'): # If not cancelled
@@ -489,7 +489,7 @@ class google_calendar(osv.AbstractModel):
result.update({
'attendee_ids': attendee_record,
'partner_ids': list(set(partner_record)),
- 'alarm_ids': [(6, 0, alarm_record)],
+ 'alarm_ids': [(6, 0, list(alarm_record))],
'name': single_event_dict.get('summary', 'Event'),
'description': single_event_dict.get('description', False),
@@ -976,7 +976,9 @@ class calendar_event(osv.Model):
_inherit = "calendar.event"
def get_fields_need_update_google(self, cr, uid, context=None):
- return ['name', 'description', 'allday', 'date', 'date_end', 'stop', 'attendee_ids', 'alarm_ids', 'location', 'class', 'active']
+ return ['name', 'description', 'allday', 'start', 'date_end', 'stop',
+ 'attendee_ids', 'alarm_ids', 'location', 'class', 'active',
+ 'start_date', 'start_datetime', 'stop_date', 'stop_datetime']
def write(self, cr, uid, ids, vals, context=None):
if context is None:
diff --git a/addons/google_drive/google_drive.py b/addons/google_drive/google_drive.py
index 8bfc6fd7697..b26cc44860e 100644
--- a/addons/google_drive/google_drive.py
+++ b/addons/google_drive/google_drive.py
@@ -23,6 +23,7 @@ from openerp import SUPERUSER_ID
from openerp.addons.google_account import TIMEOUT
from openerp.osv import fields, osv
from openerp.tools.translate import _
+from openerp.tools.safe_eval import safe_eval as eval
from openerp.exceptions import UserError
import werkzeug.urls
diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py
index 3e2aec8b621..dc46c0e4cf9 100644
--- a/addons/hr_timesheet/hr_timesheet.py
+++ b/addons/hr_timesheet/hr_timesheet.py
@@ -159,12 +159,12 @@ class account_analytic_account(models.Model):
@api.onchange('invoice_on_timesheets')
def onchange_invoice_on_timesheets(self):
- result = {}
+ result = {'value': {}}
if not self.invoice_on_timesheets:
return {'value': {'to_invoice': False}}
try:
to_invoice = self.env['ir.model.data'].xmlid_to_res_id('hr_timesheet_invoice.timesheet_invoice_factor1')
- result['to_invoice'] = to_invoice
+ result['value']['to_invoice'] = to_invoice
except ValueError:
pass
return result
diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py
index d622d9310bf..a706cbdbf95 100644
--- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py
+++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py
@@ -314,8 +314,8 @@ class account_analytic_line(osv.osv):
res['value']['to_invoice'] = st or False
if acc.state == 'pending':
res['warning'] = {
- 'title': 'Warning',
- 'message': 'The analytic account is in pending state.\nYou should not work on this account !'
+ 'title': _('Warning'),
+ 'message': _('The analytic account is in pending state.\nYou should not work on this account !')
}
elif acc.state == 'close' or acc.state == 'cancelled':
raise osv.except_osv(_('Invalid Analytic Account!'), _('You cannot select a Analytic Account which is in Close or Cancelled state.'))
diff --git a/addons/hw_proxy/controllers/main.py b/addons/hw_proxy/controllers/main.py
index 64f6cf0765c..337874cf67a 100644
--- a/addons/hw_proxy/controllers/main.py
+++ b/addons/hw_proxy/controllers/main.py
@@ -192,12 +192,12 @@ class Proxy(http.Controller):
print 'print_receipt' + str(receipt)
@http.route('/hw_proxy/is_scanner_connected', type='json', auth='none', cors='*')
- def print_receipt(self, receipt):
+ def is_scanner_connected(self, receipt):
print 'is_scanner_connected?'
return False
@http.route('/hw_proxy/scanner', type='json', auth='none', cors='*')
- def print_receipt(self, receipt):
+ def scanner(self, receipt):
print 'scanner'
time.sleep(10)
return ''
diff --git a/addons/hw_scale/__openerp__.py b/addons/hw_scale/__openerp__.py
index 6c83a854730..387a7e618d9 100644
--- a/addons/hw_scale/__openerp__.py
+++ b/addons/hw_scale/__openerp__.py
@@ -37,6 +37,7 @@ such as the Mettler Toledo Ariva.
""",
'author': 'OpenERP SA',
'depends': ['hw_proxy'],
+ 'external_dependencies': {'python': ['serial']},
'test': [
],
'installable': True,
diff --git a/addons/hw_scale/controllers/main.py b/addons/hw_scale/controllers/main.py
index 531f2739f55..44a031f5566 100644
--- a/addons/hw_scale/controllers/main.py
+++ b/addons/hw_scale/controllers/main.py
@@ -178,28 +178,34 @@ class Scale(Thread):
if not self.device:
time.sleep(5)
-s = Scale()
-
-hw_proxy.drivers['scale'] = s
+scale_thread = None
+if serial:
+ scale_thread = Scale()
+ hw_proxy.drivers['scale'] = scale_thread
class ScaleDriver(hw_proxy.Proxy):
@http.route('/hw_proxy/scale_read/', type='json', auth='none', cors='*')
def scale_read(self):
- return {'weight':s.get_weight(), 'unit':'kg', 'info':s.get_weight_info()}
+ if scale_thread:
+ return {'weight': scale_thread.get_weight(), 'unit':'kg', 'info': scale_thread.get_weight_info()}
+ return None
@http.route('/hw_proxy/scale_zero/', type='json', auth='none', cors='*')
def scale_zero(self):
- s.set_zero()
+ if scale_thread:
+ scale_thread.set_zero()
return True
@http.route('/hw_proxy/scale_tare/', type='json', auth='none', cors='*')
def scale_tare(self):
- s.set_tare()
+ if scale_thread:
+ scale_thread.set_tare()
return True
@http.route('/hw_proxy/scale_clear_tare/', type='json', auth='none', cors='*')
def scale_clear_tare(self):
- s.clear_tare()
+ if scale_thread:
+ scale_thread.clear_tare()
return True
diff --git a/addons/hw_scanner/__openerp__.py b/addons/hw_scanner/__openerp__.py
index aa74b0fbc5b..f38fa7dc420 100644
--- a/addons/hw_scanner/__openerp__.py
+++ b/addons/hw_scanner/__openerp__.py
@@ -38,6 +38,7 @@ point of sale module.
""",
'author': 'OpenERP SA',
'depends': ['hw_proxy'],
+ 'external_dependencies': {'python': ['evdev']},
'test': [
],
'installable': True,
diff --git a/addons/hw_scanner/controllers/main.py b/addons/hw_scanner/controllers/main.py
index 057674c1ca1..6e53c37006f 100644
--- a/addons/hw_scanner/controllers/main.py
+++ b/addons/hw_scanner/controllers/main.py
@@ -111,8 +111,6 @@ class Scanner(Thread):
def get_device(self):
try:
- if not evdev:
- return None
devices = [ device for device in listdir(self.input_dir)]
keyboards = [ device for device in devices if ('kbd' in device) and ('keyboard' not in device.lower())]
scanners = [ device for device in devices if ('barcode' in device.lower()) or ('scanner' in device.lower())]
@@ -135,7 +133,6 @@ class Scanner(Thread):
been returned before. This is necessary to catch barcodes scanned while the POS is
busy reading another barcode
"""
-
self.lockedstart()
while True:
@@ -204,12 +201,12 @@ class Scanner(Thread):
except Exception as e:
self.set_status('error',str(e))
-s = Scanner()
-
-hw_proxy.drivers['scanner'] = s
+scanner_thread = None
+if evdev:
+ scanner_thread = Scanner()
+ hw_proxy.drivers['scanner'] = scanner_thread
class ScannerDriver(hw_proxy.Proxy):
@http.route('/hw_proxy/scanner', type='json', auth='none', cors='*')
def scanner(self):
- return s.get_barcode()
-
+ return scanner_thread.get_barcode() if scanner_thread else None
diff --git a/addons/im_chat/static/src/xml/im_chat.xml b/addons/im_chat/static/src/xml/im_chat.xml
index 9adef41a24f..80447cc38d0 100644
--- a/addons/im_chat/static/src/xml/im_chat.xml
+++ b/addons/im_chat/static/src/xml/im_chat.xml
@@ -87,7 +87,7 @@
-
+
diff --git a/addons/im_livechat/models/im_chat_session.py b/addons/im_livechat/models/im_chat_session.py
index 0cae7f76c46..f4c00329a11 100644
--- a/addons/im_livechat/models/im_chat_session.py
+++ b/addons/im_livechat/models/im_chat_session.py
@@ -49,8 +49,11 @@ class ImChatSession(models.Model):
"""
self.ensure_one()
users_infos = super(ImChatSession, self).session_user_info()
+ # identify the operator for the 'welcome message'
+ for user_profile in users_infos:
+ user_profile['is_operator'] = bool(user_profile['id'] == self.env._context.get('im_livechat_operator_id'))
if self.anonymous_name:
- users_infos.append({'id': False, 'name': self.anonymous_name, 'im_status': 'online'})
+ users_infos.append({'id': False, 'name': self.anonymous_name, 'im_status': 'online', 'is_operator': False})
return users_infos
@api.model
diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py
index 258b4e2aeb1..85b202e002f 100644
--- a/addons/im_livechat/models/im_livechat_channel.py
+++ b/addons/im_livechat/models/im_livechat_channel.py
@@ -171,7 +171,7 @@ class ImLivechatChannel(models.Model):
user_to_add.append((4, self.env.uid))
# create the session, and add the link with the given channel
session = self.env["im_chat.session"].sudo().create({'user_ids': user_to_add, 'channel_id': channel_id, 'anonymous_name': anonymous_name})
- return session.sudo().session_info()
+ return session.sudo().with_context(im_livechat_operator_id=user_id).session_info()
@api.model
def get_channel_infos(self, channel_id):
diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js
index 88c234378a0..15f3f5bae09 100644
--- a/addons/im_livechat/static/src/js/im_livechat.js
+++ b/addons/im_livechat/static/src/js/im_livechat.js
@@ -203,12 +203,13 @@ var ChatButton = Widget.extend({
if(this.session.users.length > 0){
if (self.options.defaultMessage) {
setTimeout(function(){
+ var operator = _.last(_.filter(self.session.users, function(user){return user.is_operator}));
self.conv.message_receive({
id : 1,
type: "message",
message: self.options.defaultMessage,
create_date: time.datetime_to_str(new Date()),
- from_id: [self.session.users[0].id, self.session.users[0].name],
+ from_id: [operator.id, operator.name],
to_id: [0, self.session.uuid]
});
}, 1000);
diff --git a/addons/im_odoo_support/static/src/js/im_odoo_support.js b/addons/im_odoo_support/static/src/js/im_odoo_support.js
index 4945ba49ca2..ec61c18af06 100644
--- a/addons/im_odoo_support/static/src/js/im_odoo_support.js
+++ b/addons/im_odoo_support/static/src/js/im_odoo_support.js
@@ -11,7 +11,7 @@ var Widget = require('web.Widget');
var _t = core._t;
-var COOKIE_NAME = 'livechat_conversation';
+var COOKIE_NAME = 'odoo_livechat_conversation';
var SERVICE_URL = 'https://services.odoo.com/';
var OdooSupport = Widget.extend({
diff --git a/addons/l10n_ca/account_chart_en.xml b/addons/l10n_ca/account_chart_en.xml
index fb7532e6ff8..86228db2c35 100644
--- a/addons/l10n_ca/account_chart_en.xml
+++ b/addons/l10n_ca/account_chart_en.xml
@@ -259,101 +259,119 @@
LABOUR TAXES TO PAY
-
- 2141
-
- CANADIAN REVENU AGENCY
-
+
+ 2141
+
+ CANADA REVENUE AGENCY
+
-
- 21411
-
- EMPLOYMENT INSURANCE TO PAY
-
+
+ 21411
+
+ EMPLOYMENT INSURANCE TO PAY
+
-
- 214111
+
+ 214111
- EI - Employees Contribution
-
+ EI - Employees Contribution
+
-
- 214112
+
+ 214112
- EI - Employer Contribution
-
+ EI - Employer Contribution
+
-
- 21412
+
+ 21412
- Federal Income Tax
-
+ Federal Income Tax
+
-
- 2142
-
- PROVINCIAL REVENU AGENCY
-
+
+ 21413
+
+ CANADA PENSION PLAN TO PAY
+
-
- 21421
+
+ 214131
+
+ CPP - Employees Contribution
+
+
+
+ 214132
+
+ CPP - Employer Contribution
+
+
+
+ 2142
+
+ PROVINCIAL REVENU AGENCY
+
+
+
+ 21421
- Health Services Fund to pay
-
+ Health Services Fund to pay
+
-
- 21422
-
- ANNUITIES TO PAY
-
+
+ 21422
+
+ PROVINCIAL PENSION PLAN TO PAY
+
-
- 214221
+
+ 214221
- Annuities - Employees Contribution
-
+ Provincial Pension Plan - Employees Contribution
+
-
- 214222
+
+ 214222
- Annuities - Employer Contribution
-
+ Provincial Pension Plan - Employer Contribution
+
-
- 21423
-
- PARENTAL INSURANCE PLAN TO PAY
-
+
+ 21423
+
+ PROVINCIAL PARENTAL INSURANCE PLAN TO PAY
+
-
- 214231
+
+ 214231
- PAP - Employee Contribution
-
+ Parental Insurance Plan - Employee Contribution
+
-
- 214232
+
+ 214232
- PAP - Employer Contribution
-
+ Parental Insurance Plan - Employer Contribution
+
-
- 21424
+
+ 21424
- Labour Health and Safety to pay
-
+ Labour Health and Safety to pay
+
-
- 21425
+
+ 21425
- Labour Standards to pay
-
+ Labour Standards to pay
+
-
- 21426
+
+ 21426
- Provincial Income Tax
-
+ Provincial Income Tax
+ 215
@@ -379,6 +397,66 @@
Stock Received But Not Billed
+
+ 218
+
+ CURRENT LIABILITIES RELATED TO SALARIES
+
+
+
+ 2181
+
+ Salaries to pay
+
+
+
+ 2183
+
+ Bonus to pay
+
+
+
+ 2184
+
+ Retroactive Payment to pay
+
+
+
+ 2185
+
+ GROUP PENSION PLAN TO PAY
+
+
+
+ 218501
+
+ Group Pension Plan to pay - Employees Contribution
+
+
+
+ 218502
+
+ Group Pension Plan to pay - Employer Contribution
+
+
+
+ 2186
+
+ EMPLOYEE BENEFITS
+
+
+
+ 218601
+
+ Employee Benefits Provision - Employees Contribution
+
+
+
+ 218602
+
+ Employee Benefits Provision - Employer Contribution
+
+
25
@@ -387,8 +465,6 @@
251
-
- viewNON-CURRENT FINANCIAL DEBTS
@@ -399,12 +475,54 @@
PROVISIONS FOR PENSIONS AND OTHER POST-EMPLOYMENT ADVANTAGES
-
- 254
+
+ 2521
+
+ Provision for pension plans
+
+
+
+ 253DEFERRED TAXES
+
+ 254
+
+ NON-CURRENT LIABILITIES RELATED TO SALARIES
+
+
+
+ 2541
+
+ Leaves Accruded
+
+
+
+ 254101
+
+ Vacations Accruded
+
+
+
+ 254102
+
+ Compensatory Days Accruded
+
+
+
+ 254103
+
+ Sick Leaves Accruded
+
+
+
+ 2542
+
+ Bonus Accruded
+
+
259
@@ -561,71 +679,127 @@
International Purchases
-
- 512
-
- LABOUR EXPENSES
-
+
+ 512
+
+ LABOUR EXPENSES
+
-
- 51201
-
- Salaries, wages and commissions
-
+
+ 5121
+
+
+ Salaries
+
-
- 51202
-
- Holidays
-
+
+ 512101
-
- 51203
-
- Employment Insurance
-
+
+ Regular Salaries
+
-
- 51204
-
- Health Services Fund
-
+
+ 512102
+
+ Bonus
+
-
- 51205
-
- Annuities
-
+
+ 512103
+
+ Retroactive Pay
+
-
- 51206
-
- Parental Insurance
-
+
+ 5122
+
+
+ Leaves Accruded
+
-
- 51207
-
- Labour Health and Safety
-
+
+ 512201
+
+ Vacations Accruded
+
-
- 51208
-
- Labour Standards
-
+
+ 512202
+
-
- 51209
-
- Federal Income Tax
-
+ Compensatory Days Accruded
+
-
- 51210
+
+ 512203
+
+ Sick Leaves Accruded
+
+
+
+ 5123
+
+
+ Employer Contributions
+
+
+
+ 512301
+
+
+ Canada Pension Plan
+
+
+
+ 512302
+
+ Employment Insurance
+
+
+
+ 512303
- Provincial Income Tax
-
+ Group Pension Plan
+
+
+
+ 512304
+
+ Employee benefits expense
+
+
+
+ 512310
+
+ Provincial Pension Plan
+
+
+
+ 512311
+
+ Provincial Parental Insurance Plan
+
+
+
+ 512312
+
+ Labour Health and Safety
+
+
+
+ 512313
+
+ Labour Standards
+
+
+
+ 512314
+
+ Health Service Fund
+
+
513
diff --git a/addons/l10n_ca/account_chart_fr.xml b/addons/l10n_ca/account_chart_fr.xml
index 00674ac4e12..b24de09d845 100644
--- a/addons/l10n_ca/account_chart_fr.xml
+++ b/addons/l10n_ca/account_chart_fr.xml
@@ -253,107 +253,127 @@
TVH à payer - 15%
-
- 214
-
- IMPÔTS LIÉS AUX SALAIRES À PAYER
-
-
-
- 2141
-
- AGENCE DU REVENU DU CANADA
-
+
+ 214
+
+ DAS ET CONTRIBUTIONS DE L'EMPLOYEUR À PAYER
+
-
- 21411
-
- ASSURANCE EMPLOI À PAYER
-
+
+ 2141
+
+ AGENCE DU REVENU DU CANADA
+
-
- 214111
+
+ 21411
+
+ ASSURANCE EMPLOI À PAYER
+
+
+
+ 214111
- AE - Contribution des employés
-
+ AE - Contribution des employés
+
-
- 214112
+
+ 214112
- AE - Contribution de l'employeur
-
+ AE - Contribution de l'employeur
+
-
- 21412
+
+ 21412
- Impôt fédéral sur les revenus
-
+ Impôt fédéral sur les revenus
+
-
- 2142
-
- AGENCE DU REVENU PROVINCIAL
-
+
+ 21413
+
+ RÉGIME DE PENSIONS DU CANADA À PAYER
+
-
- 21421
+
+ 214131
+
+
+ RPC - Contribution des employés
+
+
+
+ 214132
+
+
+ RPC - Contribution de l'employeur
+
+
+
+ 2142
+
+ AGENCE PROVINCIALE
+
+
+
+ 21421
- Fond des Services de Santé à payer
-
+ Fond des Services de Santé à payer
+
-
- 21422
-
- RENTES À PAYER
-
+
+ 21422
+
+ RÉGIME DE PENSION PROVINCIAL À PAYER
+
-
- 214221
+
+ 214221
- Rentes - Contribution des employés
-
+ Régime de pension provincial - Contribution des employés
+
-
- 214222
+
+ 214222
- Rentes - Contribution de l'employeur
-
+ Régime de pension provincial - Contribution de l'employeur
+
-
- 21423
-
- ASSURANCE PARENTALE À PAYER
-
-
-
- 214231
-
- AP - Contribution des employés
-
-
-
- 214232
-
- AP - Contribution de l'employeur
-
+
+ 21423
+
+ RÉGIME PROVINCIAL D'ASSURANCE PARENTALE À PAYER
+
-
- 21424
+
+ 214231
- Santé et Sécurité au Travail à payer
-
+ Assurance parentale - Contribution des employés
+
-
- 21425
+
+ 214232
- Normes du Travail à payer
-
+ Assurance parentale - Contribution de l'employeur
+
-
- 21426
+
+ 21424
- Impôt provincial sur les revenus
-
+ Santé et Sécurité au Travail à payer
+
+
+
+ 21425
+
+ Normes du Travail à payer
+
+
+
+ 21426
+
+ Impôt provincial sur les revenus
+ 215
@@ -379,6 +399,67 @@
Stock reçu non facturé
+
+ 218
+
+ PASSIFS COURANTS LIÉS AUX SALAIRES
+
+
+
+ 2181
+
+ Salaires à payer
+
+
+
+ 2183
+
+ Bonis à payer
+
+
+
+ 2184
+
+ Paie Rétroactive à payer
+
+
+
+
+ 2185
+
+ RÉGIMES DE PENSION COLLECTIFS À PAYER
+
+
+
+ 218501
+
+ Régimes de pension collectifs à payer - Contribution des employés
+
+
+
+ 218502
+
+ Régimes de pension collectifs à payer - Contribution de l'employeur
+
+
+
+ 2186
+
+ PROVISION POUR AVANTAGES SOCIAUX
+
+
+
+ 218601
+
+ Provision pour avantages sociaux - Contribution de l'employé
+
+
+
+ 218602
+
+ Provision pour avantages sociaux - Contribution de l'employeur
+
+
25
@@ -397,17 +478,53 @@
PROVISIONS POUR RETRAITES ET AUTRES AVANTAGES POSTÉRIEURS À L'EMPLOI
-
- 253
-
- IMPÔTS DIFFÉRÉS
-
-
-
- 254
-
- AUTRES PASSIFS NON-COURANTS
-
+
+ 253
+
+ IMPÔTS DIFFÉRÉS
+
+
+
+ 254
+
+ PASSIFS NON-COURANTS LIÉS AUX SALAIRES
+
+
+
+ 2541
+
+ Congés Accumulés
+
+
+
+ 254101
+
+ Vacances Accumulées
+
+
+
+ 254102
+
+ Jours Compensatoires Accumulés
+
+
+
+ 254103
+
+ Congés de Maladie Accumulés
+
+
+
+ 2542
+
+ Bonis Accumulés
+
+
+
+ 259
+
+ AUTRES PASSIFS NON-COURANTS
+
@@ -565,71 +682,125 @@
Achats à l'étranger
-
- 512
-
- SALAIRES ET CHARGES SOCIALES
-
+
+ 512
+
+ SALAIRES ET CHARGES SOCIALES
+
-
- 51201
-
- Salaires
-
+
+ 5121
+
+
+ Salaires
+
-
- 51202
-
- Vacances
-
+
+ 512101
+
+ Salaires Réguliers
+
-
- 51203
-
- Assurance Emploi
-
+
+ 512102
-
- 51204
-
- Fonds des services de santé
-
+
+ Bonis
+
-
- 51205
-
- Rentes
-
+
+ 512103
+
+ Paies Rétroactives
+
-
- 51206
-
- Assurance parentale
-
+
+ 5122
-
- 51207
-
- Santé et sécurité au travail
-
+
+ Congés Accumulées
+
-
- 51208
-
- Normes du travail
-
+
+ 512201
+
+ Vacances Accumulées
+
-
- 51209
-
- Impôt fédéral
-
+
+ 512202
-
- 51210
+
+ Jours Compensatoires Accumulées
+
+
+
+ 512203
+
+ Congés de Maladie Accumulés
+
+
+
+ 5123
+
+
+ Contributions de l'Employeur
+
+
+
+ 512301
+
+ Régime de Pensions du Canada
+
+
+
+ 512302
+
+
+ Assurance Emploi
+
+
+
+ 512303
- Impôt provincial
-
+ Régimes de pension collectifs
+
+
+
+ 512304
+
+ Dépense d'avantages sociaux
+
+
+
+ 512310
+
+ Régime de pension provincial
+
+
+
+ 512311
+
+ Régime d'assurance parental provincial
+
+
+
+ 512312
+
+ Santé et sécurité au travail
+
+
+
+ 512313
+
+ Normes du travail
+
+
+
+ 512314
+
+ Fonds des services de santé
+ 513
diff --git a/addons/l10n_ca/account_tax_en.xml b/addons/l10n_ca/account_tax_en.xml
index 54073d0f545..10e7bc79483 100644
--- a/addons/l10n_ca/account_tax_en.xml
+++ b/addons/l10n_ca/account_tax_en.xml
@@ -14,6 +14,8 @@
1percent1
+
+
@@ -28,6 +30,8 @@
+
+
@@ -41,6 +45,8 @@
+
+
@@ -53,6 +59,8 @@
1percent
+
+
@@ -67,6 +75,8 @@
+
+
@@ -80,6 +90,8 @@
+
+
@@ -92,6 +104,8 @@
1percent
+
+
@@ -105,6 +119,8 @@
+
+
@@ -118,6 +134,8 @@
+
+
@@ -130,6 +148,8 @@
1percent
+
+
@@ -144,6 +164,8 @@
+
+
@@ -157,6 +179,8 @@
+
+
@@ -170,6 +194,8 @@
percent
+
+
@@ -181,6 +207,8 @@
percent
+
+
@@ -192,6 +220,8 @@
percent
+
+
@@ -205,6 +235,8 @@
percent
+
+
@@ -219,6 +251,8 @@
1percent1
+
+
@@ -233,6 +267,8 @@
+
+
@@ -246,6 +282,8 @@
+
+
@@ -258,6 +296,8 @@
1percent
+
+
@@ -272,6 +312,8 @@
+
+
@@ -285,6 +327,8 @@
+
+
@@ -297,6 +341,8 @@
1percent
+
+
@@ -310,6 +356,8 @@
+
+
@@ -323,6 +371,8 @@
+
+
@@ -335,6 +385,8 @@
1percent
+
+
@@ -349,6 +401,8 @@
+
+
@@ -362,6 +416,8 @@
+
+
@@ -375,6 +431,8 @@
percent
+
+
@@ -386,6 +444,8 @@
percent
+
+
@@ -397,6 +457,8 @@
percent
+
+
@@ -410,6 +472,8 @@
percent
+
+
diff --git a/addons/l10n_ca/account_tax_fr.xml b/addons/l10n_ca/account_tax_fr.xml
index 793bb1c750e..2a72eb1af77 100644
--- a/addons/l10n_ca/account_tax_fr.xml
+++ b/addons/l10n_ca/account_tax_fr.xml
@@ -14,6 +14,8 @@
11percent
+
+
@@ -28,6 +30,8 @@
+
+
@@ -41,6 +45,8 @@
+
+
@@ -53,6 +59,8 @@
1percent
+
+
@@ -67,6 +75,8 @@
+
+
@@ -80,6 +90,8 @@
+
+
@@ -92,6 +104,8 @@
1percent
+
+
@@ -105,6 +119,8 @@
+
+
@@ -118,6 +134,8 @@
+
+
@@ -130,6 +148,8 @@
1percent
+
+
@@ -144,6 +164,8 @@
+
+
@@ -157,6 +179,8 @@
+
+
@@ -170,6 +194,8 @@
percent
+
+
@@ -181,6 +207,8 @@
percent
+
+
@@ -192,6 +220,8 @@
percent
+
+
@@ -205,6 +235,8 @@
percent
+
+
@@ -220,6 +252,8 @@
1percent1
+
+
@@ -234,6 +268,8 @@
+
+
@@ -247,6 +283,8 @@
+
+
@@ -259,6 +297,8 @@
1percent
+
+
@@ -273,6 +313,8 @@
+
+
@@ -286,6 +328,8 @@
+
+
@@ -298,6 +342,8 @@
1percent
+
+
@@ -311,6 +357,8 @@
+
+
@@ -324,6 +372,8 @@
+
+
@@ -336,6 +386,8 @@
1percent
+
+
@@ -350,6 +402,8 @@
+
+
@@ -363,6 +417,8 @@
+
+
@@ -376,6 +432,8 @@
percent
+
+
@@ -387,6 +445,8 @@
percent
+
+
@@ -398,6 +458,8 @@
percent
+
+
@@ -411,6 +473,8 @@
percent
+
+
diff --git a/addons/l10n_fr/report/base_report.py b/addons/l10n_fr/report/base_report.py
index 8e9c75161e1..d38dcd5c007 100644
--- a/addons/l10n_fr/report/base_report.py
+++ b/addons/l10n_fr/report/base_report.py
@@ -28,6 +28,7 @@
import time
from openerp.report import report_sxw
+from openerp.tools.safe_eval import safe_eval as eval
class base_report(report_sxw.rml_parse):
diff --git a/addons/l10n_jp/__init__.py b/addons/l10n_jp/__init__.py
new file mode 100644
index 00000000000..03d6a3a323c
--- /dev/null
+++ b/addons/l10n_jp/__init__.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) Rooms For (Hong Kong) Limited T/A OSCG
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/l10n_jp/__openerp__.py b/addons/l10n_jp/__openerp__.py
new file mode 100644
index 00000000000..85acc113fc5
--- /dev/null
+++ b/addons/l10n_jp/__openerp__.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) Rooms For (Hong Kong) Limited T/A OSCG
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+{
+ 'name': 'Japan - Accounting',
+ 'version': '1.2',
+ 'category': 'Localization/Account Charts',
+ 'description': """
+
+Overview:
+---------
+
+* Chart of Accounts and Taxes template for companies in Japan.
+* This probably does not cover all the necessary accounts for a company. \
+You are expected to add/delete/modify accounts based on this template.
+
+Note:
+-----
+
+* Fiscal positions '内税' and '外税' have been added to handle special \
+requirements which might arise from POS implementation. [1] You may not \
+need to use these at all under normal circumstances.
+
+[1] See https://github.com/odoo/odoo/pull/6470 for detail.
+
+ """,
+ 'author': 'Rooms For (Hong Kong) Limited T/A OSCG',
+ 'website': 'http://www.openerp-asia.net/',
+ 'depends': ['account'],
+ 'data': [
+ 'data/account.account.template.csv',
+ 'data/account.tax.code.template.csv',
+ 'data/account.chart.template.csv',
+ 'data/account.tax.template.csv',
+ 'data/account.fiscal.position.template.csv',
+ ],
+ 'installable': False,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/l10n_jp/data/account.account.template.csv b/addons/l10n_jp/data/account.account.template.csv
new file mode 100644
index 00000000000..06a61786351
--- /dev/null
+++ b/addons/l10n_jp/data/account.account.template.csv
@@ -0,0 +1,157 @@
+id,code,name,parent_id:id,type,user_type/id,tax_ids/id,reconcile,currency_id/id
+COM0,0,日本勘定科目表,,View,account.data_account_type_view,,FALSE,
+A,A,貸借対照表,COM0,View,account.data_account_type_view,,FALSE,
+A1,A1,資産の部,A,View,account.account_type_asset_view1,,FALSE,
+A11,A11,流動資産,A1,View,account.account_type_asset_view1,,FALSE,
+A111,A111,現金・預金,A11,View,account.account_type_asset_view1,,FALSE,
+A11101,A11101,普通預金,A111,Liquidity,account.data_account_type_cash,,FALSE,
+A11102,A11102,当座預金,A111,Liquidity,account.data_account_type_cash,,FALSE,
+A11103,A11103,定期預金,A111,Liquidity,account.data_account_type_cash,,FALSE,
+A11105,A11105,小口現金,A111,Liquidity,account.data_account_type_cash,,FALSE,
+A112,A112,売掛金等,A11,View,account.account_type_asset_view1,,FALSE,
+A11211,A11211,売掛金,A112,Receivable,account.data_account_type_receivable,,TRUE,
+A11212,A11212,売掛金(USD),A112,Receivable,account.data_account_type_receivable,,TRUE,base.USD
+A11215,A11215,受取手形,A112,Receivable,account.data_account_type_receivable,,TRUE,
+A11216,A11216,割引手形,A112,Receivable,account.data_account_type_receivable,,TRUE,
+A11219,A11219,出庫請求仮,A112,Regular,account.data_account_type_receivable,,FALSE,
+A11301,A11301,未収収益,A11,Regular,account.data_account_type_asset,,FALSE,
+A11401,A11401,有価証券,A11,Regular,account.data_account_type_asset,,FALSE,
+A115,A115,在庫,A11,View,account.account_type_asset_view1,,FALSE,
+A11501,A11501,商品,A115,Regular,account.data_account_type_asset,,FALSE,
+A11503,A11503,製品,A115,Regular,account.data_account_type_asset,,FALSE,
+A11504,A11504,仕掛品,A115,Regular,account.data_account_type_asset,,FALSE,
+A11505,A11505,原材料,A115,Regular,account.data_account_type_asset,,FALSE,
+A11506,A11506,資材,A115,Regular,account.data_account_type_asset,,FALSE,
+A11503,A11503,積送品,A115,Regular,account.data_account_type_asset,,FALSE,
+A11601,A11601,未収金,A11,Receivable,account.data_account_type_receivable,,TRUE,
+A118,A118,その他流動資産,A11,View,account.account_type_asset_view1,,FALSE,
+A11802,A11802,前渡金,A118,Regular,account.data_account_type_asset,,FALSE,
+A11804,A11804,前払費用,A118,Regular,account.data_account_type_asset,,FALSE,
+A11805,A11805,立替金,A118,Regular,account.data_account_type_asset,,FALSE,
+A11806,A11806,仮払金,A118,Regular,account.data_account_type_asset,,FALSE,
+A11807,A11807,仮払消費税,A118,Regular,account.conf_account_type_tax,,FALSE,
+A11901,A11901,貸倒引当金,A11,Regular,account.data_account_type_asset,,FALSE,
+A12,A12,固定資産,A1,View,account.account_type_asset_view1,,FALSE,
+A121,A121,有形固定資産,A12,View,account.account_type_asset_view1,,FALSE,
+A1211,A1211,建物及び構築物(純額),A121,View,account.account_type_asset_view1,,FALSE,
+A12111,A12111,建物及び構築物,A1211,Regular,account.data_account_type_asset,,FALSE,
+A12112,A12112,建物及び構築物減償累計額,A1211,Regular,account.data_account_type_asset,,FALSE,
+A1212,A1212,機械及び装置(純額),A121,View,account.account_type_asset_view1,,FALSE,
+A12121,A12121,機械及び装置,A1212,Regular,account.data_account_type_asset,,FALSE,
+A12122,A12122,機械及び装置物減償累計額,A1212,Regular,account.data_account_type_asset,,FALSE,
+A1213,A1213,工具、機器及び備品(純額),A121,View,account.account_type_asset_view1,,FALSE,
+A12131,A12131,工具、機器及び備品,A1213,Regular,account.data_account_type_asset,,FALSE,
+A12132,A12132,工具、機器及び備品減償累計額,A1213,Regular,account.data_account_type_asset,,FALSE,
+A12141,A12141,土地,A121,Regular,account.data_account_type_asset,,FALSE,
+A122,A122,無形固定資産,A12,View,account.account_type_asset_view1,,FALSE,
+A1221,A1221,ソフトウェア,A122,Regular,account.data_account_type_asset,,FALSE,
+A1222,A1222,ソフトウェア仮勘定,A122,Regular,account.data_account_type_asset,,FALSE,
+A1223,A1223,その他無形固定資産,A122,Regular,account.data_account_type_asset,,FALSE,
+A123,A123,投資その他資産,A12,View,account.account_type_asset_view1,,FALSE,
+A12301,A12301,投資有価証券,A123,Regular,account.data_account_type_asset,,FALSE,
+A12302,A12302,関係会社株式,A123,Regular,account.data_account_type_asset,,FALSE,
+A12303,A12303,長期貸付金,A123,Regular,account.data_account_type_asset,,FALSE,
+A13,A13,繰延資産,A1,View,account.account_type_asset_view1,,FALSE,
+A13001,A13001,創立費,A13,Regular,account.data_account_type_asset,,FALSE,
+A2,A2,負債の部,A,View,account.account_type_liability_view1,,FALSE,
+A21,A21,流動負債,A2,View,account.account_type_liability_view1,,FALSE,
+A212,A212,買掛金等,A21,View,account.account_type_liability_view1,,FALSE,
+A21211,A21211,買掛金,A212,Payable,account.data_account_type_payable,,TRUE,
+A21212,A21212,買掛金(USD),A212,Payable,account.data_account_type_payable,,TRUE,base.USD
+A21215,A21215,支払手形,A212,Payable,account.data_account_type_payable,,TRUE,
+A21219,A21219,入庫請求仮,A212,Regular,account.data_account_type_payable,,FALSE,
+A213,A213,短期借入金等,A212,Payable,account.data_account_type_payable,,TRUE,
+A21301,A21301,短期借入金,A21,Payable,account.data_account_type_payable,,TRUE,
+A21302,A21302,一年以内返済長期借入金,A21,Payable,account.data_account_type_payable,,TRUE,
+A214,A214,未払金等,A21,View,account.account_type_liability_view1,,FALSE,
+A21401,A21401,未払金,A214,Payable,account.data_account_type_payable,,TRUE,
+A21404,A21404,未払金(クレジット),A214,Payable,account.data_account_type_payable,,TRUE,
+A21407,A21407,未払配当金,A214,Payable,account.data_account_type_payable,,TRUE,
+A21501,A21501,未払費用,A21,Regular,account.data_account_type_liability,,FALSE,
+A21601,A21601,未払法人税等,A21,Regular,account.conf_account_type_tax,,FALSE,
+A218,A218,その他流動負債,A21,View,account.account_type_liability_view1,,FALSE,
+A21802,A21802,前受金,A218,Regular,account.data_account_type_liability,,FALSE,
+A21803,A21803,預り金,A218,Regular,account.data_account_type_liability,,FALSE,
+A21804,A21804,仮受金,A218,Regular,account.data_account_type_liability,,FALSE,
+A21806,A21806,賞与引当金,A218,Regular,account.data_account_type_liability,,FALSE,
+A21807,A21807,仮受消費税,A218,Regular,account.conf_account_type_tax,,FALSE,
+A22,A22,固定負債,A2,View,account.account_type_liability_view1,,FALSE,
+A22001,A22001,社債,A22,Regular,account.data_account_type_liability,,FALSE,
+A22002,A22002,長期借入金,A22,Regular,account.data_account_type_liability,,FALSE,
+A22005,A22005,退職給付引当金,A22,Regular,account.data_account_type_liability,,FALSE,
+A3,A3,純資産の部,A,View,account.account_type_liability_view1,,FALSE,
+A31,A31,株主資本,A3,View,account.account_type_liability_view1,,FALSE,
+A31001,A31001,資本金,A31,Regular,account.conf_account_type_equity,,FALSE,
+A32,A32,資本剰余金,A3,View,account.account_type_liability_view1,,FALSE,
+A32101,A32101,資本準備金,A32,Regular,account.conf_account_type_equity,,FALSE,
+A32109,A32109,その他資本剰余金,A32,Regular,account.conf_account_type_equity,,FALSE,
+A33,A33,利益剰余金,A3,View,account.account_type_liability_view1,,FALSE,
+A33101,A33101,利益準備金,A33,Regular,account.conf_account_type_equity,,FALSE,
+A332,A332,その他利益剰余金,A33,View,account.account_type_liability_view1,,FALSE,
+A33202,A33202,特別償却準備金,A332,Regular,account.conf_account_type_equity,,FALSE,
+A33204,A33204,任意積立金,A332,Regular,account.conf_account_type_equity,,FALSE,
+A33209,A33209,繰越利益剰余金,A332,Regular,account.conf_account_type_equity,,FALSE,
+B,B,損益計算書,COM0,View,account.data_account_type_view,,FALSE,
+B4,B4,売上総利益,B,View,account.account_type_income_view1,,FALSE,
+B41001,B41001,売上高,B4,Regular,account.data_account_type_income,,FALSE,
+B42001,B42001,売上原価,B4,Regular,account.data_account_type_income,,FALSE,
+B42091,B42091,購買価格差異,B4,Regular,account.data_account_type_income,,FALSE,
+B42092,B42092,棚卸調整,B4,Regular,account.data_account_type_income,,FALSE,
+B5,B5,販売費及び一般管理費,B,View,account.account_type_expense_view1,,FALSE,
+B50011,B50011,貸倒引当金繰入額,B5,Regular,account.data_account_type_expense,,FALSE,
+B50041,B50041,役員報酬,B5,Regular,account.data_account_type_expense,,FALSE,
+B50071,B50071,給料及び手当,B5,Regular,account.data_account_type_expense,,FALSE,
+B50081,B50081,賞与,B5,Regular,account.data_account_type_expense,,FALSE,
+B50091,B50091,退職金,B5,Regular,account.data_account_type_expense,,FALSE,
+B50111,B50111,賞与引当金繰入,B5,Regular,account.data_account_type_expense,,FALSE,
+B50131,B50131,退職給付引当金繰入,B5,Regular,account.data_account_type_expense,,FALSE,
+B50151,B50151,法定福利費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50161,B50161,福利厚生費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50171,B50171,保険料,B5,Regular,account.data_account_type_expense,,FALSE,
+B50191,B50191,外注費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50211,B50211,荷造運賃,B5,Regular,account.data_account_type_expense,,FALSE,
+B50221,B50221,棚卸減耗費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50231,B50231,商品評価損,B5,Regular,account.data_account_type_expense,,FALSE,
+B50241,B50241,地代家賃,B5,Regular,account.data_account_type_expense,,FALSE,
+B50251,B50251,リース料,B5,Regular,account.data_account_type_expense,,FALSE,
+B50271,B50271,広告宣伝費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50281,B50281,通信費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50311,B50311,消耗品費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50341,B50341,旅費交通費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50371,B50371,交際費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50401,B50401,支払手数料,B5,Regular,account.data_account_type_expense,,FALSE,
+B50431,B50431,諸会費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50461,B50461,新聞図書費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50491,B50491,租税公課,B5,Regular,account.data_account_type_expense,,FALSE,
+B50511,B50511,水道光熱費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50521,B50521,会議費,B5,Regular,account.data_account_type_expense,,FALSE,
+B50551,B50551,雑費,B5,Regular,account.data_account_type_expense,,FALSE,
+B61,B61,営業外収益,B,View,account.account_type_income_view1,,FALSE,
+B61101,B61101,受取利息,B61,Regular,account.data_account_type_income,,FALSE,
+B61201,B61201,受取配当金,B61,Regular,account.data_account_type_income,,FALSE,
+B61401,B61401,未実現為替差益,B61,Regular,account.data_account_type_income,,FALSE,
+B61501,B61501,実現為替差益,B61,Regular,account.data_account_type_income,,FALSE,
+B61601,B61601,投資有価証券売却益(外益),B61,Regular,account.data_account_type_income,,FALSE,
+B61602,B61602,投資有価証券評価益(外益),B61,Regular,account.data_account_type_income,,FALSE,
+B61801,B61801,雑収入,B61,Regular,account.data_account_type_income,,FALSE,
+B62,B62,営業外費用,B,View,account.account_type_expense_view1,,FALSE,
+B62101,B62101,支払利息,B62,Regular,account.data_account_type_expense,,FALSE,
+B62201,B62201,創立費償却,B62,Regular,account.data_account_type_expense,,FALSE,
+B62401,B62401,未実現為替差損,B62,Regular,account.data_account_type_expense,,FALSE,
+B62402,B62402,実現為替差損,B62,Regular,account.data_account_type_expense,,FALSE,
+B62601,B62601,投資有価証券売却損(外損),B62,Regular,account.data_account_type_expense,,FALSE,
+B62602,B62602,投資有価証券評価損(外損),B62,Regular,account.data_account_type_expense,,FALSE,
+B62801,B62801,雑費用,B62,Regular,account.data_account_type_expense,,FALSE,
+B71,B71,特別利益,B,View,account.account_type_income_view1,,FALSE,
+B71101,B71101,固定資産売却益,B71,Regular,account.data_account_type_income,,FALSE,
+B71102,B71102,固定資産評価益,B71,Regular,account.data_account_type_income,,FALSE,
+B71201,B71201,投資有価証券売却益(特益),B71,Regular,account.data_account_type_income,,FALSE,
+B71202,B71202,投資有価証券評価益(特益),B71,Regular,account.data_account_type_income,,FALSE,
+B72,B72,特別損失,B,View,account.account_type_expense_view1,,FALSE,
+B72101,B72101,固定資産売却損,B72,Regular,account.data_account_type_expense,,FALSE,
+B72102,B72102,固定資産評価損,B72,Regular,account.data_account_type_expense,,FALSE,
+B72201,B72201,投資有価証券売却損(特損),B72,Regular,account.data_account_type_expense,,FALSE,
+B72202,B72202,投資有価証券評価損(特損),B72,Regular,account.data_account_type_expense,,FALSE,
+B8,B8,法人税等,B,View,account.account_type_expense_view1,,FALSE,
+B80101,B80101,法人税、住民税及び事業税,B8,Regular,account.data_account_type_expense,,FALSE,
+B90001,B90001,期間利益,B,Regular,account.data_account_type_expense,,FALSE,
diff --git a/addons/l10n_jp/data/account.chart.template.csv b/addons/l10n_jp/data/account.chart.template.csv
new file mode 100644
index 00000000000..8488d0445aa
--- /dev/null
+++ b/addons/l10n_jp/data/account.chart.template.csv
@@ -0,0 +1,2 @@
+id,name,account_root_id/id,tax_code_root_id/id,bank_account_view_id/id,property_account_receivable/id,property_account_payable/id,property_account_expense_categ/id,property_account_income_categ/id,property_account_expense/id,property_account_income/id
+l10n_jp1,日本勘定設定テンプレート,COM0,jpt_root,A111,A11211,A21211,A21219,B41001,A21219,B41001
diff --git a/addons/l10n_jp/data/account.fiscal.position.template.csv b/addons/l10n_jp/data/account.fiscal.position.template.csv
new file mode 100644
index 00000000000..07e7b11531d
--- /dev/null
+++ b/addons/l10n_jp/data/account.fiscal.position.template.csv
@@ -0,0 +1,7 @@
+id,chart_template_id/id,name,note,tax_ids/tax_src_id/id,tax_ids/tax_dest_id/id
+fiscal_position_tax_inclusive_template,l10n_jp1,内税,,tax_in_e,tax_in_i
+,,,,tax_out_e,tax_out_i
+fiscal_position_tax_exclusive_template,l10n_jp1,外税,,tax_in_i,tax_in_e
+,,,,tax_out_i,tax_out_e
+fiscal_position_tax_exempt_template,l10n_jp1,海外取引先,,tax_in_e,tax_in_x
+,,,,tax_out_e,tax_out_im
diff --git a/addons/l10n_jp/data/account.tax.code.template.csv b/addons/l10n_jp/data/account.tax.code.template.csv
new file mode 100644
index 00000000000..71bf73cff47
--- /dev/null
+++ b/addons/l10n_jp/data/account.tax.code.template.csv
@@ -0,0 +1,20 @@
+id,name,parent_id/id,code,notprintable,sign
+jpt_root,日本税チャート,,,FALSE,1
+jpt_tax_code_balance_net,支払対象税額,jpt_root,,FALSE,1
+jpt_tax_code_input,仮受税額,jpt_tax_code_balance_net,,FALSE,-1
+jpt_tax_code_input_A,仮受消費税(8%),jpt_tax_code_input,,FALSE,1
+jpt_tax_code_input_X,免税,jpt_tax_code_input,,FALSE,1
+jpt_tax_code_input_O,不課税,jpt_tax_code_input,,FALSE,1
+jpt_tax_code_output,仮払税額,jpt_tax_code_balance_net,,FALSE,1
+jpt_tax_code_output_A,仮払消費税(8%),jpt_tax_code_output,,FALSE,1
+jpt_tax_code_output_I,輸入,jpt_tax_code_output,,FALSE,1
+jpt_tax_code_output_O,不課税,jpt_tax_code_output,,FALSE,1
+jpt_tax_code_base_net,税計算基準額,jpt_root,,FALSE,1
+jpt_tax_code_base_sales,販売基準額,jpt_tax_code_base_net,,FALSE,1
+jpt_tax_code_sales_A,課税対象売上(8%),jpt_tax_code_base_sales,,FALSE,1
+jpt_tax_code_sales_X,免税売上,jpt_tax_code_base_sales,,FALSE,1
+jpt_tax_code_sales_O,不課税売上,jpt_tax_code_base_sales,,FALSE,1
+jpt_tax_code_base_purchases,購買基準額,jpt_tax_code_base_net,,FALSE,1
+jpt_tax_code_purch_A,課税対象仕入(8%),jpt_tax_code_base_purchases,,FALSE,1
+jpt_tax_code_purch_I,輸入仕入,jpt_tax_code_base_purchases,,FALSE,1
+jpt_tax_code_purch_O,不課税仕入,jpt_tax_code_base_purchases,,FALSE,1
diff --git a/addons/l10n_jp/data/account.tax.template.csv b/addons/l10n_jp/data/account.tax.template.csv
new file mode 100644
index 00000000000..d029c0d41e0
--- /dev/null
+++ b/addons/l10n_jp/data/account.tax.template.csv
@@ -0,0 +1,9 @@
+id,name,description,chart_template_id/id,type_tax_use,type,amount,price_include,sequence,include_base_amount,account_collected_id/id,base_code_id/id,base_sign,tax_code_id/id,tax_sign,account_paid_id/id,ref_base_code_id/id,ref_base_sign,ref_tax_code_id/id,ref_tax_sign,child_depend
+tax_in_e,仮受消費税(外),,l10n_jp1,sale,percent,0.08,FALSE,1,FALSE,A11807,jpt_tax_code_sales_A,1,jpt_tax_code_input_A,1,A11807,jpt_tax_code_sales_A,1,jpt_tax_code_input_A,1,FALSE
+tax_in_i,仮受消費税(内),,l10n_jp1,sale,percent,0.08,TRUE,1,FALSE,A11807,jpt_tax_code_sales_A,1,jpt_tax_code_input_A,1,A11807,jpt_tax_code_sales_A,1,jpt_tax_code_input_A,1,FALSE
+tax_in_x,輸出免税,,l10n_jp1,sale,percent,,FALSE,1,FALSE,,jpt_tax_code_sales_X,1,jpt_tax_code_input_X,1,,jpt_tax_code_sales_X,1,jpt_tax_code_input_X,1,FALSE
+tax_in_o,非課税販売,,l10n_jp1,sale,percent,,FALSE,1,FALSE,,jpt_tax_code_sales_O,1,jpt_tax_code_input_O,1,,jpt_tax_code_sales_O,1,jpt_tax_code_input_O,1,FALSE
+tax_out_e,仮払消費税(外),,l10n_jp1,purchase,percent,0.08,FALSE,1,FALSE,A21807,jpt_tax_code_purch_A,1,jpt_tax_code_output_A,1,A21807,jpt_tax_code_purch_A,1,jpt_tax_code_output_A,1,FALSE
+tax_out_i,仮払消費税(内),,l10n_jp1,purchase,percent,0.08,TRUE,1,FALSE,A21807,jpt_tax_code_purch_A,1,jpt_tax_code_output_A,1,A21807,jpt_tax_code_purch_A,1,jpt_tax_code_output_A,1,FALSE
+tax_out_im,海外仕入,,l10n_jp1,purchase,percent,,FALSE,1,FALSE,,jpt_tax_code_purch_I,1,jpt_tax_code_output_I,1,,jpt_tax_code_purch_I,1,jpt_tax_code_output_I,1,FALSE
+tax_out_o,非課税購買,,l10n_jp1,purchase,percent,,FALSE,1,FALSE,,jpt_tax_code_purch_O,1,jpt_tax_code_output_O,1,,jpt_tax_code_purch_O,1,jpt_tax_code_output_O,1,FALSE
diff --git a/addons/l10n_jp/static/description/icon.png b/addons/l10n_jp/static/description/icon.png
new file mode 100644
index 00000000000..96bc158944e
Binary files /dev/null and b/addons/l10n_jp/static/description/icon.png differ
diff --git a/addons/mail/models/mail_alias.py b/addons/mail/models/mail_alias.py
index 3136174a657..56844ad5243 100644
--- a/addons/mail/models/mail_alias.py
+++ b/addons/mail/models/mail_alias.py
@@ -8,6 +8,7 @@ from openerp import _, api, fields, models, SUPERUSER_ID
from openerp.exceptions import UserError
from openerp.modules.registry import RegistryManager
from openerp.tools import ustr
+from openerp.tools.safe_eval import safe_eval as eval
_logger = logging.getLogger(__name__)
diff --git a/addons/mail/models/mail_followers.py b/addons/mail/models/mail_followers.py
index 441caadbccc..db1c20e8f00 100644
--- a/addons/mail/models/mail_followers.py
+++ b/addons/mail/models/mail_followers.py
@@ -181,6 +181,7 @@ class Notification(models.Model):
mail_values = {
'mail_message_id': message.id,
'auto_delete': self._context.get('mail_auto_delete', True),
+ 'mail_server_id': self._context.get('mail_server_id', False),
'body_html': body_html,
'recipient_ids': [(4, id) for id in chunk],
'references': references,
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py
index bb010372025..7e191f9517d 100644
--- a/addons/mail/models/mail_message.py
+++ b/addons/mail/models/mail_message.py
@@ -17,7 +17,9 @@ def decode(text):
# TDE proposal: move to tools ?
if text:
text = decode_header(text.replace('\r', ''))
- return ''.join([tools.ustr(x[0], x[1]) for x in text])
+ # The joining space will not be needed as of Python 3.3
+ # See https://hg.python.org/cpython/rev/8c03fe231877
+ return ' '.join([tools.ustr(x[0], x[1]) for x in text])
class Message(models.Model):
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 4872200ef15..ab3ddf4f65c 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -49,7 +49,7 @@ var TimelineRecordThread = form_common.AbstractField.extend ({
'readonly': this.node.attrs.readonly || false,
'compose_placeholder' : this.node.attrs.placeholder || false,
'display_log_button' : this.options.display_log_button || true,
- 'show_compose_message': this.view.is_action_enabled('edit') || false,
+ 'show_compose_message': true,
'show_link': this.parent.is_action_enabled('edit') || true,
}, this.node.params);
},
@@ -1434,7 +1434,6 @@ var ComposeMessage = Attachment.extend ({
}
}
}
-
this.$(".o_timeline_msg_attachment_list").html(this.display_attachments(this));
var $input = this.$('input.oe_form_binary_file');
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 83af81104ec..2a8957fa35f 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -216,7 +216,7 @@ class MailComposer(models.TransientModel):
if wizard.template_id:
# template user_signature is added when generating body_html
# mass mailing: use template auto_delete value -> note, for emails mass mailing only
- Mail = Mail.with_context(mail_notify_user_signature=False, mail_auto_delete=wizard.template_id.auto_delete)
+ Mail = Mail.with_context(mail_notify_user_signature=False, mail_auto_delete=wizard.template_id.auto_delete, mail_server_id=wizard.template_id.mail_server_id.id)
if wizard.attachment_ids and wizard.composition_mode != 'mass_mail' and wizard.template_id:
new_attachment_ids = []
for attachment in wizard.attachment_ids:
@@ -285,7 +285,7 @@ class MailComposer(models.TransientModel):
# static wizard (mail.message) values
mail_values = {
'subject': self.subject,
- 'body': self.body,
+ 'body': self.body or '',
'parent_id': self.parent_id and self.parent_id.id,
'partner_ids': [partner.id for partner in self.partner_ids],
'attachment_ids': [attach.id for attach in self.attachment_ids],
diff --git a/addons/mass_mailing/models/mass_mailing_stats.py b/addons/mass_mailing/models/mass_mailing_stats.py
index 7b929f5f24f..2136110ae14 100644
--- a/addons/mass_mailing/models/mass_mailing_stats.py
+++ b/addons/mass_mailing/models/mass_mailing_stats.py
@@ -19,9 +19,7 @@
#
##############################################################################
-import openerp
from openerp.osv import fields, osv
-from openerp import models, api, _
class MailMailStats(osv.Model):
@@ -35,28 +33,27 @@ class MailMailStats(osv.Model):
_rec_name = 'message_id'
_order = 'message_id'
- def _compute_state(self, cr, uid, stat_ids, field_names, arg, context=None):
- stats = self.browse(cr, uid, stat_ids, context=context)
- res = dict([(stat, False) for stat in stat_ids])
+ def _compute_state(self, cr, uid, ids, field_names, arg, context=None):
+ res = dict((i, {'state': 'outgoing', 'state_update': fields.datetime.now()}) for i in ids)
- self.write(cr, uid, stat_ids, {'state_update': fields.datetime.now()}, context=context)
-
- for stat in stats:
+ for stat in self.browse(cr, uid, ids, context=context):
if stat.exception:
- res[stat.id] = 'exception'
+ res[stat.id]['state'] = 'exception'
if stat.sent:
- res[stat.id] = 'sent'
+ res[stat.id]['state'] = 'sent'
if stat.opened:
- res[stat.id] = 'opened'
+ res[stat.id]['state'] = 'opened'
if stat.replied:
- res[stat.id] = 'replied'
+ res[stat.id]['state'] = 'replied'
if stat.bounced:
- res[stat.id] = 'bounced'
+ res[stat.id]['state'] = 'bounced'
return res
+ __store = {_name: ((lambda s, c, u, i, t: i), ['exception', 'sent', 'opened', 'replied', 'bounced'], 10)}
+
_columns = {
- 'mail_mail_id': fields.many2one('mail.mail', 'Mail', ondelete='set null'),
+ 'mail_mail_id': fields.many2one('mail.mail', 'Mail', ondelete='set null', select=True),
'mail_mail_id_int': fields.integer(
'Mail ID (tech)',
help='ID of the related mail_mail. This field is an integer field because'
@@ -86,10 +83,17 @@ class MailMailStats(osv.Model):
'replied': fields.datetime('Replied', help='Date when this email has been replied for the first time.'),
'bounced': fields.datetime('Bounced', help='Date when this email has bounced.'),
'links_click_ids': fields.one2many('website.links.click', 'mail_stat_id', 'Links click'),
- 'state': fields.function(_compute_state, string='State', type="selection",
- selection=[('outgoing', 'Outgoing'), ('exception', 'Exception'), ('sent', 'Sent'), ('opened', 'Opened'), ('replied', 'Replied'), ('bounced', 'Bounced')],
- store={'mail.mail.statistics': (lambda self, cr, uid, ids, context=None: ids, ['exception', 'sent', 'opened', 'replied', 'bounced'], 10)}),
- 'state_update': fields.datetime('State Update', help='Last state update of the mail'),
+ 'state': fields.function(_compute_state, string='State', type="selection", multi="state",
+ selection=[('outgoing', 'Outgoing'),
+ ('exception', 'Exception'),
+ ('sent', 'Sent'),
+ ('opened', 'Opened'),
+ ('replied', 'Replied'),
+ ('bounced', 'Bounced')],
+ store=__store),
+ 'state_update': fields.function(_compute_state, string='State Update', type='datetime',
+ multi='state', help='Last state update of the mail',
+ store=__store),
}
_defaults = {
diff --git a/addons/mass_mailing/views/mass_mailing.xml b/addons/mass_mailing/views/mass_mailing.xml
index dbda4773f07..6b8f23f9116 100644
--- a/addons/mass_mailing/views/mass_mailing.xml
+++ b/addons/mass_mailing/views/mass_mailing.xml
@@ -271,7 +271,7 @@
- Contact Lists
+ Mailing Listsmail.mass_mailing.listformtree,form
diff --git a/addons/membership/membership_view.xml b/addons/membership/membership_view.xml
index c06e65f0c3d..51295ca03c7 100644
--- a/addons/membership/membership_view.xml
+++ b/addons/membership/membership_view.xml
@@ -262,7 +262,7 @@
-
+
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 504c43e065d..1817d212669 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -25,7 +25,7 @@ from collections import OrderedDict
import openerp.addons.decimal_precision as dp
from openerp.osv import fields, osv
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
-from openerp.tools import float_compare
+from openerp.tools import float_compare, float_is_zero
from openerp.tools.translate import _
from openerp import tools, SUPERUSER_ID
from openerp.addons.product import _common
@@ -215,6 +215,8 @@ class mrp_bom(osv.osv):
@param properties: List of related properties.
@return: False or BoM id.
"""
+ if not context:
+ context = {}
if properties is None:
properties = []
if product_id:
@@ -232,19 +234,21 @@ class mrp_bom(osv.osv):
else:
# neither product nor template, makes no sense to search
return False
+ if context.get('company_id'):
+ domain = domain + [('company_id', '=', context['company_id'])]
domain = domain + [ '|', ('date_start', '=', False), ('date_start', '<=', time.strftime(DEFAULT_SERVER_DATE_FORMAT)),
'|', ('date_stop', '=', False), ('date_stop', '>=', time.strftime(DEFAULT_SERVER_DATE_FORMAT))]
# order to prioritize bom with product_id over the one without
- ids = self.search(cr, uid, domain, order='product_id', context=context)
+ ids = self.search(cr, uid, domain, order='sequence, product_id', context=context)
# Search a BoM which has all properties specified, or if you can not find one, you could
- # pass a BoM without any properties
+ # pass a BoM without any properties with the smallest sequence
bom_empty_prop = False
for bom in self.pool.get('mrp.bom').browse(cr, uid, ids, context=context):
if not set(map(int, bom.property_ids or [])) - set(properties or []):
- if properties and not bom.property_ids:
- bom_empty_prop = bom.id
- else:
+ if not properties or bom.property_ids:
return bom.id
+ elif not bom_empty_prop:
+ bom_empty_prop = bom.id
return bom_empty_prop
def _bom_explode(self, cr, uid, bom, product, factor, properties=None, level=0, routing_id=False, previous_products=None, master_bom=None, context=None):
@@ -300,6 +304,9 @@ class mrp_bom(osv.osv):
if not product or (set(map(int,bom_line_id.attribute_value_ids or [])) - set(map(int,product.attribute_value_ids))):
continue
+ if set(map(int, bom_line_id.property_ids or [])) - set(properties or []):
+ continue
+
if previous_products and bom_line_id.product_id.product_tmpl_id.id in previous_products:
raise UserError(_('BoM "%s" contains a BoM line with a product recursion: "%s".') % (master_bom.name,bom_line_id.product_id.name_get()[0][1]))
@@ -421,6 +428,7 @@ class mrp_bom_line(osv.osv):
'product_rounding': lambda *a: 0.0,
'type': lambda *a: 'normal',
'product_uom': _get_uom_id,
+ 'sequence': 1,
}
_sql_constraints = [
('bom_qty_zero', 'CHECK (product_qty>0)', 'All product quantities must be greater than 0.\n' \
@@ -602,7 +610,7 @@ class mrp_production(osv.osv):
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'product_qty': lambda *a: 1.0,
'user_id': lambda self, cr, uid, c: uid,
- 'name': lambda x, y, z, c: x.pool.get('ir.sequence').next_by_code(y, z, 'mrp.production') or '/',
+ 'name': lambda self, cr, uid, context: self.pool['ir.sequence'].next_by_code(cr, uid, 'mrp.production', context=context) or '/',
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),
'location_src_id': _src_id_default,
'location_dest_id': _dest_id_default
@@ -745,7 +753,7 @@ class mrp_production(osv.osv):
#reset workcenter_lines in production order
for line in results2:
line['production_id'] = production.id
- workcenter_line_obj.create(cr, uid, line)
+ workcenter_line_obj.create(cr, uid, line, context)
return results
def action_compute(self, cr, uid, ids, properties=None, context=None):
@@ -948,6 +956,7 @@ class mrp_production(osv.osv):
uom_obj = self.pool.get("product.uom")
production = self.browse(cr, uid, production_id, context=context)
production_qty_uom = uom_obj._compute_qty(cr, uid, production.product_uom.id, production_qty, production.product_id.uom_id.id)
+ precision = self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure')
main_production_move = False
if production_mode == 'consume_produce':
@@ -969,7 +978,8 @@ class mrp_production(osv.osv):
location_id=produce_product.location_id.id, restrict_lot_id=lot_id, context=context)
stock_mov_obj.write(cr, uid, new_moves, {'production_id': production_id}, context=context)
remaining_qty = subproduct_factor * production_qty_uom - qty
- if remaining_qty: # In case you need to make more than planned
+ if not float_is_zero(remaining_qty, precision_rounding=precision):
+ # In case you need to make more than planned
#consumed more in wizard than previously planned
extra_move_id = stock_mov_obj.copy(cr, uid, produce_product.id, default={'product_uom_qty': remaining_qty,
'production_id': production_id}, context=context)
@@ -999,7 +1009,7 @@ class mrp_production(osv.osv):
stock_mov_obj.action_consume(cr, uid, [raw_material_line.id], consumed_qty, raw_material_line.location_id.id,
restrict_lot_id=consume['lot_id'], consumed_for=main_production_move, context=context)
remaining_qty -= consumed_qty
- if remaining_qty:
+ if not float_is_zero(remaining_qty, precision_rounding=precision):
#consumed more in wizard than previously planned
product = self.pool.get('product.product').browse(cr, uid, consume['product_id'], context=context)
extra_move_id = self._make_consume_line_from_data(cr, uid, production, product, product.uom_id.id, remaining_qty, False, 0, context=context)
@@ -1242,6 +1252,8 @@ class mrp_production(osv.osv):
""" Confirms production order.
@return: Newly generated Shipment Id.
"""
+ user_lang = self.pool.get('res.users').browse(cr, uid, [uid]).partner_id.lang
+ context = dict(context, lang=user_lang)
uncompute_ids = filter(lambda x: x, [not x.product_lines and x.id or False for x in self.browse(cr, uid, ids, context=context)])
self.action_compute(cr, uid, uncompute_ids, context=context)
for production in self.browse(cr, uid, ids, context=context):
diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml
index 6732a5c3447..77b7ad4f2f6 100644
--- a/addons/mrp/mrp_demo.xml
+++ b/addons/mrp/mrp_demo.xml
@@ -452,6 +452,25 @@
normal
+
+ PC Assemble + DDR 512MB
+
+
+ 5
+ normal
+
+
+
+
+ RAM SR2 PLUS
+
+
+
+ 5
+ phantom
+
+
+
1
@@ -501,7 +520,7 @@
PC Assemble + 512MB RAM
- 5
+ 4phantom
@@ -639,6 +658,35 @@
+
+
+ 1
+
+ 1
+ normal
+
+
+
+
+
+
+ 1
+
+ 1
+ normal
+
+
+
+
+
+
+ 1
+
+ 1
+ normal
+
+
+
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 168276eb2db..c4bb0ba5655 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -400,6 +400,7 @@
+
diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py
index 7969a7f724a..a0a9863491e 100644
--- a/addons/mrp/procurement.py
+++ b/addons/mrp/procurement.py
@@ -87,7 +87,7 @@ class procurement_order(osv.osv):
else:
properties = [x.id for x in procurement.property_ids]
bom_id = bom_obj._bom_find(cr, uid, product_id=procurement.product_id.id,
- properties=properties, context=context)
+ properties=properties, context=dict(context, company_id=procurement.company_id.id))
bom = bom_obj.browse(cr, uid, bom_id, context=context)
routing_id = bom.routing_id.id
return {
@@ -117,7 +117,7 @@ class procurement_order(osv.osv):
if self.check_bom_exists(cr, uid, [procurement.id], context=context):
#create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
vals = self._prepare_mo_vals(cr, uid, procurement, context=context)
- produce_id = production_obj.create(cr, SUPERUSER_ID, vals, context=context)
+ produce_id = production_obj.create(cr, SUPERUSER_ID, vals, context=dict(context, force_company=procurement.company_id.id))
res[procurement.id] = produce_id
self.write(cr, uid, [procurement.id], {'production_id': produce_id})
self.production_order_create_note(cr, uid, procurement, context=context)
diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py
index 0aa91010c14..77e3b0d27b6 100644
--- a/addons/mrp/stock.py
+++ b/addons/mrp/stock.py
@@ -44,6 +44,7 @@ class StockMove(osv.osv):
if move.raw_material_production_id and move.location_dest_id.usage == 'production' and move.raw_material_production_id.product_id.track_production and not move.consumed_for:
raise UserError(_("Because the product %s requires it, you must assign a serial number to your raw material %s to proceed further in your production. Please use the 'Produce' button to do so.") % (move.raw_material_production_id.product_id.name, move.product_id.name))
+ # TODO master: remove me, no longer used
def _check_phantom_bom(self, cr, uid, move, context=None):
"""check if product associated to move has a phantom bom
return list of ids of mrp.bom for that product """
@@ -59,24 +60,28 @@ class StockMove(osv.osv):
('company_id', '=', user_company)]
return self.pool.get('mrp.bom').search(cr, SUPERUSER_ID, domain, context=context)
+
def _action_explode(self, cr, uid, move, context=None):
""" Explodes pickings.
@param move: Stock moves
@return: True
"""
+ if context is None:
+ context = {}
bom_obj = self.pool.get('mrp.bom')
move_obj = self.pool.get('stock.move')
prod_obj = self.pool.get("product.product")
proc_obj = self.pool.get("procurement.order")
uom_obj = self.pool.get("product.uom")
to_explode_again_ids = []
- processed_ids = []
- bis = self._check_phantom_bom(cr, uid, move, context=context)
- if bis:
- bom_point = bom_obj.browse(cr, SUPERUSER_ID, bis[0], context=context)
+ property_ids = context.get('property_ids') or []
+ bis = bom_obj._bom_find(cr, SUPERUSER_ID, product_id=move.product_id.id, properties=property_ids)
+ bom_point = bom_obj.browse(cr, SUPERUSER_ID, bis, context=context)
+ if bis and bom_point.type == 'phantom':
+ processed_ids = []
factor = uom_obj._compute_qty(cr, SUPERUSER_ID, move.product_uom.id, move.product_uom_qty, bom_point.product_uom.id) / bom_point.product_qty
- res = bom_obj._bom_explode(cr, SUPERUSER_ID, bom_point, move.product_id, factor, [], context=context)
-
+ res = bom_obj._bom_explode(cr, SUPERUSER_ID, bom_point, move.product_id, factor, property_ids, context=context)
+
for line in res[0]:
product = prod_obj.browse(cr, uid, line['product_id'], context=context)
if product.type != 'service':
@@ -115,7 +120,6 @@ class StockMove(osv.osv):
else:
proc = proc_obj.create(cr, uid, valdef, context=context)
proc_obj.run(cr, uid, [proc], context=context) #could be omitted
-
#check if new moves needs to be exploded
if to_explode_again_ids:
@@ -134,8 +138,10 @@ class StockMove(osv.osv):
#delete the move with original product which is not relevant anymore
move_obj.unlink(cr, SUPERUSER_ID, [move.id], context=context)
- #return list of newly created move or the move id otherwise, unless there is no move anymore
- return processed_ids or (not bis and [move.id]) or []
+ #return list of newly created move
+ return processed_ids
+
+ return [move.id]
def action_confirm(self, cr, uid, ids, context=None):
move_ids = []
diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py
index 86a50626558..d86c8e6cd63 100644
--- a/addons/mrp_operations/mrp_operations.py
+++ b/addons/mrp_operations/mrp_operations.py
@@ -337,7 +337,7 @@ class mrp_production(osv.osv):
for po in self.browse(cr, uid, ids, context=context):
direction[po.id] = cmp(po.date_start, vals.get('date_start', False))
result = super(mrp_production, self).write(cr, uid, ids, vals, context=context)
- if (vals.get('workcenter_lines', False) or vals.get('date_start', False)) and update:
+ if (vals.get('workcenter_lines', False) or vals.get('date_start', False) or vals.get('date_planned', False)) and update:
self._compute_planned_workcenter(cr, uid, ids, context=context, mini=mini)
for d in direction:
if direction[d] == 1:
diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py
index 74ba8806528..73380dcfda7 100644
--- a/addons/mrp_repair/mrp_repair.py
+++ b/addons/mrp_repair/mrp_repair.py
@@ -409,6 +409,7 @@ class mrp_repair(osv.osv):
'price_subtotal': fee.product_uom_qty * fee.price_unit
})
repair_fee_obj.write(cr, uid, [fee.id], {'invoiced': True, 'invoice_line_id': invoice_fee_id})
+ #inv_obj.button_reset_taxes(cr, uid, inv_id, context=context)
res[repair.id] = inv_id
return res
@@ -559,11 +560,16 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
@return: Dictionary of values.
"""
res = {}
- cur_obj = self.pool.get('res.currency')
+ tax_obj = self.pool.get('account.tax')
+ # cur_obj = self.pool.get('res.currency')
for line in self.browse(cr, uid, ids, context=context):
- res[line.id] = line.to_invoice and line.price_unit * line.product_uom_qty or 0
- cur = line.repair_id.pricelist_id.currency_id
- res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+ if line.to_invoice:
+ cur = line.repair_id.pricelist_id.currency_id
+ taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, cur.id, line.product_uom_qty, line.product_id, line.repair_id.partner_id)
+ #res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
+ res[line.id] = taxes['total_included']
+ else:
+ res[line.id] = 0
return res
_columns = {
@@ -650,11 +656,15 @@ class mrp_repair_fee(osv.osv, ProductChangeMixin):
@return: Dictionary of values.
"""
res = {}
+ tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
for line in self.browse(cr, uid, ids, context=context):
- res[line.id] = line.to_invoice and line.price_unit * line.product_uom_qty or 0
- cur = line.repair_id.pricelist_id.currency_id
- res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+ if line.to_invoice:
+ cur = line.repair_id.pricelist_id.currency_id
+ taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, cur.id, line.product_uom_qty, line.product_id, line.repair_id.partner_id)
+ res[line.id] = taxes['total_included']
+ else:
+ res[line.id] = 0
return res
_columns = {
diff --git a/addons/note/note.py b/addons/note/note.py
index 2db3173a907..fa69b96050e 100644
--- a/addons/note/note.py
+++ b/addons/note/note.py
@@ -168,7 +168,7 @@ class note_note(osv.osv):
return result
else:
- return super(note_note, self).read_group(self, cr, uid, domain, fields, groupby,
+ return super(note_note, self).read_group(cr, uid, domain, fields, groupby,
offset=offset, limit=limit, context=context, orderby=orderby,lazy=lazy)
diff --git a/addons/payment/models/res_config.py b/addons/payment/models/res_config.py
index b64b698c83d..888e0a89fda 100644
--- a/addons/payment/models/res_config.py
+++ b/addons/payment/models/res_config.py
@@ -19,7 +19,7 @@ class AccountPaymentConfig(osv.TransientModel):
'module_payment_buckaroo': fields.boolean(
'Manage Payments Using Buckaroo',
help='-It installs the module payment_buckaroo.'),
- 'module_payment_authorize': fields.boolean(
+ 'module_payment_authorize': fields.dummy(
'Manage Payments Using Authorize.Net',
help='-It installs the module payment_authorize.'),
}
diff --git a/addons/payment/views/res_config_view.xml b/addons/payment/views/res_config_view.xml
index 8f5e5f31321..e4e6fc96652 100644
--- a/addons/payment/views/res_config_view.xml
+++ b/addons/payment/views/res_config_view.xml
@@ -24,10 +24,6 @@