diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 92ea5f493f6..6c9b9a48409 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -290,7 +290,7 @@ class AccountMoveLine(models.Model):
if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_partner_id_ref_idx ON account_move_line (partner_id, ref)')
- @api.depends('debit', 'credit', 'amount_currency', 'currency_id', 'matched_debit_ids', 'matched_credit_ids', 'matched_debit_ids.amount', 'matched_credit_ids.amount', 'account_id.currency_id', 'move_id.state')
+ @api.depends('debit', 'credit', 'amount_currency', 'currency_id', 'matched_debit_ids', 'matched_credit_ids', 'matched_debit_ids.amount', 'matched_credit_ids.amount', 'move_id.state')
def _amount_residual(self):
""" Computes the residual amount of a move line from a reconciliable account in the company currency and the line's currency.
This amount will be 0 for fully reconciled lines or lines from a non-reconciliable account, the original line amount
diff --git a/addons/account/models/company.py b/addons/account/models/company.py
index 6aabee9118c..d3042f466a9 100644
--- a/addons/account/models/company.py
+++ b/addons/account/models/company.py
@@ -4,7 +4,7 @@ from datetime import timedelta, datetime
import calendar
from odoo import fields, models, api, _
-from odoo.exceptions import ValidationError
+from odoo.exceptions import ValidationError, UserError
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_round, float_is_zero
@@ -136,6 +136,12 @@ Best Regards,'''))
company.reflect_code_prefix_change(company.cash_account_code_prefix, new_cash_code, digits)
if values.get('accounts_code_digits'):
company.reflect_code_digits_change(digits)
+
+ #forbid the change of currency_id if there are already some accounting entries existing
+ if 'currency_id' in values and values['currency_id'] != company.currency_id.id:
+ if self.env['account.move.line'].search([('company_id', '=', company.id)]):
+ raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
+
return super(ResCompany, self).write(values)
@api.model
diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py
index 46a75581fc2..9855452e209 100644
--- a/addons/account/tests/test_payment.py
+++ b/addons/account/tests/test_payment.py
@@ -17,7 +17,9 @@ class TestPayment(AccountingTestCase):
self.currency_chf_id = self.env.ref("base.CHF").id
self.currency_usd_id = self.env.ref("base.USD").id
self.currency_eur_id = self.env.ref("base.EUR").id
- self.env.ref('base.main_company').write({'currency_id': self.currency_eur_id})
+
+ company = self.env.ref('base.main_company')
+ self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_eur_id, company.id])
self.product = self.env.ref("product.product_product_4")
self.payment_method_manual_in = self.env.ref("account.account_payment_method_manual_in")
self.payment_method_manual_out = self.env.ref("account.account_payment_method_manual_out")
diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py
index b91d4748954..bda31562874 100644
--- a/addons/account/tests/test_reconciliation.py
+++ b/addons/account/tests/test_reconciliation.py
@@ -25,7 +25,8 @@ class TestReconciliation(AccountingTestCase):
self.currency_swiss_id = self.env.ref("base.CHF").id
self.currency_usd_id = self.env.ref("base.USD").id
self.currency_euro_id = self.env.ref("base.EUR").id
- self.env.ref('base.main_company').write({'currency_id': self.currency_euro_id})
+ company = self.env.ref('base.main_company')
+ self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_euro_id, company.id])
self.account_rcv = partner_agrolait.property_account_receivable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1)
self.account_rsa = partner_agrolait.property_account_payable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1)
self.product = self.env.ref("product.product_product_4")
diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py
index 07afb0c079f..06655894e4d 100644
--- a/addons/crm/models/crm_lead.py
+++ b/addons/crm/models/crm_lead.py
@@ -968,6 +968,8 @@ class Lead(models.Model):
'nb_opportunities': 0,
}
+ today = fields.Date.from_string(fields.Date.context_today(self))
+
opportunities = self.search([('type', '=', 'opportunity'), ('user_id', '=', self._uid)])
for opp in opportunities:
@@ -975,28 +977,28 @@ class Lead(models.Model):
if opp.activity_date_deadline:
if opp.date_deadline:
date_deadline = fields.Date.from_string(opp.date_deadline)
- if date_deadline == date.today():
+ if date_deadline == today:
result['closing']['today'] += 1
- if date.today() <= date_deadline <= date.today() + timedelta(days=7):
+ if today <= date_deadline <= today + timedelta(days=7):
result['closing']['next_7_days'] += 1
- if date_deadline < date.today() and not opp.date_closed:
+ if date_deadline < today and not opp.date_closed:
result['closing']['overdue'] += 1
# Next activities
for activity in opp.activity_ids:
date_deadline = fields.Date.from_string(activity.date_deadline)
- if date_deadline == date.today():
+ if date_deadline == today:
result['activity']['today'] += 1
- if date.today() <= date_deadline <= date.today() + timedelta(days=7):
+ if today <= date_deadline <= today + timedelta(days=7):
result['activity']['next_7_days'] += 1
- if date_deadline < date.today():
+ if date_deadline < today:
result['activity']['overdue'] += 1
# Won in Opportunities
if opp.date_closed and opp.stage_id.probability == 100:
date_closed = fields.Date.from_string(opp.date_closed)
- if date.today().replace(day=1) <= date_closed <= date.today():
+ if today.replace(day=1) <= date_closed <= today:
if opp.planned_revenue:
result['won']['this_month'] += opp.planned_revenue
- elif date.today() + relativedelta(months=-1, day=1) <= date_closed < date.today().replace(day=1):
+ elif today + relativedelta(months=-1, day=1) <= date_closed < today.replace(day=1):
if opp.planned_revenue:
result['won']['last_month'] += opp.planned_revenue
@@ -1021,9 +1023,9 @@ class Lead(models.Model):
for activity in activites_done:
if activity['date']:
date_act = fields.Date.from_string(activity['date'])
- if date.today().replace(day=1) <= date_act <= date.today():
+ if today.replace(day=1) <= date_act <= today:
result['done']['this_month'] += 1
- elif date.today() + relativedelta(months=-1, day=1) <= date_act < date.today().replace(day=1):
+ elif today + relativedelta(months=-1, day=1) <= date_act < today.replace(day=1):
result['done']['last_month'] += 1
# Meetings
@@ -1038,9 +1040,9 @@ class Lead(models.Model):
for meeting in meetings:
if meeting['start']:
start = datetime.strptime(meeting['start'], tools.DEFAULT_SERVER_DATETIME_FORMAT).date()
- if start == date.today():
+ if start == today:
result['meeting']['today'] += 1
- if date.today() <= start <= date.today() + timedelta(days=7):
+ if today <= start <= today + timedelta(days=7):
result['meeting']['next_7_days'] += 1
result['done']['target'] = self.env.user.target_sales_done
diff --git a/addons/delivery/models/__init__.py b/addons/delivery/models/__init__.py
index 5229017a189..9e162e76592 100644
--- a/addons/delivery/models/__init__.py
+++ b/addons/delivery/models/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from . import res_config_settings
from . import delivery_carrier
from . import delivery_grid
from . import product_template
diff --git a/addons/delivery/models/res_config_settings.py b/addons/delivery/models/res_config_settings.py
new file mode 100644
index 00000000000..070f8dcdb29
--- /dev/null
+++ b/addons/delivery/models/res_config_settings.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+class ResConfigSettings(models.TransientModel):
+ _inherit = 'res.config.settings'
+
+ def set_values(self):
+ super(ResConfigSettings, self).set_values()
+ rule = self.env.ref('delivery.delivery_carrier_comp_rule', False)
+ if rule:
+ rule.write({'active': not bool(self.company_share_product)})
diff --git a/addons/delivery/security/delivery_carrier_security.xml b/addons/delivery/security/delivery_carrier_security.xml
index 8fad0891676..db718fbf361 100644
--- a/addons/delivery/security/delivery_carrier_security.xml
+++ b/addons/delivery/security/delivery_carrier_security.xml
@@ -6,6 +6,7 @@
Attached files :
'), - 'model': model.model, + 'model': model_name, 'message_type': 'comment', 'no_auto_thread': False, 'res_id': id_record, diff --git a/addons/website_sale_delivery/models/res_country.py b/addons/website_sale_delivery/models/res_country.py index 8b4648a7105..601ac731787 100644 --- a/addons/website_sale_delivery/models/res_country.py +++ b/addons/website_sale_delivery/models/res_country.py @@ -35,5 +35,7 @@ class ResCountry(models.Model): states = res break states |= carrier.state_ids + if not states: + states = states.search([('country_id', '=', self.id)]) res = res & states return res diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index b9d4aa2d757..764d8acfa6a 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -348,7 +348,7 @@ class Slide(models.Model): base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') for record in self: if record.datas and (not record.document_id or record.slide_type in ['document', 'presentation']): - record.embed_code = '' % (base_url, record.id, 315, 420) + record.embed_code = '' % (base_url, record.id, 315, 420) elif record.slide_type == 'video' and record.document_id: if not record.mime_type: # embed youtube video diff --git a/addons/website_slides/static/src/js/slides.js b/addons/website_slides/static/src/js/slides.js index 279c256c5ac..a3b578a3e48 100644 --- a/addons/website_slides/static/src/js/slides.js +++ b/addons/website_slides/static/src/js/slides.js @@ -109,11 +109,12 @@ var page_widgets = {}; }, }); - $('iframe').ready(function() { + $('iframe.o_wslides_iframe_viewer').ready(function() { // TODO : make it work. For now, once the iframe is loaded, the value of #page_count is // still now set (the pdf is still loading) - var max_page = $('iframe').contents().find('#page_count').val(); - new SlideSocialEmbed($(this), max_page).setElement($('.oe_slide_js_embed_code_widget')); + var $iframe = $(this); + var max_page = $iframe.contents().find('#page_count').val(); + new SlideSocialEmbed($iframe, max_page).setElement($('.oe_slide_js_embed_code_widget')); }); diff --git a/doc/cla/corporate/odoogap.md b/doc/cla/corporate/odoogap.md new file mode 100644 index 00000000000..08a10ddd683 --- /dev/null +++ b/doc/cla/corporate/odoogap.md @@ -0,0 +1,18 @@ +PromptEQUATION, 2017-09-03 + +PromptEquation/ OdooGap agrees to the terms of the Odoo Corporate Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Diogo Duarte dduarte@odoogap.com https://github.com/dduarte-odoogap + +List of contributors: + +Diogo Duarte dduarte@odoogap.com https://github.com/dduarte-odoogap +Diogo Duarte diogocarvalhoduarte@gmail.com https://github.com/dduarte-odoogap +Carlos Fonseca cfonseca@odoogap.com https://github.com/cfonseca-odoogap +Carlos Fonseca carlosmigueldafonseca@gmail.com https://github.com/cpintofonseca diff --git a/doc/cla/individual/hilarak.md b/doc/cla/individual/hilarak.md new file mode 100644 index 00000000000..4e164fe88d1 --- /dev/null +++ b/doc/cla/individual/hilarak.md @@ -0,0 +1,11 @@ +India, 18-02-2018 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Hilar AK hilarak@gmail.com https://github.com/hilarak diff --git a/doc/cla/individual/lbelorgey.md b/doc/cla/individual/lbelorgey.md index 6cdacb5cdf1..c8db490ec4d 100644 --- a/doc/cla/individual/lbelorgey.md +++ b/doc/cla/individual/lbelorgey.md @@ -8,4 +8,4 @@ declaration. Signed, -Laurent Bélorgey lb@lalieutenante.com https://github.com/lbelorgey \ No newline at end of file +Laurent BĂ©lorgey lb@lalieutenante.com https://github.com/lbelorgey \ No newline at end of file diff --git a/odoo/addons/base/ir/ir_autovacuum.py b/odoo/addons/base/ir/ir_autovacuum.py index 804f7bc827d..8ffdb0b1b3e 100644 --- a/odoo/addons/base/ir/ir_autovacuum.py +++ b/odoo/addons/base/ir/ir_autovacuum.py @@ -17,7 +17,11 @@ class AutoVacuum(models.AbstractModel): for mname in self.env: model = self.env[mname] if model.is_transient(): - model._transient_vacuum(force=True) + try: + with self._cr.savepoint(): + model._transient_vacuum(force=True) + except Exception as e: + _logger.warning("Failed to clean transient model %s\n%s", model, str(e)) @api.model def _gc_user_logs(self):