From 429bcd9464928c21b0bdc3e99280cd50bf0c36b8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 9 May 2018 14:10:51 +0200 Subject: [PATCH 01/14] [FIX] payment_sips: special characters The field `transactionReference` of Sips must contain only alphanumerical characters. Previous commit 31dc6b888eeb2d787f5675 solved the special case of several attempts to pay, but a much simpler case may appear in v11. Paying an invoice is likely to fail since the reference contains by default `/`. In the previous commit, we could simply modify the common `payment` module code. In this specific case, however, we only change the reference if the acquirer is Sips. opw-1841483 --- addons/account_payment/models/payment.py | 2 +- addons/payment/models/payment_acquirer.py | 4 ++++ addons/payment_sips/models/payment.py | 11 +++++++++++ addons/sale_payment/models/payment.py | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/addons/account_payment/models/payment.py b/addons/account_payment/models/payment.py index 389cfa206e1..cfc90258289 100644 --- a/addons/account_payment/models/payment.py +++ b/addons/account_payment/models/payment.py @@ -159,7 +159,7 @@ class PaymentTransaction(models.Model): 'currency_id': invoice.currency_id.id, 'partner_id': invoice.partner_id.id, 'partner_country_id': invoice.partner_id.country_id.id, - 'reference': self.get_next_reference(invoice.number), + 'reference': self._get_next_reference(invoice.number, acquirer=acquirer), 'account_invoice_id': invoice.id, } if add_tx_values: diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index efd6573c778..98992c2a679 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -685,6 +685,10 @@ class PaymentTransaction(models.Model): @api.model def get_next_reference(self, reference): + return self._get_next_reference(reference) + + @api.model + def _get_next_reference(self, reference, acquirer=None): ref_suffix = 1 init_ref = reference while self.env['payment.transaction'].sudo().search_count([('reference', '=', reference)]): diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py index 46464b7d60c..60e4d9f3153 100644 --- a/addons/payment_sips/models/payment.py +++ b/addons/payment_sips/models/payment.py @@ -4,6 +4,7 @@ import json import logging +import re from hashlib import sha256 from werkzeug import urls @@ -111,6 +112,16 @@ class AcquirerSips(models.Model): return self.environment == 'prod' and self.sips_prod_url or self.sips_test_url +class PaymentTransactionSips(models.Model): + _inherit = 'payment.transaction' + + @api.model + def _get_next_reference(self, reference, acquirer=None): + if acquirer and acquirer.provider == 'sips': + reference = re.sub(r'[^0-9a-zA-Z]+', 'x' , reference) + return super(PaymentTransactionSips, self)._get_next_reference(reference, acquirer=acquirer) + + class TxSips(models.Model): _inherit = 'payment.transaction' diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py index 831af37550f..f710b63630f 100644 --- a/addons/sale_payment/models/payment.py +++ b/addons/sale_payment/models/payment.py @@ -182,7 +182,7 @@ class PaymentTransaction(models.Model): 'currency_id': order.pricelist_id.currency_id.id, 'partner_id': order.partner_id.id, 'partner_country_id': order.partner_id.country_id.id, - 'reference': self.get_next_reference(order.name), + 'reference': self._get_next_reference(order.name, acquirer=acquirer), 'sale_order_id': order.id, } if add_tx_values: From 1dbeda01578734859220bcb2079a5083789ff135 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 14 May 2018 12:13:06 +0200 Subject: [PATCH 02/14] [FIX] project: sub-tasks - Activate sub-tasks in projects - Enter a project's tasks, click on the stat button 'Sub-tasks' - Reload the page (F5) A traceback occurs since `project_id` is undefined. The fields `project_id` and `partner_id` are only defined in the context of the stat button. opw-1844334 --- addons/project/models/project.py | 14 ++++++++++++++ addons/project/views/project_views.xml | 12 +----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index d25de3f6ab4..b00b160ae2b 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -877,6 +877,20 @@ class Task(models.Model): 'type': 'ir.actions.act_window' } + def action_subtask(self): + action = self.env.ref('project.project_task_action_sub_task').read()[0] + ctx = self.env.context.copy() + ctx.update({ + 'default_parent_id' : self.id, + 'default_project_id' : self.env.context.get('project_id', self.subtask_project_id.id), + 'default_name' : self.env.context.get('name', self.name) + ':', + 'default_partner_id' : self.env.context.get('partner_id', self.partner_id.id), + 'search_default_project_id': self.env.context.get('project_id', self.subtask_project_id.id), + }) + action['context'] = ctx + action['domain'] = [('id', 'child_of', self.id), ('id', '!=', self.id)] + return action + class AccountAnalyticAccount(models.Model): _inherit = 'account.analytic.account' diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 9ebcef69138..bf1e63a5599 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -84,16 +84,6 @@ Sub-tasks project.task kanban,tree,form,calendar,pivot,graph - [('id', 'child_of', active_id), ('id', '!=', active_id)] - - { - 'default_parent_id' : active_id, - 'default_project_id' : project_id, - 'default_name' : name + ':', - 'default_partner_id' : partner_id, - 'search_default_project_id': [project_id], - } - @@ -403,7 +393,7 @@
+
+
From 6558d52e9b5dd774145d2df3822dcea8a35f7872 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 15 May 2018 16:30:05 +0200 Subject: [PATCH 11/14] [FIX] account: adjustment wizard usability This commits removes a disambiguation on the choices of the 'Adjustment Type' selection as 'in your favor' could be achieved by debitting the 'Collected Tax' account or creditting the 'Paid Tax' accounts (respectively for 'in favor of the Estate'). The choices now refers directly to the journal item where the tax is gonna be copied Related to https://github.com/odoo/odoo/commit/c58ef14a01f600d75391f2a9c38bb2b30e0e2528 Related to OPW 1826242 --- addons/account/wizard/wizard_tax_adjustments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/wizard_tax_adjustments.py b/addons/account/wizard/wizard_tax_adjustments.py index 22d2235ef04..05f893722a0 100644 --- a/addons/account/wizard/wizard_tax_adjustments.py +++ b/addons/account/wizard/wizard_tax_adjustments.py @@ -18,7 +18,7 @@ class TaxAdjustments(models.TransientModel): debit_account_id = fields.Many2one('account.account', string='Debit account', required=True, domain=[('deprecated', '=', False)]) credit_account_id = fields.Many2one('account.account', string='Credit account', required=True, domain=[('deprecated', '=', False)]) amount = fields.Monetary(currency_field='company_currency_id', required=True) - adjustment_type = fields.Selection([('debit', 'Adjustment in favor of the Estate'), ('credit', 'Adjustment in your favor')], string="Adjustment Type", store=False, required=True) + adjustment_type = fields.Selection([('debit', 'Applied on debit journal item'), ('credit', 'Applied on credit journal item')], string="Adjustment Type", store=False, required=True) company_currency_id = fields.Many2one('res.currency', readonly=True, default=lambda self: self.env.user.company_id.currency_id) tax_id = fields.Many2one('account.tax', string='Adjustment Tax', ondelete='restrict', domain=[('type_tax_use', '=', 'none'), ('tax_adjustment', '=', True)], required=True) From 35c2a74480cf06849f561abcc27c5c9021b28151 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 15 May 2018 13:28:32 +0200 Subject: [PATCH 12/14] [FIX] delivery: Delivery method name not translated When adding a SO line with a delivery method (e.g. The Post) for a customer with a different language that the one set on the current language, the description of the SO line was not translated. Inspired from function 'product_id_change' in model 'sale.order.line' opw:1843934 --- addons/delivery/models/sale_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 184374020af..cea84ee491c 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -89,9 +89,10 @@ class SaleOrder(models.Model): taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids # Create the sales order line + carrier_name = carrier.product_id.with_context(lang=self.partner_id.lang).name_get()[0][1] values = { 'order_id': self.id, - 'name': carrier.name, + 'name': carrier_name, 'product_uom_qty': 1, 'product_uom': carrier.product_id.uom_id.id, 'product_id': carrier.product_id.id, From e5fb990db1d6216a156617e387d85d13c1a0b93c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 15 May 2018 17:07:44 +0200 Subject: [PATCH 13/14] [FIX] project: prevent to create recursive hierarchy of tasks Until this revision, this was possible to set as parent task the current task. From then, it was impossible to compute the field `subtask_count` because of an infinite loop. This resulted to the inability to open the task form, which contains this field. opw-1847982 --- addons/project/i18n/project.pot | 6 ++++++ addons/project/models/project.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/project/i18n/project.pot b/addons/project/i18n/project.pot index 101c95cdd82..79618e19e4a 100644 --- a/addons/project/i18n/project.pot +++ b/addons/project/i18n/project.pot @@ -1573,6 +1573,12 @@ msgstr "" msgid "Ending Date" msgstr "" +#. module: project +#: code:addons/project/models/project.py:556 +#, python-format +msgid "Error! You cannot create recursive hierarchy of task(s)." +msgstr "" + #. module: project #: sql_constraint:project.project:0 msgid "Error! project start-date must be lower than project end-date." diff --git a/addons/project/models/project.py b/addons/project/models/project.py index b00b160ae2b..2798faaf12a 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -4,7 +4,7 @@ from lxml import etree from odoo import api, fields, models, tools, SUPERUSER_ID, _ -from odoo.exceptions import UserError, AccessError +from odoo.exceptions import UserError, AccessError, ValidationError from odoo.tools.safe_eval import safe_eval @@ -549,6 +549,12 @@ class Task(models.Model): for task in self: task.subtask_count = self.search_count([('id', 'child_of', task.id), ('id', '!=', task.id)]) + @api.constrains('parent_id') + def _check_parent_id(self): + for task in self: + if not task._check_recursion(): + raise ValidationError(_('Error! You cannot create recursive hierarchy of task(s).')) + @api.constrains('parent_id') def _check_subtask_project(self): for task in self: From fb17edd0b0d5c956f6991feabfa704566fa0a11b Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 15 May 2018 19:19:51 +0200 Subject: [PATCH 14/14] [FIX] event_sale: update registrations as sudo. Consequence of 19878d011f8abdc737b7b702c4c79632670d4b78 --- addons/event_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/event_sale/models/sale_order.py b/addons/event_sale/models/sale_order.py index 7a2dcd8a745..6902d8e4743 100644 --- a/addons/event_sale/models/sale_order.py +++ b/addons/event_sale/models/sale_order.py @@ -41,7 +41,7 @@ class SaleOrderLine(models.Model): order line has a product_uom_qty attribute that will be the number of registrations linked to this line. This method update existing registrations and create new one for missing one. """ - Registration = self.env['event.registration'] + Registration = self.env['event.registration'].sudo() registrations = Registration.search([('sale_order_line_id', 'in', self.ids), ('state', '!=', 'cancel')]) for so_line in self.filtered('event_id'): existing_registrations = registrations.filtered(lambda self: self.sale_order_line_id.id == so_line.id)