diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index c23229288b2..0b3f1c75e71 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -151,7 +151,7 @@ class AccountMove(models.Model): if not journal.refund_sequence_id: raise UserError(_('Please define a sequence for the refunds')) sequence = journal.refund_sequence_id - + new_name = sequence.with_context(ir_sequence_date=move.date).next_by_id() else: raise UserError(_('Please define a sequence on the journal.')) @@ -254,7 +254,7 @@ class AccountMove(models.Model): aml = ac_move.line_ids.filtered(lambda x: x.account_id.reconcile or x.account_id.internal_type == 'liquidity') aml.remove_move_reconcile() #reconcile together the reconciliable and the liquidity aml and their newly created counterpart - for account in [x.account_id for x in aml]: + for account in set([x.account_id for x in aml]): to_rec = aml.filtered(lambda y: y.account_id == account) to_rec |= reversed_move.line_ids.filtered(lambda y: y.account_id == account) to_rec.reconcile() @@ -1222,6 +1222,8 @@ class AccountMoveLine(models.Model): ctx = {} if 'date' in vals: ctx['date'] = vals['date'] + elif 'date_maturity' in vals: + ctx['date'] = vals['date_maturity'] temp['currency_id'] = bank.currency_id.id temp['amount_currency'] = bank.company_id.currency_id.with_context(ctx).compute(tax_vals['amount'], bank.currency_id, round=True) tax_lines_vals.append(temp) diff --git a/addons/product/models/product_attribute.py b/addons/product/models/product_attribute.py index 269dc244d1a..844e363444b 100644 --- a/addons/product/models/product_attribute.py +++ b/addons/product/models/product_attribute.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo.osv import expression from odoo import api, fields, models, _ from odoo.addons import decimal_precision as dp from odoo.exceptions import UserError, ValidationError @@ -107,6 +108,7 @@ class ProductAttributeLine(models.Model): # search on a m2o and one on a m2m, probably this will quickly become # difficult to compute - check if performance optimization is required if name and operator in ('=', 'ilike', '=ilike', 'like', '=like'): - args = ['|', ('attribute_id', operator, name), ('value_ids', operator, name)] - return self.search(args, limit=limit).name_get() + args = args or [] + domain = ['|', ('attribute_id', operator, name), ('value_ids', operator, name)] + return self.search(expression.AND([domain, args]), limit=limit).name_get() return super(ProductAttributeLine, self).name_search(name=name, args=args, operator=operator, limit=limit) diff --git a/addons/purchase_requisition/models/purchase_requisition.py b/addons/purchase_requisition/models/purchase_requisition.py index 7082d934630..49f139b08cf 100644 --- a/addons/purchase_requisition/models/purchase_requisition.py +++ b/addons/purchase_requisition/models/purchase_requisition.py @@ -170,7 +170,7 @@ class PurchaseOrder(models.Model): self.partner_id = partner.id self.fiscal_position_id = fpos.id - self.payment_term_id = payment_term.id, + self.payment_term_id = payment_term.id self.company_id = requisition.company_id.id self.currency_id = currency.id self.origin = requisition.name diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 3c4e60b9d7c..848f25c1d71 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -38,10 +38,12 @@ class AccountAnalyticLine(models.Model): return {} unit_amount = values.get('unit_amount', 0.0) or self.unit_amount user_id = values.get('user_id') or self.user_id.id or self._default_user() - emp = self.env['hr.employee'].search([('user_id', '=', user_id)], limit=1) - account = values.get('account_id') and self.env['account.analytic.account'].browse([values['account_id']]) or self.account_id or emp.account_id + user = self.env['res.users'].browse([user_id]) + emp = self.env['hr.employee'].search([('user_id', '=', user_id), ('company_id', '=', user.company_id.id)], limit=1) + if not emp: + emp = self.env['hr.employee'].search([('user_id', '=', user_id)], limit=1).sudo() cost = emp and emp.timesheet_cost or 0.0 - uom = account.sudo().company_id.project_time_mode_id + uom = (emp or user).company_id.project_time_mode_id # Nominal employee cost = 1 * company project UoM (project_time_mode_id) return { 'amount': -unit_amount * cost, diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 006fd2e7e72..7743cce59f4 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -348,6 +348,9 @@ class WebsiteSale(http.Controller): @http.route(['/shop/cart'], type='http', auth="public", website=True) def cart(self, **post): order = request.website.sale_get_order() + if order and order.state != 'draft': + request.session['sale_order_id'] = None + order = request.website.sale_get_order() if order: from_currency = order.company_id.currency_id to_currency = order.pricelist_id.currency_id @@ -374,7 +377,7 @@ class WebsiteSale(http.Controller): @http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False) def cart_update(self, product_id, add_qty=1, set_qty=0, **kw): - sale_order = request.website.sale_get_order(force_create=1) + sale_order = request.website.sale_get_order(force_create=True) if sale_order.state != 'draft': request.session['sale_order_id'] = None sale_order = request.website.sale_get_order(force_create=True) diff --git a/addons/website_sale_options/controllers/main.py b/addons/website_sale_options/controllers/main.py index 1c84f9e460f..b734ee93776 100644 --- a/addons/website_sale_options/controllers/main.py +++ b/addons/website_sale_options/controllers/main.py @@ -18,7 +18,10 @@ class WebsiteSaleOptions(WebsiteSale): if lang: request.website = request.website.with_context(lang=lang) - order = request.website.sale_get_order(force_create=1) + order = request.website.sale_get_order(force_create=True) + if order.state != 'draft': + request.session['sale_order_id'] = None + order = request.website.sale_get_order(force_create=True) product = request.env['product.product'].browse(int(product_id)) option_ids = product.optional_product_ids.mapped('product_variant_ids').ids