From e402c89bcc54d2dd471b08d9ca59ffc73657bf01 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 9 Apr 2019 12:14:49 +0000 Subject: [PATCH 1/7] [FIX] stock_account: price unit is zero - Set a product P to average valuation, real time - Create a PO for 1 unit @ 100, validate the picking - Create a PO for 1 unit @ 0 (e.g. you receive a free product) You cannot validate the picking because of the message 'The cost of P is currently equal to 0...' This error message is historical, to prevent users from an incorrect configuration. Since we still want to prevent misconfiguration, but support the mentioned use case, we introduce an `ir._config_parameter` for people who 'know what they are doing'. opw-1962249 closes odoo/odoo#32550 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock_account/models/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 1b544c5559d..7204e532c7e 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -562,7 +562,7 @@ class StockMove(models.Model): debit_value = self.company_id.currency_id.round(valuation_amount) # check that all data is correct - if self.company_id.currency_id.is_zero(debit_value): + if self.company_id.currency_id.is_zero(debit_value) and not self.env['ir.config_parameter'].sudo().get_param('stock_account.allow_zero_cost'): raise UserError(_("The cost of %s is currently equal to 0. Change the cost or the configuration of your product to avoid an incorrect valuation.") % (self.product_id.display_name,)) credit_value = debit_value From 5a83cd264999c588d2a980ac5ae972343619f255 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 10 Apr 2019 13:36:39 +0000 Subject: [PATCH 2/7] [FIX]sale_stock: Issue when clicking on "No backorder" Steps to reproduce the bug: - Create a SO with no salesperson - Add a SO line with 2 storable product - Confirm the SO and deliver only one product - Click on "No backorder" Bug: A error was raised because the function "_log_activity"(called by _log_less_quantities_than_expected) requires a responsible Partial Backport: https://github.com/odoo/odoo/commit/e1f9499d2672fb0a346f8ac74552f038f5204a64 opw:1950968 closes odoo/odoo#32592 Signed-off-by: Simon Goffin (sig) --- addons/stock/models/stock_picking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index b4d120ce53b..004b085f6ba 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -7,7 +7,7 @@ import time from datetime import date from itertools import groupby -from odoo import api, fields, models, _ +from odoo import api, fields, models, _, SUPERUSER_ID from odoo.osv import expression from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT from odoo.tools.float_utils import float_compare, float_is_zero, float_round @@ -931,7 +931,7 @@ class Picking(models.Model): 'mail.mail_activity_data_warning', date.today(), note=note, - user_id=responsible.id + user_id=responsible.id or SUPERUSER_ID ) def _log_less_quantities_than_expected(self, moves): From 6bd9e71d9d54ea541a107846543e4de463be7132 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 11 Apr 2019 06:26:17 +0000 Subject: [PATCH 3/7] [FIX] SSF: misinterpretation of onchange command (4) From an onchange, at this point, (4) doesn't mean "no change" it means "reset to database values". Through the interplay of client and server reverse-engineering one another at this point the client (is supposed to) assume the o2m results are "complete" and a diff from the current *in-database* values rather than the in-client (sent to the server) ones. So a (1) should completely replace all existing values, and a (4) should just remove all of them (but keep the record linked). closes odoo/odoo#32617 Signed-off-by: Xavier Morel (xmo) --- odoo/tests/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 507d023fc98..df6c626906b 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1461,12 +1461,13 @@ class Form(object): return [] v = [] - c = {t[1]: t[2] for t in current if t[0] in (1, 2)} if current else {} + c = {t[1] for t in current if t[0] in (1, 2)} if current else set() # which view should this be??? subfields = descr['views']['edition']['fields'] + # TODO: simplistic, unlikely to work if e.g. there's a 5 inbetween other commands for command in value: if command[0] in (0, 1): - c.pop(command[1], None) # remove record from currents + c.discard(command[1]) v.append((command[0], command[1], { k: self._cleanup_onchange( subfields[k], v, None @@ -1475,9 +1476,11 @@ class Form(object): if k in subfields })) elif command[0] == 2: + c.discard(command[1]) v.append((2, command[1], False)) elif command[0] == 4: - v.append((1, command[1], c.pop(command[1], {}))) + c.discard(command[1]) + v.append((1, command[1], {})) elif command[0] == 5: v = [] # explicitly mark all non-relinked (or modified) records as deleted From 9365dc5d17b89a44c1d84313d7228c9f7b7f4efd Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Thu, 11 Apr 2019 10:16:31 +0000 Subject: [PATCH 4/7] [FIX] account: better message on user group error The validation error introduced in 552da8dc can pop up in contexts where it is not expected; e.g. not in editing user rights but while upgrading a module. Therefore we make it more explicit, giving the user a way to resolve the error. closes odoo/odoo#32623 Signed-off-by: Nans Lefebvre (len) --- addons/account/i18n/account.pot | 6 +++++- addons/account/models/res_users.py | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 7d790411b5d..8af8a88254a 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -657,7 +657,11 @@ msgstr "" #. module: account #: code:addons/account/models/res_users.py:17 #, python-format -msgid "A user cannot have both Tax B2B and Tax B2C" +msgid "A user cannot have both Tax B2B and Tax B2C.\n" +"Problematic user(s): %s\n" +"You should go in General Settings, and choose to display Product Prices\n" +"either in 'Tax-Included' or in 'Tax-Excluded' mode\n" +"(or switch twice the mode if you are already in the desired one)." msgstr "" #. module: account diff --git a/addons/account/models/res_users.py b/addons/account/models/res_users.py index 3e6fd163482..ab85e359d22 100644 --- a/addons/account/models/res_users.py +++ b/addons/account/models/res_users.py @@ -12,7 +12,15 @@ class Users(models.Model): @api.constrains('groups_id') def _check_one_user_type(self): super(Users, self)._check_one_user_type() - for user in self: - if (user.user_has_groups('account.group_show_line_subtotals_tax_included') and - user.user_has_groups('account.group_show_line_subtotals_tax_excluded')): - raise ValidationError(_('A user cannot have both Tax B2B and Tax B2C')) + + users_with_both_groups = self.filtered(lambda user: + user.user_has_groups('account.group_show_line_subtotals_tax_included') and + user.user_has_groups('account.group_show_line_subtotals_tax_excluded') + ) + if users_with_both_groups: + names = ", ".join(users_with_both_groups.mapped('name')) + raise ValidationError(_("A user cannot have both Tax B2B and Tax B2C.\n" + "Problematic user(s): %s\n" + "You should go in General Settings, and choose to display Product Prices\n" + "either in 'Tax-Included' or in 'Tax-Excluded' mode\n" + "(or switch twice the mode if you are already in the desired one).") % names) From 87a30cca7ddde77f42e15886a1b11946624c975d Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Wed, 10 Apr 2019 12:43:47 +0000 Subject: [PATCH 5/7] [IMP] l10n_be_hr_payroll: Add an overridable method to compute costs closes odoo/odoo#32582 Signed-off-by: Yannick Tivisse (yti) --- .../models/l10n_be_hr_payroll.py | 51 ++++++++----------- .../views/l10n_be_hr_payroll_view.xml | 2 +- .../views/res_config_settings_views.xml | 2 +- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py b/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py index a224be4ce9a..a005521f586 100644 --- a/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py +++ b/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py @@ -95,15 +95,7 @@ class HrContract(models.Model): def _inverse_wage_with_holidays(self): for contract in self: if contract.holidays > 20.0: - remaining_for_gross = contract.wage_with_holidays * (13.0 + 13.0 * 0.3507 + 0.92) - yearly_cost = remaining_for_gross \ - + 12.0 * contract.representation_fees \ - + 12.0 * contract.fuel_card \ - + 12.0 * contract.internet \ - + 12.0 * (contract.mobile + contract.mobile_plus) \ - + 12.0 * contract.transport_employer_cost \ - + contract.warrants_cost \ - + 220.0 * contract.meal_voucher_paid_by_employer + yearly_cost = contract._get_advantages_costs() + (13.92 + 13.0 * 0.3507) * contract.wage_with_holidays contract.final_yearly_costs = yearly_cost / (1.0 - (contract.holidays - 20.0) / 231.0) contract.wage = contract._get_gross_from_employer_costs(contract.final_yearly_costs) else: @@ -112,7 +104,6 @@ class HrContract(models.Model): @api.depends('transport_mode_car', 'transport_mode_public', 'transport_mode_others', 'company_car_total_depreciated_cost', 'public_transport_reimbursed_amount', 'others_reimbursed_amount') def _compute_transport_employer_cost(self): - # Don't call to super has we ovewrite the method for contract in self: transport_employer_cost = 0.0 if contract.transport_mode_car: @@ -143,17 +134,13 @@ class HrContract(models.Model): contract.transport_employer_cost ) - @api.depends('yearly_cost_before_charges', 'social_security_contributions', 'wage', - 'social_security_contributions', 'warrants_cost', 'meal_voucher_paid_by_employer') + @api.depends( + 'wage', 'fuel_card', 'representation_fees', 'transport_employer_cost', + 'internet', 'mobile', 'mobile_plus', 'warrants_cost', + 'meal_voucher_paid_by_employer') def _compute_final_yearly_costs(self): for contract in self: - contract.final_yearly_costs = ( - contract.yearly_cost_before_charges + - contract.social_security_contributions + - contract.wage * 0.92 + - contract.warrants_cost + - (220.0 * contract.meal_voucher_paid_by_employer) - ) + contract.final_yearly_costs = contract._get_advantages_costs() + (13.92 + 13.0 * 0.3507) * contract.wage @api.depends('holidays', 'final_yearly_costs') def _compute_holidays_compensation(self): @@ -218,6 +205,18 @@ class HrContract(models.Model): if self.mobile_plus and not self.mobile: raise ValidationError(_('You should have a mobile subscription to select an international communication amount.')) + def _get_advantages_costs(self): + self.ensure_one() + return ( + 12.0 * self.representation_fees + + 12.0 * self.fuel_card + + 12.0 * self.internet + + 12.0 * (self.mobile + self.mobile_plus) + + 12.0 * self.transport_employer_cost + + self.warrants_cost + + 220.0 * self.meal_voucher_paid_by_employer + ) + def _get_mobile_amount(self, has_mobile, international_communication): if has_mobile and international_communication: return self.env['ir.default'].sudo().get('hr.contract', 'mobile') + self.env['ir.default'].sudo().get('hr.contract', 'mobile_plus') @@ -226,17 +225,9 @@ class HrContract(models.Model): return 0.0 def _get_gross_from_employer_costs(self, yearly_cost): - contract = self - remaining_for_gross = yearly_cost \ - - 12.0 * contract.representation_fees \ - - 12.0 * contract.fuel_card \ - - 12.0 * contract.internet \ - - 12.0 * (contract.mobile + contract.mobile_plus) \ - - 12.0 * contract.transport_employer_cost \ - - contract.warrants_cost \ - - 220.0 * contract.meal_voucher_paid_by_employer - gross = remaining_for_gross / (13.0 + 13.0 * 0.3507 + 0.92) - return gross + self.ensure_one() + remaining_for_gross = yearly_cost - self._get_advantages_costs() + return remaining_for_gross / (13.92 + 13.0 * 0.3507) class HrEmployee(models.Model): diff --git a/addons/l10n_be_hr_payroll/views/l10n_be_hr_payroll_view.xml b/addons/l10n_be_hr_payroll/views/l10n_be_hr_payroll_view.xml index 38bd7d2bf3a..8c9dfd6a05d 100644 --- a/addons/l10n_be_hr_payroll/views/l10n_be_hr_payroll_view.xml +++ b/addons/l10n_be_hr_payroll/views/l10n_be_hr_payroll_view.xml @@ -62,7 +62,7 @@ - + diff --git a/addons/l10n_be_hr_payroll/views/res_config_settings_views.xml b/addons/l10n_be_hr_payroll/views/res_config_settings_views.xml index 947cfbb98f7..fc3c38f8c34 100644 --- a/addons/l10n_be_hr_payroll/views/res_config_settings_views.xml +++ b/addons/l10n_be_hr_payroll/views/res_config_settings_views.xml @@ -16,7 +16,7 @@
Configure Default Values for Belgian Advantages
- + >