Skip to content

Commit

Permalink
Merge 256c32a into 3e20a58
Browse files Browse the repository at this point in the history
  • Loading branch information
fmdl committed Oct 31, 2019
2 parents 3e20a58 + 256c32a commit 8f59500
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stock_scanner/__manifest__.py
Expand Up @@ -4,7 +4,7 @@
{
'name': 'Stock Scanner',
'summary': 'Allows managing barcode readers with simple scenarios',
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'category': 'Generic Modules/Inventory Control',
'website': 'https://github.com/OCA/stock-logistics-barcode',
'author': 'Subteno IT,'
Expand Down
3 changes: 2 additions & 1 deletion stock_scanner/models/scanner_scenario.py
Expand Up @@ -107,7 +107,7 @@ def _check_recursion(self):
)

@api.multi
def copy(self, default):
def copy(self, default=None):
default = default or {}
default['name'] = _('Copy of %s') % self.name

Expand All @@ -120,3 +120,4 @@ def copy(self, default):
[('scenario_id', '=', self.id)]):
trans.copy({'from_id': step_news[trans.from_id.id],
'to_id': step_news[trans.to_id.id]})
return scenario_new
13 changes: 13 additions & 0 deletions stock_scanner/tests/test_stock_scanner_scenario.py
Expand Up @@ -14,3 +14,16 @@ def test_recursive_scenarios(self):
'stock_scanner.scanner_scenario_sentinel')
with self.assertRaises(exceptions.ValidationError):
parent_scenario.parent_id = child_scenario

def test_copy_scenario(self):
scenario = self.env.ref(
'stock_scanner.scanner_scenario_tutorial')
copied_scenario = scenario.copy()

self.assertEqual(len(scenario.step_ids), len(copied_scenario.step_ids))

transitions = scenario.step_ids.mapped('out_transition_ids') \
| scenario.step_ids.mapped('in_transition_ids')
copied_transitions = copied_scenario.step_ids.mapped('out_transition_ids') \
| copied_scenario.step_ids.mapped('in_transition_ids')
self.assertEqual(len(transitions), len(copied_transitions))

0 comments on commit 8f59500

Please sign in to comment.