diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 24525364a01..d978ea9b8b6 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -665,6 +665,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/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 170e2ddf0e8..a17867ab07f 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -671,7 +671,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 ?) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index d5b5aaae349..d688b10d1e3 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -343,9 +343,6 @@ class MrpWorkorder(models.Model): move_line.lot_produced_id = self.final_lot_id.id move_line.done_wo = True - # One a piece is produced, you can launch the next work order - self._start_nextworkorder() - self.move_line_ids.filtered( lambda move_line: not move_line.done_move and not move_line.lot_produced_id and move_line.qty_done > 0 ).write({ @@ -396,6 +393,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: @@ -417,12 +417,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): diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index a708f57e256..398b7d6d672 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -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 diff --git a/doc/cla/individual/hviniciusg.md b/doc/cla/individual/hviniciusg.md new file mode 100644 index 00000000000..d98b0703a49 --- /dev/null +++ b/doc/cla/individual/hviniciusg.md @@ -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 diff --git a/odoo/tests/common.py b/odoo/tests/common.py index fc70adb88a2..bc5a460bcd3 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