[MERGE] forward port branch saas-12.1 up to 636df25f21

This commit is contained in:
Christophe Simonis
2019-04-11 18:17:25 +02:00
10 changed files with 74 additions and 50 deletions
+10
View File
@@ -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)"
+12 -4
View File
@@ -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)
@@ -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):
@@ -62,7 +62,7 @@
</div>
<field name="monthly_yearly_costs"/>
</group>
<group string="Monthly Benefit in Kind">
<group string="Monthly Benefit in Kind" name="monthly_benefits">
<field name="transport_mode_car"/>
<field name="car_atn" attrs="{'invisible': [('transport_mode_car', '=', False)]}" invisible="1"/>
<field name="transport_employer_cost" invisible="1"/>
@@ -16,7 +16,7 @@
<div class="text-muted">
Configure Default Values for Belgian Advantages
</div>
<group class="mt16">
<group class="mt16" name="default_advantages">>
<label for="default_holidays"/>
<div>
<field name="default_holidays" nolabel="1"/>
+1 -1
View File
@@ -743,7 +743,7 @@ class MrpProduction(models.Model):
})
if workorders:
workorders[-1].next_work_order_id = workorder.id
workorders[-1]._init_nextworkorder_states()
workorders[-1]._start_nextworkorder()
workorders += workorder
# assign moves; last operation receive all unassigned moves (which case ?)
+10 -9
View File
@@ -219,9 +219,6 @@ class MrpWorkorder(models.Model):
if self.qty_producing <= 0:
raise UserError(_('Please set the quantity you are currently producing. It should be different from zero.'))
# One a piece is produced, you can launch the next work order
self._start_nextworkorder()
# 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:
@@ -237,6 +234,9 @@ class MrpWorkorder(models.Model):
self.final_lot_id.use_next_on_work_order_id = self.next_work_order_id
self.final_lot_id = False
# One a piece is produced, you can launch the next work order
self._start_nextworkorder()
# Set a qty producing
rounding = self.production_id.product_uom_id.rounding
if float_compare(self.qty_produced, self.production_id.product_qty, precision_rounding=rounding) >= 0:
@@ -258,12 +258,13 @@ class MrpWorkorder(models.Model):
@api.multi
def _start_nextworkorder(self):
for record in self:
if record.next_work_order_id.state == 'pending':
record.next_work_order_id.state = 'ready'
def _init_nextworkorder_states(self):
return 'pending'
rounding = self.product_id.uom_id.rounding
if self.next_work_order_id.state == 'pending' and (
(self.operation_id.batch == 'no' and
float_compare(self.qty_production, self.qty_produced, precision_rounding=rounding) <= 0) or
(self.operation_id.batch == 'yes' and
float_compare(self.operation_id.batch_size, self.qty_produced, precision_rounding=rounding) <= 0)):
self.next_work_order_id.state = 'ready'
@api.multi
def button_start(self):
+1 -1
View File
@@ -560,7 +560,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
+11
View File
@@ -0,0 +1,11 @@
Bolivia, 2019-03-31
I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Hugo Vinicius Garcia Razeara hviniciusg@gmail.com https://github.com/hviniciusg
+6 -3
View File
@@ -1454,12 +1454,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
@@ -1468,9 +1469,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