diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py
index 47a92e018b5..dd054e0fc21 100644
--- a/addons/mail/controllers/main.py
+++ b/addons/mail/controllers/main.py
@@ -89,6 +89,13 @@ class MailController(http.Controller):
return cls._redirect_to_messaging()
if record_action['type'] == 'ir.actions.act_url':
return werkzeug.utils.redirect(record_action['url'])
+ else:
+ # Specific case in 10.0 only: not logged users could receive an act_url that is
+ # not public. As we don't handle fully access tokens in 10.0 we have to redirect
+ # to the login to avoid access issues and/or crash when computing url_params.
+ # CHS-note: do not forward-port me as in saas-16 it is already managed
+ if record_action['type'] == 'ir.actions.act_url':
+ return cls._redirect_to_messaging()
url_params = {
'view_type': record_action['view_type'],
diff --git a/addons/mass_mailing/static/src/js/mass_mailing_editor.js b/addons/mass_mailing/static/src/js/mass_mailing_editor.js
index 70a50131706..da51c1d322d 100644
--- a/addons/mass_mailing/static/src/js/mass_mailing_editor.js
+++ b/addons/mass_mailing/static/src/js/mass_mailing_editor.js
@@ -87,11 +87,11 @@ options.registry["width-x"] = options.Class.extend({
});
options.registry.table_item = options.Class.extend({
- on_clone: function ($clone) {
+ on_clone: function ($clone, options) {
this._super.apply(this, arguments);
// If we cloned a td or th element...
- if (this.$target.is("td, th")) {
+ if (options.isCurrent && this.$target.is("td, th")) {
// ... and that the td or th element was alone on its row ...
if (this.$target.siblings().length === 1) {
var $tr = $clone.parent();
diff --git a/addons/mass_mailing/static/src/less/themes/theme_default.less b/addons/mass_mailing/static/src/less/themes/theme_default.less
index adfa4bba5ce..3bde380c89d 100644
--- a/addons/mass_mailing/static/src/less/themes/theme_default.less
+++ b/addons/mass_mailing/static/src/less/themes/theme_default.less
@@ -46,6 +46,11 @@
background-color: @o_mm_def_color_alpha;
}
+td {
+ // Default browser style but needed so that alignment works on some mail
+ // clients (see transcoder)
+ text-align: inherit;
+}
// ===== Layout =====
.o_layout {
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index 69b095cd0f7..6f640d6c695 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -312,20 +312,24 @@ class MrpWorkorder(models.Model):
# If last work order, then post lots used
# TODO: should be same as checking if for every workorder something has been done?
if not self.next_work_order_id:
- production_move = self.production_id.move_finished_ids.filtered(lambda x: (x.product_id.id == self.production_id.product_id.id) and (x.state not in ('done', 'cancel')))
- if production_move.product_id.tracking != 'none':
- move_lot = production_move.move_lot_ids.filtered(lambda x: x.lot_id.id == self.final_lot_id.id)
- if move_lot:
- move_lot.quantity += self.qty_producing
+ production_moves = self.production_id.move_finished_ids.filtered(lambda x: (x.state not in ('done', 'cancel')))
+ for production_move in production_moves:
+ if production_move.product_id.id == self.production_id.product_id.id and production_move.product_id.tracking != 'none':
+ move_lot = production_move.move_lot_ids.filtered(lambda x: x.lot_id.id == self.final_lot_id.id)
+ if move_lot:
+ move_lot.quantity += self.qty_producing
+ else:
+ move_lot.create({'move_id': production_move.id,
+ 'lot_id': self.final_lot_id.id,
+ 'quantity': self.qty_producing,
+ 'quantity_done': self.qty_producing,
+ 'workorder_id': self.id,
+ })
+ elif production_move.unit_factor:
+ rounding = production_move.product_uom.rounding
+ production_move.quantity_done += float_round(self.qty_producing * production_move.unit_factor, precision_rounding=rounding)
else:
- move_lot.create({'move_id': production_move.id,
- 'lot_id': self.final_lot_id.id,
- 'quantity': self.qty_producing,
- 'quantity_done': self.qty_producing,
- 'workorder_id': self.id,
- })
- else:
- production_move.quantity_done += self.qty_producing # TODO: UoM conversion?
+ production_move.quantity_done += self.qty_producing # TODO: UoM conversion?
# Update workorder quantity produced
self.qty_produced += self.qty_producing
diff --git a/addons/point_of_sale/__init__.py b/addons/point_of_sale/__init__.py
index ff29fd64226..3a8c2063f5d 100644
--- a/addons/point_of_sale/__init__.py
+++ b/addons/point_of_sale/__init__.py
@@ -5,3 +5,4 @@ import models
import controllers
import report
import wizard
+import tests
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py
index 036f9cefd7e..8bb5dcf8f97 100644
--- a/addons/point_of_sale/models/pos_order.py
+++ b/addons/point_of_sale/models/pos_order.py
@@ -215,6 +215,41 @@ class PosOrder(models.Model):
have_to_group_by = session and session.config_id.group_by or False
rounding_method = session and session.config_id.company_id.tax_calculation_rounding_method
+ def add_anglosaxon_lines(grouped_data):
+ Product = self.env['product.product']
+ Analytic = self.env['account.analytic.account']
+ for product_key in list(grouped_data.keys()):
+ if product_key[0] == "product":
+ line = grouped_data[product_key][0]
+ product = Product.browse(line['product_id'])
+ # In the SO part, the entries will be inverted by function compute_invoice_totals
+ price_unit = - product._get_anglo_saxon_price_unit()
+ account_analytic = Analytic.browse(line.get('analytic_account_id'))
+ res = Product._anglo_saxon_sale_move_lines(
+ line['name'], product, product.uom_id, line['quantity'], price_unit,
+ fiscal_position=order.fiscal_position_id,
+ account_analytic=account_analytic)
+ if res:
+ line1, line2 = res
+ line1 = Product._convert_prepared_anglosaxon_line(line1, order.partner_id)
+ insert_data('counter_part', {
+ 'name': line1['name'],
+ 'account_id': line1['account_id'],
+ 'credit': line1['credit'] or 0.0,
+ 'debit': line1['debit'] or 0.0,
+ 'partner_id': line1['partner_id']
+
+ })
+
+ line2 = Product._convert_prepared_anglosaxon_line(line2, order.partner_id)
+ insert_data('counter_part', {
+ 'name': line2['name'],
+ 'account_id': line2['account_id'],
+ 'credit': line2['credit'] or 0.0,
+ 'debit': line2['debit'] or 0.0,
+ 'partner_id': line2['partner_id']
+ })
+
for order in self.filtered(lambda o: not o.account_move or o.state == 'paid'):
current_company = order.sale_journal.company_id
account_def = IrProperty.get(
@@ -335,6 +370,9 @@ class PosOrder(models.Model):
order.write({'state': 'done', 'account_move': move.id})
+ if self and order.company_id.anglo_saxon_accounting:
+ add_anglosaxon_lines(grouped_data)
+
all_lines = []
for group_key, group_data in grouped_data.iteritems():
for value in group_data:
diff --git a/addons/point_of_sale/tests/__init__.py b/addons/point_of_sale/tests/__init__.py
index 2e1ff183381..3168adf78ef 100644
--- a/addons/point_of_sale/tests/__init__.py
+++ b/addons/point_of_sale/tests/__init__.py
@@ -4,3 +4,4 @@
import test_point_of_sale_flow
import test_frontend
import test_point_of_sale_ui
+import test_anglo_saxon
diff --git a/addons/point_of_sale/tests/test_anglo_saxon.py b/addons/point_of_sale/tests/test_anglo_saxon.py
new file mode 100644
index 00000000000..b6d27af9505
--- /dev/null
+++ b/addons/point_of_sale/tests/test_anglo_saxon.py
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+
+import openerp
+import time
+from openerp import fields
+
+from openerp.tests import common
+
+
+class TestAngloSaxonCommon(common.TransactionCase):
+
+ def setUp(self):
+ super(TestAngloSaxonCommon, self).setUp()
+ self.PosMakePayment = self.env['pos.make.payment']
+ self.PosOrder = self.env['pos.order']
+ self.Statement = self.env['account.bank.statement']
+ self.company = self.env.ref('base.main_company')
+ self.product = self.env.ref('product.product_product_3')
+ self.partner = self.env.ref('base.res_partner_1')
+ self.category = self.env.ref('product.product_category_1')
+ self.category = self.category.copy({'name': 'New category','property_valuation': 'real_time'})
+ account_type_rcv = self.env['account.account.type'].create({'name': 'RCV type', 'type': 'receivable'})
+ account_type_oth = self.env['account.account.type'].create({'name': 'RCV type', 'type': 'other'})
+ self.account = self.env['account.account'].create({'name': 'Receivable', 'code': 'RCV00' , 'user_type_id': account_type_rcv.id, 'reconcile': True})
+ account_expense = self.env['account.account'].create({'name': 'Expense', 'code': 'EXP00' , 'user_type_id': account_type_oth.id, 'reconcile': True})
+ account_output = self.env['account.account'].create({'name': 'Output', 'code': 'OUT00' , 'user_type_id': account_type_oth.id, 'reconcile': True})
+ self.partner.property_account_receivable_id = self.account
+ self.category.property_account_income_categ_id = self.account
+ self.category.property_account_expense_categ_id = account_expense
+ self.category.property_stock_account_input_categ_id = self.account
+ self.category.property_stock_account_output_categ_id = account_output
+ self.category.property_stock_valuation_account_id = self.account
+ self.category.property_stock_journal = self.env['account.journal'].create({'name': 'Stock journal', 'type': 'sale', 'code': 'STK00'})
+ self.pos_config = self.env.ref('point_of_sale.pos_config_main')
+ self.pos_config = self.pos_config.copy({'name': 'New POS config'})
+ self.product = self.product.copy({'name': 'New product','standard_price': 100})
+ self.company.anglo_saxon_accounting = True
+ self.product.categ_id = self.category
+ sale_journal = self.env['account.journal'].create({'name': 'POS journal', 'type': 'sale', 'code': 'POS00'})
+ self.pos_config.journal_id = sale_journal
+ self.cash_journal = self.env['account.journal'].create({'name': 'CASH journal', 'type': 'cash', 'code': 'CSH00'})
+
+
+class TestAngloSaxonFlow(TestAngloSaxonCommon):
+
+ def test_create_account_move_line(self):
+ # This test will check that the correct journal entries are created when a product in real time valuation
+ # is sold in a company using anglo-saxon
+ self.pos_config.open_session_cb()
+ self.pos_config.current_session_id.write({'journal_ids': [(6, 0, [self.cash_journal.id])]})
+ self.cash_journal.loss_account_id = self.account
+ self.pos_statement = self.Statement.create({
+ 'balance_start': 0.0,
+ 'balance_end_real': 0.0,
+ 'date': time.strftime('%Y-%m-%d'),
+ 'journal_id': self.cash_journal.id,
+ 'company_id': self.company.id,
+ 'name': 'pos session test',
+ })
+ self.pos_config.current_session_id.write({'statement_ids': [(6, 0, [self.pos_statement.id])]})
+
+ # I create a PoS order with 1 unit of New product at 450 EUR
+ self.pos_order_pos0 = self.PosOrder.create({
+ 'company_id': self.company.id,
+ 'partner_id': self.partner.id,
+ 'pricelist_id': self.company.partner_id.property_product_pricelist.id,
+ 'session_id': self.pos_config.current_session_id.id,
+ 'lines': [(0, 0, {
+ 'name': "OL/0001",
+ 'product_id': self.product.id,
+ 'price_unit': 450,
+ 'discount': 0.0,
+ 'qty': 1.0
+ })]
+ })
+
+ # I make a payment to fully pay the order
+ context_make_payment = {"active_ids": [self.pos_order_pos0.id], "active_id": self.pos_order_pos0.id}
+ self.pos_make_payment_0 = self.PosMakePayment.with_context(context_make_payment).create({
+ 'amount': 450.0,
+ 'journal_id': self.cash_journal.id,
+ })
+
+ # I click on the validate button to register the payment.
+ context_payment = {'active_id': self.pos_order_pos0.id}
+ self.pos_make_payment_0.with_context(context_payment).check()
+
+ # I check that the order is marked as paid
+ self.assertEqual(self.pos_order_pos0.state, 'paid', 'Order should be in paid state.')
+
+ # I close the current session to generate the journal entries
+ self.pos_config.current_session_id.action_pos_session_close()
+
+ # I test that the generated journal entries are correct.
+ account_output = self.category.property_stock_account_output_categ_id
+ expense_account = self.category.property_account_expense_categ_id
+ aml = self.pos_order_pos0.account_move.line_ids
+ aml_output = aml.filtered(lambda l: l.account_id.id == account_output.id)
+ aml_expense = aml.filtered(lambda l: l.account_id.id == expense_account.id)
+ self.assertEqual(aml_output.credit, self.product.standard_price, "Cost of Good Sold entry missing or mismatching")
+ self.assertEqual(aml_expense.debit, self.product.standard_price, "Cost of Good Sold entry missing or mismatching")
\ No newline at end of file
diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py
index 492223df2fe..1064e925930 100644
--- a/addons/product/models/product_template.py
+++ b/addons/product/models/product_template.py
@@ -397,7 +397,7 @@ class ProductTemplate(models.Model):
for tmpl_id in self.with_context(active_test=False):
# adding an attribute with only one value should not recreate product
# write this attribute on every product to make sure we don't lose them
- variant_alone = tmpl_id.attribute_line_ids.filtered(lambda line: len(line.value_ids) == 1).mapped('value_ids')
+ variant_alone = tmpl_id.attribute_line_ids.filtered(lambda line: line.attribute_id.create_variant and len(line.value_ids) == 1).mapped('value_ids')
for value_id in variant_alone:
updated_products = tmpl_id.product_variant_ids.filtered(lambda product: value_id.attribute_id not in product.mapped('attribute_value_ids.attribute_id'))
updated_products.write({'attribute_value_ids': [(4, value_id.id)]})
diff --git a/addons/product/tests/test_variants.py b/addons/product/tests/test_variants.py
index 813f5f9e28d..1a621d689cb 100644
--- a/addons/product/tests/test_variants.py
+++ b/addons/product/tests/test_variants.py
@@ -4,10 +4,10 @@
from . import common
from odoo.tests.common import TransactionCase
-class TestVariants(TransactionCase):
+class TestVariantsSearch(TransactionCase):
def setUp(self):
- res = super(TestVariants, self).setUp()
+ res = super(TestVariantsSearch, self).setUp()
self.size_attr = self.env['product.attribute'].create({'name': 'Size'})
self.size_attr_value_s = self.env['product.attribute.value'].create({'name': 'S', 'attribute_id': self.size_attr.id})
self.size_attr_value_m = self.env['product.attribute.value'].create({'name': 'M', 'attribute_id': self.size_attr.id})
@@ -152,3 +152,181 @@ class TestVariants(common.TestProductCommon):
'value_ids': [(4, self.size_attr_value_l.id)],
})]
})
+
+
+class TestVariantsNoCreate(common.TestProductCommon):
+
+ def setUp(self):
+ super(TestVariantsNoCreate, self).setUp()
+ self.size = self.env['product.attribute'].create({
+ 'name': 'Size',
+ 'create_variant': False,
+ 'value_ids': [(0, 0, {'name': 'S'}), (0, 0, {'name': 'M'}), (0, 0, {'name': 'L'})],
+ })
+ self.size_S = self.size.value_ids[0]
+ self.size_M = self.size.value_ids[1]
+ self.size_L = self.size.value_ids[2]
+
+ def test_create_mono(self):
+ """ create a product with a 'nocreate' attribute with a single value """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ 'attribute_line_ids': [(0, 0, {
+ 'attribute_id': self.size.id,
+ 'value_ids': [(4, self.size_S.id)],
+ })],
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+ self.assertFalse(template.product_variant_ids.attribute_value_ids)
+
+ def test_update_mono(self):
+ """ modify a product with a 'nocreate' attribute with a single value """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+
+ template.write({
+ 'attribute_line_ids': [(0, 0, {
+ 'attribute_id': self.size.id,
+ 'value_ids': [(4, self.size_S.id)],
+ })],
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+ self.assertFalse(template.product_variant_ids.attribute_value_ids)
+
+ def test_create_multi(self):
+ """ create a product with a 'nocreate' attribute with several values """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ 'attribute_line_ids': [(0, 0, {
+ 'attribute_id': self.size.id,
+ 'value_ids': [(6, 0, self.size.value_ids.ids)],
+ })],
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+ self.assertFalse(template.product_variant_ids.attribute_value_ids)
+
+ def test_update_multi(self):
+ """ modify a product with a 'nocreate' attribute with several values """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+
+ template.write({
+ 'attribute_line_ids': [(0, 0, {
+ 'attribute_id': self.size.id,
+ 'value_ids': [(6, 0, self.size.value_ids.ids)],
+ })],
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+ self.assertFalse(template.product_variant_ids.attribute_value_ids)
+
+ def test_create_mixed_mono(self):
+ """ create a product with regular and 'nocreate' attributes """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ 'attribute_line_ids': [
+ (0, 0, { # no variants for this one
+ 'attribute_id': self.size.id,
+ 'value_ids': [(4, self.size_S.id)],
+ }),
+ (0, 0, { # two variants for this one
+ 'attribute_id': self.prod_att_1.id,
+ 'value_ids': [(4, self.prod_attr1_v1.id), (4, self.prod_attr1_v2.id)],
+ }),
+ ],
+ })
+ self.assertEqual(len(template.product_variant_ids), 2)
+ self.assertEqual(
+ {variant.attribute_value_ids for variant in template.product_variant_ids},
+ {self.prod_attr1_v1, self.prod_attr1_v2},
+ )
+
+ def test_update_mixed_mono(self):
+ """ modify a product with regular and 'nocreate' attributes """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+
+ template.write({
+ 'attribute_line_ids': [
+ (0, 0, { # no variants for this one
+ 'attribute_id': self.size.id,
+ 'value_ids': [(4, self.size_S.id)],
+ }),
+ (0, 0, { # two variants for this one
+ 'attribute_id': self.prod_att_1.id,
+ 'value_ids': [(4, self.prod_attr1_v1.id), (4, self.prod_attr1_v2.id)],
+ }),
+ ],
+ })
+ self.assertEqual(len(template.product_variant_ids), 2)
+ self.assertEqual(
+ {variant.attribute_value_ids for variant in template.product_variant_ids},
+ {self.prod_attr1_v1, self.prod_attr1_v2},
+ )
+
+ def test_create_mixed_multi(self):
+ """ create a product with regular and 'nocreate' attributes """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ 'attribute_line_ids': [
+ (0, 0, { # no variants for this one
+ 'attribute_id': self.size.id,
+ 'value_ids': [(6, 0, self.size.value_ids.ids)],
+ }),
+ (0, 0, { # two variants for this one
+ 'attribute_id': self.prod_att_1.id,
+ 'value_ids': [(4, self.prod_attr1_v1.id), (4, self.prod_attr1_v2.id)],
+ }),
+ ],
+ })
+ self.assertEqual(len(template.product_variant_ids), 2)
+ self.assertEqual(
+ {variant.attribute_value_ids for variant in template.product_variant_ids},
+ {self.prod_attr1_v1, self.prod_attr1_v2},
+ )
+
+ def test_update_mixed_multi(self):
+ """ modify a product with regular and 'nocreate' attributes """
+ template = self.env['product.template'].create({
+ 'name': 'Sofa',
+ 'uom_id': self.uom_unit.id,
+ 'uom_po_id': self.uom_unit.id,
+ })
+ self.assertEqual(len(template.product_variant_ids), 1)
+
+ template.write({
+ 'attribute_line_ids': [
+ (0, 0, { # no variants for this one
+ 'attribute_id': self.size.id,
+ 'value_ids': [(6, 0, self.size.value_ids.ids)],
+ }),
+ (0, 0, { # two variants for this one
+ 'attribute_id': self.prod_att_1.id,
+ 'value_ids': [(4, self.prod_attr1_v1.id), (4, self.prod_attr1_v2.id)],
+ }),
+ ],
+ })
+ self.assertEqual(len(template.product_variant_ids), 2)
+ self.assertEqual(
+ {variant.attribute_value_ids for variant in template.product_variant_ids},
+ {self.prod_attr1_v1, self.prod_attr1_v2},
+ )
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py
index f2f2efd184b..ef34741a753 100644
--- a/addons/stock/models/stock_inventory.py
+++ b/addons/stock/models/stock_inventory.py
@@ -378,6 +378,7 @@ class InventoryLine(models.Model):
def write(self, values):
values.pop('product_name', False)
res = super(InventoryLine, self).write(values)
+ return res
@api.model
def create(self, values):
diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py
index 5932f9558af..b427acbd748 100644
--- a/addons/stock/models/stock_quant.py
+++ b/addons/stock/models/stock_quant.py
@@ -591,7 +591,7 @@ class QuantPackage(models.Model):
@api.one
@api.depends('parent_id', 'children_ids')
def _compute_ancestor_ids(self):
- self.ancestor_ids = self.env['stock.quant.package'].search(['id', 'parent_of', self.id]).ids
+ self.ancestor_ids = self.env['stock.quant.package'].search([('id', 'parent_of', self.id)]).ids
@api.multi
@api.depends('parent_id', 'children_ids', 'quant_ids.package_id')
diff --git a/addons/stock_account/models/account_invoice.py b/addons/stock_account/models/account_invoice.py
index 6291da2922f..9b239453e61 100644
--- a/addons/stock_account/models/account_invoice.py
+++ b/addons/stock_account/models/account_invoice.py
@@ -28,54 +28,15 @@ class AccountInvoice(models.Model):
"""
inv = i_line.invoice_id
company_currency = inv.company_id.currency_id
+ price_unit = i_line._get_anglo_saxon_price_unit()
+ if inv.currency_id != company_currency:
+ currency_id = inv.currency_id.id
+ amount_currency = i_line._get_price(company_currency, price_unit)
+ else:
+ currency_id = False
+ amount_currency = False
- if i_line.product_id.type == 'product' and i_line.product_id.valuation == 'real_time':
- fpos = i_line.invoice_id.fiscal_position_id
- accounts = i_line.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=fpos)
- # debit account dacc will be the output account
- dacc = accounts['stock_output'].id
- # credit account cacc will be the expense account
- cacc = accounts['expense'].id
- if dacc and cacc:
- price_unit = i_line._get_anglo_saxon_price_unit()
- if inv.currency_id != company_currency:
- currency_id = inv.currency_id.id
- amount_currency = i_line._get_price(company_currency, price_unit)
- else:
- currency_id = False
- amount_currency = False
- return [
- {
- 'type': 'src',
- 'name': i_line.name[:64],
- 'price_unit': price_unit,
- 'quantity': i_line.quantity,
- 'price': price_unit * i_line.quantity,
- 'currency_id': currency_id,
- 'amount_currency': amount_currency,
- 'account_id':dacc,
- 'product_id':i_line.product_id.id,
- 'uom_id':i_line.uom_id.id,
- 'account_analytic_id': i_line.account_analytic_id.id,
- 'analytic_tag_ids': i_line.analytic_tag_ids.ids and [(6, 0, i_line.analytic_tag_ids.ids)] or False,
- },
-
- {
- 'type': 'src',
- 'name': i_line.name[:64],
- 'price_unit': price_unit,
- 'quantity': i_line.quantity,
- 'price': -1 * price_unit * i_line.quantity,
- 'currency_id': currency_id,
- 'amount_currency': -1 * amount_currency,
- 'account_id':cacc,
- 'product_id':i_line.product_id.id,
- 'uom_id':i_line.uom_id.id,
- 'account_analytic_id': i_line.account_analytic_id.id,
- 'analytic_tag_ids': i_line.analytic_tag_ids.ids and [(6, 0, i_line.analytic_tag_ids.ids)] or False,
- },
- ]
- return []
+ return self.env['product.product']._anglo_saxon_sale_move_lines(i_line.name, i_line.product_id, i_line.uom_id, i_line.quantity, price_unit, currency=currency_id, amount_currency=amount_currency, fiscal_position=inv.fiscal_position_id, account_analytic=i_line.account_analytic_id, analytic_tags=i_line.analytic_tag_ids)
class AccountInvoiceLine(models.Model):
@@ -83,11 +44,7 @@ class AccountInvoiceLine(models.Model):
def _get_anglo_saxon_price_unit(self):
self.ensure_one()
- price = self.product_id.standard_price
- if not self.uom_id or self.product_id.uom_id == self.uom_id:
- return price
- else:
- return self.product_id.uom_id._compute_price(price, self.uom_id)
+ return self.product_id._get_anglo_saxon_price_unit(uom=self.uom_id)
def _get_price(self, company_currency, price_unit):
if self.invoice_id.currency_id.id != company_currency.id:
diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py
index 751d182d30d..126bc59960a 100644
--- a/addons/stock_account/models/product.py
+++ b/addons/stock_account/models/product.py
@@ -141,6 +141,70 @@ class ProductProduct(models.Model):
self.write({'standard_price': new_price})
return True
+ @api.model
+ def _anglo_saxon_sale_move_lines(self, name, product, uom, qty, price_unit, currency=False, amount_currency=False, fiscal_position=False, account_analytic=False, analytic_tags=False):
+ """Prepare dicts describing new journal COGS journal items for a product sale.
+
+ Returns a dict that should be passed to `_convert_prepared_anglosaxon_line()` to
+ obtain the creation value for the new journal items.
+
+ :param Model product: a product.product record of the product being sold
+ :param Model uom: a product.uom record of the UoM of the sale line
+ :param Integer qty: quantity of the product being sold
+ :param Integer price_unit: unit price of the product being sold
+ :param Model currency: a res.currency record from the order of the product being sold
+ :param Interger amount_currency: unit price in the currency from the order of the product being sold
+ :param Model fiscal_position: a account.fiscal.position record from the order of the product being sold
+ :param Model account_analytic: a account.account.analytic record from the line of the product being sold
+ """
+
+ if product.type == 'product' and product.valuation == 'real_time':
+ accounts = product.product_tmpl_id.get_product_accounts(fiscal_pos=fiscal_position)
+ # debit account dacc will be the output account
+ dacc = accounts['stock_output'].id
+ # credit account cacc will be the expense account
+ cacc = accounts['expense'].id
+ if dacc and cacc:
+ return [
+ {
+ 'type': 'src',
+ 'name': name[:64],
+ 'price_unit': price_unit,
+ 'quantity': qty,
+ 'price': price_unit * qty,
+ 'currency_id': currency and currency.id,
+ 'amount_currency': amount_currency,
+ 'account_id': dacc,
+ 'product_id': product.id,
+ 'uom_id': uom.id,
+ 'account_analytic_id': account_analytic and account_analytic.id,
+ 'analytic_tag_ids': analytic_tags and analytic_tag.ids and [(6, 0, analytic_tag.ids)] or False,
+ },
+
+ {
+ 'type': 'src',
+ 'name': name[:64],
+ 'price_unit': price_unit,
+ 'quantity': qty,
+ 'price': -1 * price_unit * qty,
+ 'currency_id': currency and currency.id,
+ 'amount_currency': -1 * amount_currency,
+ 'account_id': cacc,
+ 'product_id': product.id,
+ 'uom_id': uom.id,
+ 'account_analytic_id': account_analytic and account_analytic.id,
+ 'analytic_tag_ids': analytic_tags and analytic_tags.ids and [(6, 0, analytic_tags.ids)] or False,
+ },
+ ]
+ return []
+
+ @api.model
+ def _get_anglo_saxon_price_unit(self, uom=False):
+ price = self.standard_price
+ if not uom or self.uom_id.id == uom.id:
+ return price
+ return self.uom_id._compute_price(self.uom_id.id, price, to_uom_id=uom.id)
+
class ProductCategory(models.Model):
_inherit = 'product.category'
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index e5d184117f4..f68bf8756bb 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -1010,7 +1010,9 @@ data.Editor = Class.extend({
this.$target.after($clone);
this.buildingBlock.call_for_all_snippets($clone, function (editor, $snippet) {
for (var i in editor.styles) {
- editor.styles[i].on_clone($snippet);
+ editor.styles[i].on_clone($snippet, {
+ isCurrent: ($snippet.is($clone)),
+ });
}
});
return false;
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index 265ca5ab3f0..a5cf20575d4 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -9,17 +9,12 @@ var getMatchedCSSRules = function (a) {
var sheets = document.styleSheets;
for(var i = sheets.length-1; i >= 0 ; i--) {
var rules;
- if (sheets[i].hasOwnProperty('rules')) {
- rules = sheets[i].rules;
- } else {
- //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
- try {
- rules = sheets[i].cssRules;
- } catch(e) {
- console.warn("Can't read the css rules of: " + sheets[i].href, e);
- continue;
- }
- rules = sheets[i].cssRules;
+ // try...catch because browser may not able to enumerate rules for cross-domain sheets
+ try {
+ rules = sheets[i].rules || sheets[i].cssRules;
+ } catch (e) {
+ console.warn("Can't read the css rules of: " + sheets[i].href, e);
+ continue;
}
if (rules) {
for(var r = rules.length-1; r >= 0; r--) {
@@ -131,6 +126,20 @@ var getMatchedCSSRules = function (a) {
delete style['text-decoration-style'];
}
+ // text-align inheritance does not seem to get past elements on some
+ // mail clients
+ if (style['text-align'] === 'inherit') {
+ var $el = $(a).parent();
+ do {
+ var align = $el.css('text-align');
+ if (_.indexOf(['left', 'right', 'center', 'justify'], align) >= 0) {
+ style['text-align'] = align;
+ break;
+ }
+ $el = $el.parent();
+ } while (!$el.is('html'));
+ }
+
return style;
};
diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js
index d08f70e2aea..64772e319af 100644
--- a/addons/web_editor/static/src/js/widgets.js
+++ b/addons/web_editor/static/src/js/widgets.js
@@ -539,16 +539,12 @@ var getCssSelectors = function (filter) {
var sheets = document.styleSheets;
for(var i = 0; i < sheets.length; i++) {
var rules;
- if (sheets[i].rules) {
- rules = sheets[i].rules;
- } else {
- //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
- try {
- rules = sheets[i].cssRules;
- } catch(e) {
- console.warn("Can't read the css rules of: " + sheets[i].href, e);
- continue;
- }
+ // try...catch because browser may not able to enumerate rules for cross-domain stylesheets
+ try {
+ rules = sheets[i].rules || sheets[i].cssRules;
+ } catch(e) {
+ console.warn("Can't read the css rules of: " + sheets[i].href, e);
+ continue;
}
if (rules) {
for(var r = 0; r < rules.length; r++) {
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 339c7437afe..a1082890137 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -263,9 +263,13 @@ options.registry["margin-x"] = options.registry.marginAndResize.extend({
return this.grid;
},
- on_clone: function ($clone) {
- var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
- $clone.attr("class", _class);
+ on_clone: function ($clone, options) {
+ // Below condition is added to remove offset of target element only
+ // and not its children to avoid design alteration of a container / block.
+ if (options.isCurrent) {
+ var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
+ $clone.attr("class", _class);
+ }
return false;
},
on_resize: function (compass, beginClass, current) {
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 2f8d3e8b5ff..66a887cbb54 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -889,7 +889,7 @@
-
+
@@ -968,7 +968,7 @@
- Qty:
+ Qty:
@@ -1349,7 +1349,7 @@
|
-
+
|
@@ -1515,7 +1515,7 @@
|
-
+
|
diff --git a/odoo/addons/base/ir/ir_mail_server.py b/odoo/addons/base/ir/ir_mail_server.py
index c061b56f625..b71b835e9f3 100644
--- a/odoo/addons/base/ir/ir_mail_server.py
+++ b/odoo/addons/base/ir/ir_mail_server.py
@@ -453,7 +453,7 @@ class IrMailServer(models.Model):
message['To'] = x_forge_to
# Do not actually send emails in testing mode!
- if getattr(threading.currentThread(), 'testing', False):
+ if getattr(threading.currentThread(), 'testing', False) or self.env.registry.in_test_mode():
_test_logger.info("skip sending email in test mode")
return message['Message-Id']
diff --git a/odoo/addons/base/ir/ir_ui_view.py b/odoo/addons/base/ir/ir_ui_view.py
index 23cf31dbae3..905b3dd0acb 100644
--- a/odoo/addons/base/ir/ir_ui_view.py
+++ b/odoo/addons/base/ir/ir_ui_view.py
@@ -49,7 +49,7 @@ def keep_query(*keep_params, **additional_params):
if not keep_params and not additional_params:
keep_params = ('*',)
params = additional_params.copy()
- qs_keys = request.httprequest.args.keys()
+ qs_keys = request.httprequest.args.keys() if request else []
for keep_param in keep_params:
for param in fnmatch.filter(qs_keys, keep_param):
if param not in additional_params and param in qs_keys:
diff --git a/odoo/modules/migration.py b/odoo/modules/migration.py
index 552c9d8dae7..7f86b73a0da 100644
--- a/odoo/modules/migration.py
+++ b/odoo/modules/migration.py
@@ -116,7 +116,8 @@ class MigrationManager(object):
lst.sort()
return lst
- parsed_installed_version = parse_version(getattr(pkg, 'load_version', pkg.installed_version) or '')
+ installed_version = getattr(pkg, 'load_version', pkg.installed_version) or ''
+ parsed_installed_version = parse_version(installed_version)
current_version = parse_version(convert_version(pkg.data['version']))
versions = _get_migration_versions(pkg)
@@ -153,7 +154,7 @@ class MigrationManager(object):
except AttributeError:
_logger.error('module %(addon)s: Each %(stage)s-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
else:
- migrate(self.cr, pkg.installed_version)
+ migrate(self.cr, installed_version)
finally:
if fp:
fp.close()