diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 036c6a62735..b88b5f39baa 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -670,6 +670,16 @@ msgstr "" msgid "A tax fiscal position could be defined only one time on same taxes." msgstr "" +#. module: account +#: code:addons/account/models/res_users.py:17 +#, python-format +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 #: model:res.groups,name:account.group_warning_account msgid "A warning can be set on a partner (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) 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 e4063cc7139..a1f4bfc6dca 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 @@ -89,15 +89,7 @@ class HrContract(models.Model): def _inverse_wage_with_holidays(self): for contract in self: if contract.holidays: - 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 / 231.0) contract.wage = contract._get_gross_from_employer_costs(contract.final_yearly_costs) else: @@ -106,7 +98,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: @@ -137,17 +128,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.onchange('final_yearly_costs') def _onchange_final_yearly_costs(self): @@ -197,6 +184,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') @@ -205,17 +204,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 ff04cc77592..6931a44e8bc 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
- + >