diff options
| author | Yannick Tivisse <yti@odoo.com> | 2016-08-03 10:43:28 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-08-04 11:55:50 +0200 |
| commit | 68c6f0deeb6b717f13fb0300f068249ba320aa3b (patch) | |
| tree | 76a879ec36bd282ea7b8672bba5934c3c45d7dc5 | |
| parent | 3769c7800ecf467669e13af87c1eac3207f9e398 (diff) | |
[account*, mrp*, sale*, stock*,...] Convert remaining .yml files to new API
Only purchase still has old api yml files, but they will be converted in
the module migration
38 files changed, 705 insertions, 723 deletions
diff --git a/addons/account/demo/account_bank_statement.yml b/addons/account/demo/account_bank_statement.yml index 86ce917ee44..06e7e1ef647 100644 --- a/addons/account/demo/account_bank_statement.yml +++ b/addons/account/demo/account_bank_statement.yml @@ -1,75 +1,74 @@ - Create demo bank statement - - !python {model: ir.model.data} : | - journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank')]) + !python {model: ir.model.data, id: False} : | + journal = self.env['account.journal'].search([('type', '=', 'bank')], limit=1) import time - if journal_id: - journal_id = journal_id[0] + if journal: vals = { - 'journal_id': journal_id, + 'journal_id': journal.id, 'date': time.strftime('%Y')+'-01-01', 'name': "BNK/2014/001", 'balance_end_real': '8998.2', 'company_id': ref('base.main_company'), 'balance_start': 5103.0 } - self._update(cr, uid, 'account.bank.statement', 'account', vals, 'demo_bank_statement_1') + self._update('account.bank.statement', 'account', vals, 'demo_bank_statement_1') vals = { 'ref': '', 'statement_id': ref('account.demo_bank_statement_1'), 'sequence': 1, 'company_id': ref('base.main_company'), 'name': "SAJ/2014/002 and SAJ/2014/003", - 'journal_id': journal_id, + 'journal_id': journal.id, 'amount': 1175.0, 'date': time.strftime('%Y')+'-01-01', 'partner_id': ref('base.res_partner_2'), } - self._update(cr, uid, 'account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_1') + self._update('account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_1') vals = { 'ref': '', 'statement_id': ref('account.demo_bank_statement_1'), 'sequence': 2, 'company_id': ref('base.main_company'), 'name': "Bank fees", - 'journal_id': journal_id, + 'journal_id': journal.id, 'amount': -32.58, 'date': time.strftime('%Y')+'-01-01', } - self._update(cr, uid, 'account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_2') + self._update('account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_2') vals = { 'ref': '', 'statement_id': ref('account.demo_bank_statement_1'), 'sequence': 3, 'company_id': ref('base.main_company'), 'name': "Prepayment", - 'journal_id': journal_id, + 'journal_id': journal.id, 'amount': 650.0, 'date': time.strftime('%Y')+'-01-01', 'partner_id': ref('base.res_partner_12'), } - self._update(cr, uid, 'account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_3') + self._update('account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_3') vals = { 'ref': '', 'statement_id': ref('account.demo_bank_statement_1'), 'sequence': 4, 'company_id': ref('base.main_company'), 'name': "First 2000 € of SAJ/2014/001", - 'journal_id': journal_id, + 'journal_id': journal.id, 'amount': 2000.0, 'date': time.strftime('%Y')+'-01-01', 'partner_id': ref('base.res_partner_12'), } - self._update(cr, uid, 'account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_4') + self._update('account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_4') vals = { 'ref': '', 'statement_id': ref('account.demo_bank_statement_1'), 'sequence': 5, 'company_id': ref('base.main_company'), 'name': "Last Year Interests", - 'journal_id': journal_id, + 'journal_id': journal.id, 'amount': 102.78, 'date': time.strftime('%Y')+'-01-01', } - self._update(cr, uid, 'account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_5') + self._update('account.bank.statement.line', 'account', vals, 'demo_bank_statement_line_5')
\ No newline at end of file diff --git a/addons/account/demo/account_invoice_demo.yml b/addons/account/demo/account_invoice_demo.yml index be9471405d5..8b7d58dbdc6 100644 --- a/addons/account/demo/account_invoice_demo.yml +++ b/addons/account/demo/account_invoice_demo.yml @@ -78,19 +78,19 @@ type: 'in_invoice' date_invoice: !eval time.strftime('%Y-%m')+'-01' - - !python {model: ir.model.data} : | + !python {model: ir.model.data, id: False} : | line_vals = { 'invoice_id': ref('demo_invoice_january_wages'), 'name': "CEO wages", 'price_unit': 10000, } - account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_ceo_wages_account')])]) - if not account_id: - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses'))]) - if account_id: - line_vals['account_id'] = account_id[0] - self._update(cr, uid, 'account.invoice.line', 'account', line_vals, 'ceo_wages_line') - self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('demo_invoice_january_wages')], 'invoice_open') + account = self.env['account.account'].search([('tag_ids', 'in', [ref('account.demo_ceo_wages_account')])], limit=1) + if not account: + account = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses'))], limit=1) + if account: + line_vals['account_id'] = account.id + self._update('account.invoice.line', 'account', line_vals, 'ceo_wages_line') + self.env['account.invoice'].browse(ref('demo_invoice_january_wages')).signal_workflow('invoice_open') - !record {model: account.invoice, id: demo_invoice_equipment_purchase}: company_id: base.main_company @@ -98,61 +98,63 @@ type: 'in_invoice' date_invoice: !eval time.strftime('%Y-%m')+'-15' - - !python {model: ir.model.data} : | + !python {model: ir.model.data, id: False} : | line_vals = { 'invoice_id': ref('demo_invoice_equipment_purchase'), 'name': "Coffee Machine with huge 'employee\'s performances boosting perk'", 'price_unit': 4999.99, } - account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_coffee_machine_account')])]) + account_id = self.env['account.account'].search([('tag_ids', 'in', [ref('account.demo_coffee_machine_account')])], limit=1).id if not account_id: - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses'))]) + account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses'))], limit=1).id if account_id: - line_vals['account_id'] = account_id[0] - tax_id = self.pool.get('account.tax').search(cr, uid, [('type_tax_use', '=', 'purchase'), ('amount', '>', 0)]) + line_vals['account_id'] = account_id + tax_id = self.env['account.tax'].search([('type_tax_use', '=', 'purchase'), ('amount', '>', 0)], limit=1).id if tax_id: - line_vals['invoice_line_tax_ids'] = [(6, 0, [tax_id[0]])] - self._update(cr, uid, 'account.invoice.line', 'account', line_vals, 'coffee_machine_line') - self.pool.get('account.invoice').browse(cr, uid, ref('demo_invoice_equipment_purchase'))._onchange_invoice_line_ids() - self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('demo_invoice_equipment_purchase')], 'invoice_open') -- - !python {model: account.bank.statement.line} : | - account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', 'in', [ref('account.account_tag_financing')])]) - line = self.browse(cr, uid, ref('account.demo_bank_statement_line_5')) - if not line.journal_entry_ids and account_ids: - line.write({'account_id': account_ids[0]}) + line_vals['invoice_line_tax_ids'] = [(6, 0, [tax_id])] + self._update('account.invoice.line', 'account', line_vals, 'coffee_machine_line') + self.env['account.invoice'].browse(ref('demo_invoice_equipment_purchase'))._onchange_invoice_line_ids() + self.env['account.invoice'].browse(ref('demo_invoice_equipment_purchase')).signal_workflow('invoice_open') +- + !python {model: account.bank.statement.line, id: False} : | + account = self.env['account.account'].search([ + ('user_type_id', '=', ref('account.data_account_type_revenue')), + ('tag_ids', 'in', [ref('account.account_tag_financing')])], limit=1) + line = self.env.ref('account.demo_bank_statement_line_5') + if not line.journal_entry_ids and account: + line.write({'account_id': account.id}) line.fast_counterpart_creation() - - !python {model: ir.model.data} : | + !python {model: ir.model.data, id: False} : | from datetime import datetime from dateutil.relativedelta import relativedelta vals = { 'company_id': ref('base.main_company'), - 'journal_id': self.pool.get('account.journal').search(cr, uid, [('type', '=', 'general')])[0], + 'journal_id': self.env['account.journal'].search([('type', '=', 'general')], limit=1).id, 'date': datetime.now().replace(day=1,month=1) - relativedelta(days=1), 'ref': 'Company Creation', } - self._update(cr, uid, 'account.move', 'account', vals, 'demo_opening_move') -- - !python {model: ir.model.data} : | - bank_journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank')])[0] - if bank_journal_id: - bank_account_id = self.pool.get('account.journal').browse(cr, uid, bank_journal_id).default_debit_account_id.id - fixed_asset_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', 'in', (ref('account.data_account_type_fixed_assets'),ref('account.data_account_type_current_assets')))]) - equity_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_equity')), ('tag_ids', 'in', [ref('account.demo_capital_account')])]) - if bank_account_id and fixed_asset_account_ids and equity_account_ids: - self._update(cr, uid, 'account.move.line', 'account', { + self._update('account.move', 'account', vals, 'demo_opening_move') +- + !python {model: ir.model.data, id: False} : | + bank_journal = self.env['account.journal'].search([('type', '=', 'bank')], limit=1) + if bank_journal: + bank_account_id = bank_journal.default_debit_account_id.id + fixed_asset_account_id = self.env['account.account'].search([('user_type_id', 'in', (ref('account.data_account_type_fixed_assets'),ref('account.data_account_type_current_assets')))], limit=1).id + equity_account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_equity')), ('tag_ids', 'in', [ref('account.demo_capital_account')])], limit=1).id + if bank_account_id and fixed_asset_account_id and equity_account_id: + self.with_context({'check_move_validity': False})._update('account.move.line', 'account', { 'move_id': ref('account.demo_opening_move'), 'name': 'Opening Entry', 'debit': 5103, - 'account_id': bank_account_id}, 'opening_line_1', context={'check_move_validity': False}) - self._update(cr, uid, 'account.move.line', 'account', { + 'account_id': bank_account_id}, 'opening_line_1') + self.with_context({'check_move_validity': False})._update('account.move.line', 'account', { 'move_id': ref('account.demo_opening_move'), 'name': 'Opening Entry', 'debit': 13447, - 'account_id': fixed_asset_account_ids[0]}, 'opening_line_2', context={'check_move_validity': False}) - self._update(cr, uid, 'account.move.line', 'account', { + 'account_id': fixed_asset_account_id[0]}, 'opening_line_2') + self.with_context({'check_move_validity': False})._update('account.move.line', 'account', { 'move_id': ref('account.demo_opening_move'), 'name': 'Opening Entry', 'credit': 18550, - 'account_id': equity_account_ids[0]}, 'opening_line_3', context={'check_move_validity': False}) + 'account_id': equity_account_id[0]}, 'opening_line_3') diff --git a/addons/account/demo/account_statement_operations.yml b/addons/account/demo/account_statement_operations.yml index 5e7eab605ca..342e35fdac9 100644 --- a/addons/account/demo/account_statement_operations.yml +++ b/addons/account/demo/account_statement_operations.yml @@ -1,6 +1,6 @@ - - !python {model: ir.model.data} : | - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses')), ('tag_ids', '=', ref('account_tag_operating'))]) + !python {model: ir.model.data, id: False} : | + account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses')), ('tag_ids', '=', ref('account_tag_operating'))], limit=1).id vals = { 'name': "Discount For Early Payment", 'label': 'Discount', @@ -8,11 +8,11 @@ 'amount': -7, } if account_id: - vals['account_id'] = account_id[0] - self._update(cr, uid, 'account.operation.template', 'account', vals, 'statement_operation_template_1') + vals['account_id'] = account_id + self._update('account.operation.template', 'account', vals, 'statement_operation_template_1') - - !python {model: ir.model.data} : | - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses')), ('tag_ids', '=', ref('account_tag_operating'))]) + !python {model: ir.model.data, id: False} : | + account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses')), ('tag_ids', '=', ref('account_tag_operating'))], limit=1).id vals = { 'name': "Bank Fees", 'label': 'Bank Fees', @@ -20,11 +20,11 @@ 'amount': 100.0, } if account_id: - vals['account_id'] = account_id[0] - self._update(cr, uid, 'account.operation.template', 'account', vals, 'statement_operation_template_2') + vals['account_id'] = account_id + self._update('account.operation.template', 'account', vals, 'statement_operation_template_2') - - !python {model: ir.model.data} : | - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', '=', ref('account_tag_operating'))]) + !python {model: ir.model.data, id: False} : | + account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', '=', ref('account_tag_operating'))], limit=1).id vals = { 'name': "Profit / Loss", 'label': 'Profit / Loss', @@ -32,6 +32,6 @@ 'amount': 100.0, } if account_id: - vals['account_id'] = account_id[0] - self._update(cr, uid, 'account.operation.template', 'account', vals, 'statement_operation_template_3') + vals['account_id'] = account_id + self._update('account.operation.template', 'account', vals, 'statement_operation_template_3') - diff --git a/addons/account/test/account_bank_statement.yml b/addons/account/test/account_bank_statement.yml index bd668e07a13..7043b1e2bab 100644 --- a/addons/account/test/account_bank_statement.yml +++ b/addons/account/test/account_bank_statement.yml @@ -6,10 +6,10 @@ - I select the period and journal for the bank statement - - !python {model: account.bank.statement}: | + !python {model: account.bank.statement, id: False}: | import time - journal = self._default_journal(cr, uid, {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu', - 'journal_type': 'bank', 'date': time.strftime("%Y/%m/%d")}) + journal = self.with_context({'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu', + 'journal_type': 'bank', 'date': time.strftime("%Y/%m/%d")})._default_journal() assert journal, 'Journal has not been selected' - I create a bank statement with Opening and Closing balance 0. @@ -20,9 +20,9 @@ date: !eval time.strftime('%Y-%m-%d') company_id: base.main_company - - !python {model: account.bank.statement.line}: | + !python {model: account.bank.statement.line, id: False}: | import time - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id.type', '=', 'liquidity'), ('currency_id', '=', False)])[0] + account_id = self.env['account.account'].search([('user_type_id.type', '=', 'liquidity'), ('currency_id', '=', False)], limit=1).id vals = { 'amount': 1000, 'date': time.strftime('%Y-%m-%d'), @@ -30,18 +30,18 @@ 'name': 'EXT001', 'statement_id': ref('account_bank_statement_0'), } - self.create(cr, uid, vals) + self.create(vals) - I process the bank statement line - - !python {model: account.bank.statement}: | - account_id = self.pool.get('account.account').create(cr, uid, {'name': 'toto', 'code': 'bidule', 'user_type_id': self.pool.get('ir.model.data').xmlid_to_res_id(cr, uid, 'account.data_account_type_fixed_assets')}) - statement = self.browse(cr, uid, [ref("account_bank_statement_0")]) + !python {model: account.bank.statement, id: False}: | + account = self.env['account.account'].create({'name': 'toto', 'code': 'bidule', 'user_type_id': self.env.ref('account.data_account_type_fixed_assets').id}) + statement = self.browse([ref("account_bank_statement_0")]) statement.line_ids[0].process_reconciliation(new_aml_dicts=[{ 'credit': 1000, 'debit': 0, 'name': 'toto', - 'account_id': account_id, + 'account_id': account.id, }]) - I modify the bank statement and set the Closing Balance. @@ -51,8 +51,8 @@ - I confirm the bank statement using Confirm button - - !python {model: account.bank.statement}: | - self.button_confirm_bank(cr, uid, [ref("account_bank_statement_0")]) + !python {model: account.bank.statement, id: False}: | + self.browse(ref("account_bank_statement_0")).button_confirm_bank() - I check that bank statement state is now "Closed" - diff --git a/addons/account/test/account_cash_statement.yml b/addons/account/test/account_cash_statement.yml index 9f0e81f97c7..af78c649dbf 100644 --- a/addons/account/test/account_cash_statement.yml +++ b/addons/account/test/account_cash_statement.yml @@ -44,9 +44,8 @@ - I clicked on Close CashBox button to close the cashbox - - !python {model: account.bank.statement}: | - self.button_confirm_cash(cr, uid, [ref("account_bank_statement_1")], {"lang": "en_US", "tz": False, "active_model": "account.bank.statement", "active_ids": [ref("account_bank_statement_1")], "active_id": ref("account_bank_statement_1"), }) - + !python {model: account.bank.statement, id: False}: | + self.browse(ref("account_bank_statement_1")).with_context({"lang": "en_US", "tz": False, "active_model": "account.bank.statement", "active_ids": [ref("account_bank_statement_1")], "active_id": ref("account_bank_statement_1"), }).button_confirm_cash() - I check that bank statement state is now "Closed" - diff --git a/addons/account/test/account_invoice_state.yml b/addons/account/test/account_invoice_state.yml index d7c00b8d461..91a6f9aa229 100644 --- a/addons/account/test/account_invoice_state.yml +++ b/addons/account/test/account_invoice_state.yml @@ -25,10 +25,10 @@ - I clicked on Confirm Invoices Button - - !python {model: account.invoice.confirm}: | - self.invoice_confirm(cr, uid, [ref("account_invoice_confirm_0")], {"lang": 'en_US', + !python {model: account.invoice.confirm, id: False}: | + self.browse(ref("account_invoice_confirm_0")).with_context({"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")], - "type": "out_invoice", "active_id": ref("account_invoice_state"), }) + "type": "out_invoice", "active_id": ref("account_invoice_state"), }).invoice_confirm() - I check that customer invoice state is "Open" - @@ -42,17 +42,17 @@ assert (len(moves) > 0), 'You should have multiple moves' moves[0].journal_id.write({'update_posted': True}) - - In order to check the "Cancel Selected Invoices" wizard in openerp I cancelled this open invoice using this wizard + In order to check the "Cancel Selected Invoices" wizard in odoo I cancelled this open invoice using this wizard - !record {model: account.invoice.cancel, id: account_invoice_cancel_0}: {} - I clicked on Cancel Invoices Button - - !python {model: account.invoice.cancel}: | - self.invoice_cancel(cr, uid, [ref("account_invoice_cancel_0")], {"lang": 'en_US', + !python {model: account.invoice.cancel, id: False}: | + self.browse(ref("account_invoice_cancel_0")).with_context({"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")], - "type": "out_invoice", "active_id": ref("account_invoice_state"), }) + "type": "out_invoice", "active_id": ref("account_invoice_state"), }).invoice_cancel() - I check that customer invoice is in the cancel state - diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml index b9f670f1095..7ea73c1dd75 100644 --- a/addons/account/test/account_report.yml +++ b/addons/account/test/account_report.yml @@ -12,60 +12,60 @@ - In order to test the PDF reports defined on an invoice, we will print an Invoice Report - - !python {model: account.invoice}: | + !python {model: account.invoice, id: False}: | import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('account.account_invoice_customer0')], 'account.report_invoice', {}, {}) + import odoo.report + from odoo import tools + data, format = odoo.report.render_report(self.env.cr, self.env.uid, [ref('account.account_invoice_customer0')], 'account.report_invoice', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data) - In order to test the PDF reports defined on a partner, we will print the Overdue Report - - !python {model: res.partner}: | + !python {model: res.partner, id: False}: | import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')], 'account.report_overdue', {}, {}) + import odoo.report + from odoo import tools + data, format = odoo.report.render_report(self.env.cr, self.env.uid, [ref('base.res_partner_1'),ref('base.res_partner_2'),ref('base.res_partner_12')], 'account.report_overdue', {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-report_overdue.'+format), 'wb+').write(data) - Print the Aged Partner Balance Report - - !python {model: account.account}: | + !python {model: account.account, id: False}: | ctx={} data_dict = {'chart_account_id':ref('account.chart0')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_aged_balance_view',wiz_data=data_dict, context=ctx, our_module='account') + from odoo.tools import test_reports + test_reports.try_report_action(self.env.cr, self.env.uid, 'action_account_aged_balance_view',wiz_data=data_dict, context=ctx, our_module='account') - Print the Account Balance Sheet in Normal mode - - !python {model: account.account}: | + !python {model: account.account, id: False}: | ctx={} data_dict = {'chart_account_id':ref('account.chart0'), 'account_report_id': ref('account_financial_report_balancesheet0')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') + from odoo.tools import test_reports + test_reports.try_report_action(self.env.cr, self.env.uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') - Print the Account Balance Report in Normal mode through the wizard - From Account Chart - - !python {model: account.account}: | + !python {model: account.account, id: False}: | ctx={} data_dict = {'chart_account_id':ref('account.chart0')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_balance_menu',wiz_data=data_dict, context=ctx, our_module='account') + from odoo.tools import test_reports + test_reports.try_report_action(self.env.cr, self.env.uid, 'action_account_balance_menu',wiz_data=data_dict, context=ctx, our_module='account') - Print the General Ledger Report (in Landscape Mode) - - !python {model: account.account}: | + !python {model: account.account, id: False}: | ctx={} data_dict = {'chart_account_id':ref('account.chart0')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_general_ledger_menu',wiz_data=data_dict, context=ctx, our_module='account') + from odoo.tools import test_reports + test_reports.try_report_action(self.env.cr, self.env.uid, 'action_account_general_ledger_menu',wiz_data=data_dict, context=ctx, our_module='account') - Print the Profit-Loss Report in Normal Mode - - !python {model: account.account}: | + !python {model: account.account, id: False}: | ctx={} data_dict = {'chart_account_id':ref('account.chart0'), 'target_move': 'all', 'account_report_id': ref('account_financial_report_balancesheet0')} - from openerp.tools import test_reports - test_reports.try_report_action(cr, uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') + from odoo.tools import test_reports + test_reports.try_report_action(self.env.cr, self.env.uid, 'action_account_report',wiz_data=data_dict, context=ctx, our_module='account') diff --git a/addons/account_asset/account_asset_demo.yml b/addons/account_asset/account_asset_demo.yml index 22cfc0cff35..89e0120ad58 100644 --- a/addons/account_asset/account_asset_demo.yml +++ b/addons/account_asset/account_asset_demo.yml @@ -1,34 +1,34 @@ - Creating demo data that require looking for accounts - - !python {model: ir.model.data} : | - company = self.pool.get('res.users').browse(cr, uid, uid).company_id - journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'general'), ('id', '!=', company.currency_exchange_journal_id.id)]) - expense_account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses'))]) - xfa_account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_fixed_assets'))]) + !python {model: ir.model.data, id: False} : | + company = self.env.user.company_id + journal_id = self.env['account.journal'].search([('type', '=', 'general'), ('id', '!=', company.currency_exchange_journal_id.id)], limit=1).id + expense_account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_expenses'))], limit=1).id + xfa_account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_fixed_assets'))], limit=1).id if not xfa_account_id: - xfa_account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_current_assets'))]) + xfa_account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_current_assets'))], limit=1).id from datetime import datetime, timedelta import time if xfa_account_id and expense_account_id and journal_id: vals = { - 'journal_id': journal_id[0], + 'journal_id': journal_id, 'name': 'Hardware - 3 Years', 'method_number': 3, - 'account_asset_id': xfa_account_id[0], - 'account_depreciation_id': xfa_account_id[0], - 'account_depreciation_expense_id': expense_account_id[0], + 'account_asset_id': xfa_account_id, + 'account_depreciation_id': xfa_account_id, + 'account_depreciation_expense_id': expense_account_id, } - self._update(cr, uid, 'account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets0') + self._update('account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets0') vals = { - 'journal_id': journal_id[0], + 'journal_id': journal_id, 'name': 'Cars - 5 Years', 'method_number': 5, - 'account_asset_id': xfa_account_id[0], - 'account_depreciation_id': xfa_account_id[0], - 'account_depreciation_expense_id': expense_account_id[0], + 'account_asset_id': xfa_account_id, + 'account_depreciation_id': xfa_account_id, + 'account_depreciation_expense_id': expense_account_id, } - self._update(cr, uid, 'account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets1') + self._update('account.asset.category', 'account_asset', vals, 'account_asset_category_fixedassets1') vals = { 'salvage_value': 2000.0, 'state': 'open', @@ -38,7 +38,7 @@ 'value': 12000.0, 'category_id': ref('account_asset_category_fixedassets0'), } - self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_vehicles0') + self._update('account.asset.asset', 'account_asset', vals, 'account_asset_asset_vehicles0') vals = { 'method_end': (datetime.now().replace(month=8, day=11) + timedelta(days=3*365)).strftime('%Y-%m-%d'), 'salvage_value': 0.0, @@ -47,7 +47,7 @@ 'value': 2800.0, 'category_id': ref('account_asset_category_fixedassets0'), } - self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_cab0') + self._update('account.asset.asset', 'account_asset', vals, 'account_asset_asset_cab0') vals = { 'prorata': 1, 'salvage_value': 100000.0, @@ -59,4 +59,4 @@ 'value': 500000.0, 'category_id': ref('account_asset_category_fixedassets0'), } - self._update(cr, uid, 'account.asset.asset', 'account_asset', vals, 'account_asset_asset_office0') + self._update('account.asset.asset', 'account_asset', vals, 'account_asset_asset_office0') diff --git a/addons/account_voucher/test/account_voucher.yml b/addons/account_voucher/test/account_voucher.yml index 727e5366443..df195e58d62 100644 --- a/addons/account_voucher/test/account_voucher.yml +++ b/addons/account_voucher/test/account_voucher.yml @@ -28,29 +28,6 @@ - !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: - state == 'draft' -# - -# I compute the voucher to calculate the taxes by clicking Compute button -# - -# !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0} - -# - -# I create voucher by clicking on Create button -# - -# !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0} -# - -# I clicked on Validate Button -# - -# !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: -# - state == 'posted' - -# - -# I check that Moves get created for this voucher -# - -# !python {model: account.voucher}: | -# acc_id=self.browse(cr, uid, ref("account_voucher_voucherforaxelor0")) -# assert(acc_id.move_id) - - - Now I create a Vendor Voucher - @@ -75,18 +52,3 @@ - !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: - state == 'draft' -# - -# I create voucher by clicking on Create button -# - -# !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucheraxelor0} -# - -# I check that the voucher state is "posted" -# - -# !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: -# - state == 'posted' -# - -# I check that moves get created for this voucher -# - -# !python {model: account.voucher}: | -# acc_id=self.browse(cr, uid, ref("account_voucher_voucheraxelor0")) -# assert(acc_id.move_id) diff --git a/addons/account_voucher/test/sales_receipt.yml b/addons/account_voucher/test/sales_receipt.yml index d9e4997f91b..d68930692bd 100644 --- a/addons/account_voucher/test/sales_receipt.yml +++ b/addons/account_voucher/test/sales_receipt.yml @@ -23,59 +23,3 @@ - !assert {model: account.voucher, id: account_voucher_seagate_0}: - state == 'draft' - -# - -# I click on post button to post the voucher -# - -# !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_seagate_0} - -# - -# Check that the voucher state is Posted -# - -# !assert {model: account.voucher, id: account_voucher_seagate_0}: -# - state == 'posted' -# - -# I check that move lines are validated but not reconciled -# - -# !python {model: account.voucher}: | -# reconciled = False -# for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: -# if l.reconcile_id: -# reconciled = True -# break -# assert (not reconciled), "Found reconciled move lines, should not be" -# - -# I create and post a voucher payment of amount 30000.0 for the partner Seagate -# - -# !python {model: account.voucher}: | -# import time -# vals = {} -# journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None) -# res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_2"), journal_id, 0.0, 1, ttype='receipt', date=False) -# vals = { -# 'account_id': ref('account.cash'), -# 'amount': 30000.0, -# 'company_id': ref('base.main_company'), -# 'journal_id': ref('account.bank_journal'), -# 'partner_id': ref('base.res_partner_2'), -# 'date': time.strftime("%Y-%m-%d"), -# 'voucher_type': 'receipt', -# } -# if not res['value']['line_cr_ids']: -# res['value']['line_cr_ids'] = [{'voucher_type': 'cr', 'account_id': ref('account.a_recv'),}] -# res['value']['line_cr_ids'][0]['amount'] = 30000.0 -# vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']] -# id = self.create(cr, uid, vals) -# voucher_id = self.browse(cr, uid, id) -# assert (voucher_id.state=='draft'), "Voucher is not in draft state" -# voucher_id.signal_workflow('proforma_voucher') -# - -# I check that move lines are reconciled meaning voucher is paid -# - -# !python {model: account.voucher}: | -# reconciled = False -# for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: -# if l.reconcile_id: -# reconciled = True -# break -# assert reconciled, "Found unreconciled move lines/unpaid voucher" diff --git a/addons/auth_oauth/data/auth_oauth_data.yml b/addons/auth_oauth/data/auth_oauth_data.yml index af43811a560..5ec3a53009b 100644 --- a/addons/auth_oauth/data/auth_oauth_data.yml +++ b/addons/auth_oauth/data/auth_oauth_data.yml @@ -1,6 +1,6 @@ - Use database uuid as client_id for OpenERP oauth provider - - !python {model: ir.config_parameter}: | - oauth = self.pool.get('auth.oauth.provider') - oauth.write(cr, uid, [ref('provider_openerp')], {'client_id': self.get_param(cr, uid, 'database.uuid')}) + !python {model: ir.config_parameter, id: False}: | + oauth = self.env['auth.oauth.provider'] + oauth.browse(ref('provider_openerp')).write({'client_id': self.get_param('database.uuid')}) diff --git a/addons/hr_recruitment/test/recruitment_process.yml b/addons/hr_recruitment/test/recruitment_process.yml index 4c8ed6f9276..142c10e4be2 100644 --- a/addons/hr_recruitment/test/recruitment_process.yml +++ b/addons/hr_recruitment/test/recruitment_process.yml @@ -20,19 +20,19 @@ - An applicant is interested in the job position. So he sends a resume by email. - - !python {model: mail.thread}: | - request_file = open(openerp.modules.module.get_module_resource('hr_recruitment','test', 'resume.eml'),'rb') - job_id = self.pool["ir.model.data"].xmlid_to_res_id(cr, uid, "hr.job_developer") + !python {model: mail.thread, id: False}: | + import odoo + request_file = open(odoo.modules.module.get_module_resource('hr_recruitment','test', 'resume.eml'),'rb') + job_id = self.env.ref('hr.job_developer').id request_message = request_file.read() - self.message_process(cr, uid, 'hr.applicant', request_message, custom_values={"job_id": job_id}) + self.message_process('hr.applicant', request_message, custom_values={"job_id": job_id}) - After getting the mail, I check the details of the new applicant. - - !python {model: hr.applicant}: | - applicant_ids = self.search(cr, uid, [('email_from','=', 'Mr. Richard Anderson <Richard_Anderson@yahoo.com>')]) - assert applicant_ids, "Applicant is not created after getting the mail" - applicant = self.browse(cr, uid, applicant_ids[0], context=context) - resume_ids = self.pool.get('ir.attachment').search(cr, uid, [('datas_fname','=','resume.pdf'),('res_model','=',self._name),('res_id','=',applicant.id)]) + !python {model: hr.applicant, id: False}: | + applicant = self.search([('email_from','=', 'Mr. Richard Anderson <Richard_Anderson@yahoo.com>')], limit=1) + assert applicant, "Applicant is not created after getting the mail" + resume_ids = self.env['ir.attachment'].search([('datas_fname','=','resume.pdf'),('res_model','=',self._name),('res_id','=',applicant.id)]) assert applicant.name == "Application for the post of Jr.application Programmer.", "Applicant name does not match." assert applicant.stage_id.id == ref('hr_recruitment.stage_job1'), "Stage should be 'Initial qualification' and is '%s'." % (applicant.stage_id.name) assert applicant.stage_id.sequence == 1, "Applicant stage sequence should be 1." @@ -40,16 +40,17 @@ - I assign the Job position to the applicant - - !python {model: hr.applicant}: | - self.write(cr, uid, [ref('hr_case_programmer')], {'job_id':ref('hr.job_developer')}) + !python {model: hr.applicant, id: hr_case_programmer}: | + self.write({'job_id':ref('hr.job_developer')}) - I schedule meeting with applicant for interview. - - !python {model: hr.applicant}: | - self.action_makeMeeting(cr, uid, [ref('hr_case_programmer')]) + !python {model: hr.applicant, id: hr_case_programmer}: | + self.action_makeMeeting() - I print Applicant fill up the interview quetion - - !python {model: hr.applicant}: | + !python {model: hr.applicant, id: False}: | + context = self.env.context.copy() context.update({'active_model': 'hr.applicant', 'active_ids': [ref("hr_recruitment.hr_case_programmer")], 'active_id': ref("hr_recruitment.hr_case_programmer")}) - self.action_print_survey(cr, uid, [ref('hr_case_programmer')]) + self.browse(ref('hr_case_programmer')).with_context(context).action_print_survey() diff --git a/addons/hr_timesheet/hr_timesheet_demo.yml b/addons/hr_timesheet/hr_timesheet_demo.yml index 4225d319f01..05138cece90 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.yml +++ b/addons/hr_timesheet/hr_timesheet_demo.yml @@ -1,7 +1,7 @@ - Creating demo data that require looking for accounts - - !python {model: ir.model.data} : | + !python {model: ir.model.data, id: False} : | from datetime import datetime from dateutil.relativedelta import relativedelta vals = { @@ -14,7 +14,7 @@ 'project_id': ref('project.project_project_2'), 'amount': -60.00, } - self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_requirements') + self._update('account.analytic.line', 'hr_timesheet', vals, 'working_hours_requirements') vals = { 'name': 'Design and specification', 'user_id': ref('base.user_root'), @@ -25,7 +25,7 @@ 'project_id': ref('project.project_project_2'), 'amount': -30.00, } - self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_design') + self._update('account.analytic.line', 'hr_timesheet', vals, 'working_hours_design') vals = { 'name': 'Coding and module testing', 'user_id': ref('base.user_root'), @@ -36,7 +36,7 @@ 'project_id': ref('project.project_project_2'), 'amount': -90.00, } - self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_coding') + self._update('account.analytic.line', 'hr_timesheet', vals, 'working_hours_coding') vals = { 'name': 'Integration and system testing', 'user_id': ref('base.user_root'), @@ -47,7 +47,7 @@ 'project_id': ref('project.project_project_2'), 'amount': -30.00, } - self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_testing') + self._update('account.analytic.line', 'hr_timesheet', vals, 'working_hours_testing') vals = { 'name': 'Delivery and maintenance', 'user_id': ref('base.user_root'), @@ -58,4 +58,4 @@ 'project_id': ref('project.project_project_2'), 'amount': -30.00, } - self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_maintenance') + self._update('account.analytic.line', 'hr_timesheet', vals, 'working_hours_maintenance') diff --git a/addons/l10n_fr/test/l10n_fr_report.yml b/addons/l10n_fr/test/l10n_fr_report.yml index 7038887ef52..aaff326624d 100644 --- a/addons/l10n_fr/test/l10n_fr_report.yml +++ b/addons/l10n_fr/test/l10n_fr_report.yml @@ -1,11 +1,11 @@ - In order to test the PDF reports defined on a l10n_fr, we will print an Account Move Line Report for l10n_fr - - !python {model: account.move.line}: | + !python {model: account.move.line, id: False}: | import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [], 'l10n_fr.report_l10nfrbilan', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {}) + import odoo.report + from odoo import tools + data, format = odoo.report.render_report(self.env.cr, self.env.uid, [], 'l10n_fr.report_l10nfrbilan', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'l10n_fr-bilan_report.'+format), 'wb+').write(data) @@ -14,8 +14,8 @@ - !python {model: account.move.line}: | import os - import openerp.report - from openerp import tools - data, format = openerp.report.render_report(cr, uid, [], 'l10n_fr.report_l10nfrresultat', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {}) + import odoo.report + from odoo import tools + data, format = odoo.report.render_report(self.env.cr, self.env.uid, [], 'l10n_fr.report_l10nfrresultat', {'model':'account.move.line', 'form':{'fiscalyear_id': ref('account.data_fiscalyear')}}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'l10n_fr-compute_resultant_report.'+format), 'wb+').write(data) diff --git a/addons/mrp/data/mrp_data.yml b/addons/mrp/data/mrp_data.yml index 7ec1c12bb98..cc69bbe175b 100644 --- a/addons/mrp/data/mrp_data.yml +++ b/addons/mrp/data/mrp_data.yml @@ -1,13 +1,13 @@ - - !python {model: ir.model.data}: | - warehouse = self.pool['stock.warehouse'].browse(cr, uid, ref('stock.warehouse0'), context=context) + !python {model: ir.model.data, id: False}: | + warehouse = self.env['stock.warehouse'].browse(ref('stock.warehouse0')) #create xml ids for demo data that are widely used in tests or in other codes, for more convenience xml_references = [ {'name':'picking_type_manufacturing','module':'mrp', 'model':'stock.picking.type','res_id': warehouse.manu_type_id.id}, ] for xml_record in xml_references: - xml_ids = self.search(cr, uid, [('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])], context=context) + xml_ids = self.search([('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])]).ids if not xml_ids: - self.create(cr, uid, xml_record, context=context) + self.create(xml_record) #avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it - self._update_dummy(cr, uid, xml_record['model'], xml_record['module'], xml_record['name'])
\ No newline at end of file + self._update_dummy(xml_record['model'], xml_record['module'], xml_record['name'])
\ No newline at end of file diff --git a/addons/mrp/data/mrp_lot_demo.yml b/addons/mrp/data/mrp_lot_demo.yml index e15eb6d5af5..d591ca89fd3 100644 --- a/addons/mrp/data/mrp_lot_demo.yml +++ b/addons/mrp/data/mrp_lot_demo.yml @@ -1,14 +1,12 @@ - - !python {model: mrp.production}: | - mo = self.browse(cr, uid, ref('mrp_production_laptop_cust'), context=context) - if mo.state != 'done': - mo.action_assign() - wiz_obj = self.pool['mrp.product.produce'] - ctx = dict(context, active_id=mo.id) - wiz_id = wiz_obj.create(cr, uid, {'product_qty': mo.product_qty, 'lot_id': ref('lot_product_27_0')}, context=ctx) - produce_wiz = wiz_obj.browse(cr, uid, wiz_id,context=ctx) + !python {model: mrp.production, id: mrp_production_laptop_cust}: | + if self.state != 'done': + self.action_assign() + wiz_obj = self.env['mrp.product.produce'] + ctx = dict(self.env.context, active_id=self.id) + produce_wiz = wiz_obj.with_context(ctx).create({'product_qty': self.product_qty, 'lot_id': ref('lot_product_27_0')}) produce_wiz.consume_line_ids.write({'quantity_done': produce_wiz.product_qty}) #Produce Product,Post Inventory and Set MO Done. produce_wiz.do_produce() - mo.post_inventory() - mo.button_mark_done() + self.post_inventory() + self.button_mark_done() diff --git a/addons/mrp_byproduct/test/mrp_byproduct.yml b/addons/mrp_byproduct/test/mrp_byproduct.yml index d52dc512e6a..7e02783f0fb 100644 --- a/addons/mrp_byproduct/test/mrp_byproduct.yml +++ b/addons/mrp_byproduct/test/mrp_byproduct.yml @@ -25,8 +25,8 @@ - I compute the data of production order. - - !python {model: mrp.production}: | - self.action_compute(cr, uid, [ref("mrp_production_mo0")], {"active_ids": [ref("mrp_production_mo0")],"active_id": ref("mrp_production_mo0")}) + !python {model: mrp.production, id: mrp_production_mo0}: | + self.with_context({"active_ids": [ref("mrp_production_mo0")],"active_id": ref("mrp_production_mo0")}).action_compute() - I confirm the production order. - @@ -40,16 +40,16 @@ Now I check the stock moves for the byproduct I created in the bill of material. This move is created automatically when I confirmed the production order. - - !python {model: stock.move}: | - production_order = self.pool.get('mrp.production').browse(cr, uid, ref("mrp_production_mo0")) - move_ids = self.search(cr, uid, [('origin','=',production_order.name), ('product_id','=',ref('product.product_delivery_01'))]) - assert move_ids, 'No moves are created !' - assert self.browse(cr, uid, move_ids).product_uom_qty == 3, "Incorrect quantity for byproduct move" + !python {model: stock.move, id: False}: | + production_order = self.env['mrp.production'].browse(ref("mrp_production_mo0")) + move = self.search([('origin','=',production_order.name), ('product_id','=',ref('product.product_delivery_01'))], limit=1) + assert move, 'No move are created !' + assert move.product_uom_qty == 3, "Incorrect quantity for byproduct move" - I want to start the production so I force the reservation of products. - - !python {model: mrp.production}: | - self.force_production(cr, uid, [ref("mrp_production_mo0")], {"active_ids":[ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),}) + !python {model: mrp.production, id: mrp_production_mo0}: | + self.with_context({"active_ids":[ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),}).force_production() - I start the production. - @@ -65,17 +65,15 @@ - I finish the production order. - - !python {model: mrp.product.produce}: | + !python {model: mrp.product.produce, id: mrp_product_produce0}: | ctx = context.copy() - ctx['active_id'] = ref("mrp_production_mo0") - self.on_change_qty(cr, uid, [ref('mrp_product_produce0')], context=ctx) - self.do_produce(cr, uid, [ref("mrp_product_produce0")], {"active_model": "mrp.production", "active_ids":[ref("mrp_production_mo0")], "active_id": ref("mrp_production_mo0")}) + ctx['active_id'] = self.id + self.with_context(ctx).on_change_qty() + self.with_context({"active_model": "mrp.production", "active_ids":[ref("mrp_production_mo0")], "active_id": ref("mrp_production_mo0")}).do_produce() - I see that stock moves of External Hard Disk including Headset USB are done now. - - !python {model: stock.move}: | - production_order = self.pool.get('mrp.production').browse(cr, uid, ref("mrp_production_mo0")) - move_ids = self.search(cr, uid, [('origin','=',production_order.name), ('product_id','in',[ref("product.product_delivery_02"),ref("product.product_delivery_01")])]) - moves = self.browse(cr, uid, move_ids) - assert all(move.state == 'done' for move in moves), 'Moves are not done!' - + !python {model: stock.move, id: False}: | + production_order = self.env['mrp.production'].browse(ref("mrp_production_mo0")) + moves = self.search([('origin','=',production_order.name), ('product_id','in',[ref("product.product_delivery_02"),ref("product.product_delivery_01")])]) + assert all(moves.state == 'done' for moves in moves), 'Moves are not done diff --git a/addons/product_margin/test/product_margin.yml b/addons/product_margin/test/product_margin.yml index 9252fdd52b8..0f080391fa8 100644 --- a/addons/product_margin/test/product_margin.yml +++ b/addons/product_margin/test/product_margin.yml @@ -8,18 +8,18 @@ - I open margin for PC-DEM - - !python {model: product.margin}: | - self.action_open_window(cr, uid, [ref("product_margin_wiz0")], {"lang": 'en_US', + !python {model: product.margin, id: False}: | + self.browse(ref('product_margin_wiz0')).with_context({"lang": 'en_US', "search_default_filter_to_sell": "1", "tz": False, "active_model": "product.product", "disable_log": True, - "active_ids": [ref("product.product_product_5")], "active_id": ref("product.product_product_5")}) + "active_ids": [ref("product.product_product_5")], "active_id": ref("product.product_product_5")}).action_open_window() - I read the fields of the product. - - !python {model: product.product}: | + !python {model: product.product, id: False}: | fields = ['sale_avg_price', 'expected_margin_rate', 'total_margin_rate', 'total_cost', 'sale_num_invoiced', 'total_margin', 'sales_gap', 'purchase_num_invoiced', 'expected_margin', 'turnover'] - self.read(cr, uid, [ref("product_margin_wiz0")], fields, {"lang": 'en_US', + self.browse(ref('product_margin_wiz0')).with_context({"lang": 'en_US', "search_default_filter_to_sell": "1", "tz": False, "active_model": "product.product", "bin_size": True, "active_ids": [ref("product.product_product_5")], - "active_id": ref("product.product_product_5")}) + "active_id": ref("product.product_product_5")}).read(fields) diff --git a/addons/sale/sale_demo.yml b/addons/sale/sale_demo.yml index 1e31d88448b..e405cebc04e 100644 --- a/addons/sale/sale_demo.yml +++ b/addons/sale/sale_demo.yml @@ -1,35 +1,35 @@ - - !python {model: ir.model.data} : | - journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale')]) - account_recv_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_receivable'))]) - account_sale_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', 'in', [ref('account.account_tag_operating')])]) + !python {model: ir.model.data, id: False} : | + journal_id = self.env['account.journal'].search([('type', '=', 'sale')], limit=1).id + account_recv_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_receivable'))], limit=1).id + account_sale_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', 'in', [ref('account.account_tag_operating')])], limit=1).id if not account_sale_id: - account_sale_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue'))] + account_sale_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_revenue'))], limit=1).id if journal_id and account_recv_id: vals = { 'currency': ref('base.EUR'), 'company_id': ref('base.main_company'), 'partner_id': ref('base.res_partner_1'), - 'journal_id': journal_id[0], + 'journal_id': journal_id, 'team_id': ref('sales_team.team_sales_department'), 'state': 'draft', 'type': 'out_invoice', - 'account_id': account_recv_id[0], + 'account_id': account_recv_id, 'name': 'Test invoice 1', } - self._update(cr, uid, 'account.invoice', 'sale', vals, 'test_crm_sale_invoice_1') + self._update('account.invoice', 'sale', vals, 'test_crm_sale_invoice_1') vals = { 'currency': ref('base.EUR'), 'company_id': ref('base.main_company'), 'partner_id': ref('base.res_partner_1'), - 'journal_id': journal_id[0], + 'journal_id': journal_id, 'team_id': ref('sales_team.crm_team_1'), 'state': 'draft', 'type': 'out_invoice', - 'account_id': account_recv_id[0], + 'account_id': account_recv_id, 'name': 'Test invoice 2', } - self._update(cr, uid, 'account.invoice', 'sale', vals, 'test_crm_sale_invoice_2') + self._update('account.invoice', 'sale', vals, 'test_crm_sale_invoice_2') if account_sale_id: vals = { 'name': '', @@ -37,41 +37,41 @@ 'invoice_id': ref('test_crm_sale_invoice_1'), 'price_unit': 250, 'quantity': 1, - 'account_id': account_sale_id[0], + 'account_id': account_sale_id, } - self._update(cr, uid, 'account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_1') + self._update('account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_1') vals = { 'name': '', 'product_id': ref('product.consu_delivery_02'), 'invoice_id': ref('test_crm_sale_invoice_1'), 'price_unit': 800, 'quantity': 2, - 'account_id': account_sale_id[0], + 'account_id': account_sale_id, } - self._update(cr, uid, 'account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_2') + self._update('account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_2') vals = { 'name': '', 'product_id': ref('product.consu_delivery_01'), 'invoice_id': ref('test_crm_sale_invoice_1'), 'price_unit': 4800, 'quantity': 4, - 'account_id': account_sale_id[0], + 'account_id': account_sale_id, } - self._update(cr, uid, 'account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_3') + self._update('account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_1_line_3') vals = { 'name': '', 'product_id': ref('product.consu_delivery_01'), 'invoice_id': ref('test_crm_sale_invoice_2'), 'price_unit': 500, 'quantity': 1, - 'account_id': account_sale_id[0], + 'account_id': account_sale_id, } - self._update(cr, uid, 'account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_2_line_1') - self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('test_crm_sale_invoice_1')], 'invoice_open') - self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('test_crm_sale_invoice_2')], 'invoice_open') - bank_journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank')]) + self._update('account.invoice.line', 'sale', vals, 'test_crm_sale_invoice_2_line_1') + self.env['account.invoice'].browse(ref('test_crm_sale_invoice_1')).signal_workflow('invoice_open') + self.env['account.invoice'].browse(ref('test_crm_sale_invoice_2')).signal_workflow('invoice_open') + bank_journal_id = self.env['account.journal'].search([('type', '=', 'bank')], limit=1).id if bank_journal_id: - bank_journal_id = bank_journal_id[0] - self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [ref('test_crm_sale_invoice_1')], bank_journal_id[0], 1850) - self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [ref('test_crm_sale_invoice_2')], bank_journal_id[0], 500) + bank_journal_id = bank_journal_id + self.env['account.invoice'].browse(ref('test_crm_sale_invoice_1')).pay_and_reconcile(bank_journal_id[0], 1850) + self.env['account.invoice'].browse(ref('test_crm_sale_invoice_2')).pay_and_reconcile(bank_journal_id[0], 500) - diff --git a/addons/sale_mrp/test/cancellation_propagated.yml b/addons/sale_mrp/test/cancellation_propagated.yml index 84c4dc40296..f4471a2c290 100644 --- a/addons/sale_mrp/test/cancellation_propagated.yml +++ b/addons/sale_mrp/test/cancellation_propagated.yml @@ -32,10 +32,10 @@ - And set routes on product to be MTO and manufacture - - !python {model: product.product}: | - route_warehouse0_manufacture = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).manufacture_pull_id.route_id.id - route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id - self.write(cr, uid, ref('product_manu'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_manufacture])]}, context=context) + !python {model: product.product, id: product_manu}: | + route_warehouse0_manufacture_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).manufacture_pull_id.route_id.id + route_warehouse0_mto_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).mto_pull_id.route_id.id + self.write({'route_ids': [(6, 0, [route_warehouse0_mto_id, route_warehouse0_manufacture_id])]}) - I create a sales order - @@ -53,13 +53,13 @@ - Confirm sales order - - !python {model: sale.order}: | - self.action_confirm(cr, uid, [ref("sale_order_product_manu")], context=context) + !python {model: sale.order, id: sale_order_product_manu}: | + self.action_confirm() - I run scheduler. - - !python {model: procurement.order}: | - self.run_scheduler(cr, uid) + !python {model: procurement.order, id: False}: | + self.run_scheduler() - Check the propagation when we cancel the main procurement * Retrieve related procurements and check that there are all running @@ -67,30 +67,30 @@ * Cancel the main procurement * Check that all procurements related and the purchase order has been well cancelled - - !python {model: procurement.order}: | + !python {model: procurement.order, id: False}: | # Retrieve related procu - so = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_product_manu')) - procu_ids = self.search(cr, uid, [('group_id.name', '=', so.name)]) - assert len(procu_ids)>0, 'No procurements are found for sale order "%s" (with id : %d)' %(so.name, so.id) + so = self.env['sale.order'].browse(ref('sale_order_product_manu')) + procus = self.search([('group_id.name', '=', so.name)]) + assert len(procus.ids)>0, 'No procurements are found for sale order "%s" (with id : %d)' %(so.name, so.id) # Check that all procurements are running - for procu in self.browse(cr, uid, procu_ids, context=context): + for procu in procus: assert procu.state == u'running', 'Procurement with id %d should be "running" but is with a state : %s!' %(procu.id, procu.state) # Check that one production order exist - prodor_ids = [proc.production_id for proc in self.browse(cr, uid, procu_ids) if proc.production_id] + prodor_ids = [proc.production_id for proc in procus if proc.production_id] assert len(prodor_ids) > 0, 'No production order found !' # Cancel the main procurement - main_procu_id = self.search(cr, uid, [('origin', '=', so.name)]) - assert len(main_procu_id) == 1, 'Main procurement not identified !' - self.cancel(cr, uid, main_procu_id,context=context) - assert self.browse(cr, uid, main_procu_id[0]).state == u'cancel', 'Main procurement should be cancelled !' + main_procu = self.search([('origin', '=', so.name)]) + assert len(main_procu.ids) == 1, 'Main procurement not identified !' + main_procu.cancel() + assert main_procu[0].state == u'cancel', 'Main procurement should be cancelled !' # Check that all procurements related are cancelled - for procu in self.browse(cr, uid, procu_ids, context=context): + for procu in procus: assert procu.state == u'cancel', 'Procurement with id %d should be with the state "cancel" but is with a state : %s!' %(procu.id, procu.state) # Check that the production order is cancelled - for prodor in self.pool.get('mrp.production').browse(cr, uid, [prodor.id for prodor in prodor_ids], context=context): + for prodor in self.env['mrp.production'].browse([prodor.id for prodor in prodor_ids]): assert prodor.state == u'cancel', 'Production order %d should be cancelled but is in state : %s!' %(prodor.id, prodor.state) diff --git a/addons/sale_mrp/test/sale_mrp.yml b/addons/sale_mrp/test/sale_mrp.yml index f87946fd8cf..6a155be42ed 100644 --- a/addons/sale_mrp/test/sale_mrp.yml +++ b/addons/sale_mrp/test/sale_mrp.yml @@ -39,10 +39,10 @@ - I add the routes manufacture and mto to the product - - !python {model: product.product}: | - route_warehouse0_manufacture = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).manufacture_pull_id.route_id.id - route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id - self.write(cr, uid, ref('product_product_slidermobile0'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_manufacture])]}, context=context) + !python {model: product.product, id: product_product_slidermobile0}: | + route_warehouse0_manufacture_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).manufacture_pull_id.route_id.id + route_warehouse0_mto_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).mto_pull_id.route_id.id + self.write({'route_ids': [(6, 0, [route_warehouse0_mto_id,route_warehouse0_manufacture_id])]}) - I create a Bill of Material record for Slider Mobile - @@ -77,42 +77,36 @@ - I confirm the sale order - - !python {model: sale.order}: | - self.action_confirm(cr, uid, [ref("sale_order_so0")], context=context) + !python {model: sale.order, id: sale_order_so0}: | + self.action_confirm() - I verify that a procurement has been generated for sale order - - !python {model: procurement.order}: | - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - proc_ids = self.search(cr, uid, [('origin','=',so.name)]) - assert proc_ids, 'No Procurements!' + !python {model: procurement.order, id: False}: | + so = self.env['sale.order'].browse(ref("sale_order_so0")) + procs = self.search([('origin','=',so.name)]) + assert procs, 'No Procurements!' - Then I click on the "Run Procurement" button - - !python {model: procurement.order}: | - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - proc_ids = self.search(cr, uid, [('origin','like',so.name)]) - self.run(cr, uid, proc_ids) + !python {model: procurement.order, id: False}: | + so = self.env['sale.order'].browse(ref("sale_order_so0")) + procs = self.search([('origin','like',so.name)]) + procs.run() - I verify that a procurement state is "running" - - !python {model: procurement.order}: | - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - proc_ids = self.search(cr, uid, [('origin','like',so.name)]) + !python {model: procurement.order, id: False}: | + so = self.env['sale.order'].browse(ref("sale_order_so0")) + procs = self.search([('origin','like',so.name)]) # Check that all procurement are running - for procu in self.browse(cr,uid,proc_ids,context=context): + for procu in procs: assert procu.state == u'running', 'Procurement with id %d should be with a state "running" but is with a state : %s!' %(procu.id,procu.state) - I verify that a manufacturing order has been generated, and that its name and reference are correct - - !python {model: sale.order}: | - mnf_obj = self.pool.get('mrp.production') - so = self.browse(cr, uid, ref("sale_order_so0")) - mnf_id = mnf_obj.search(cr, uid, [('origin','like',so.name)]) - assert mnf_id, 'Manufacturing order has not been generated' - mo = mnf_obj.browse(cr, uid, mnf_id)[0] - assert mo.sale_name == so.name, 'Wrong Name for the Manufacturing Order. Expected %s, Got %s' % (so.name, mo.sale_name) - assert mo.sale_ref == so.client_order_ref, 'Wrong Sale Reference for the Manufacturing Order' + !python {model: sale.order, id: sale_order_so0}: | + mo = self.env['mrp.production'].search([('origin','like',self.name)], limit=1) + assert mo, 'Manufacturing order has not been generated' + assert mo.sale_name == self.name, 'Wrong Name for the Manufacturing Order. Expected %s, Got %s' % (self.name, mo.sale_name) + assert mo.sale_ref == self.client_order_ref, 'Wrong Sale Reference for the Manufacturing Order' diff --git a/addons/stock/data/stock_data.yml b/addons/stock/data/stock_data.yml index ebcc74bd24f..bf419b360fc 100644 --- a/addons/stock/data/stock_data.yml +++ b/addons/stock/data/stock_data.yml @@ -1,11 +1,11 @@ - - !python {model: res.partner}: | - main_warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('warehouse0'), context=context) - self.write(cr, uid, ref('base.main_partner'), {'property_stock_customer':main_warehouse.lot_stock_id.id}) + !python {model: res.partner, id: base.main_partner}: | + main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0')) + self.write({'property_stock_customer':main_warehouse.lot_stock_id.id}) - - !python {model: ir.model.data}: | - main_warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('warehouse0'), context=context) + !python {model: ir.model.data, id: False}: | + main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0')) #create xml ids for demo data that are widely used in tests or in other codes, for more convenience xml_references = [ @@ -18,16 +18,16 @@ {'name':'picking_type_out','module':'stock', 'model':'stock.picking.type','res_id':main_warehouse.out_type_id.id}, ] for xml_record in xml_references: - xml_ids = self.search(cr, uid, [('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])], context=context) + xml_ids = self.search([('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])]).ids if not xml_ids: - self.create(cr, uid, xml_record, context=context) + self.create(xml_record) #avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it - self._update_dummy(cr, uid, xml_record['model'], xml_record['module'], xml_record['name']) + self._update_dummy(xml_record['model'], xml_record['module'], xml_record['name']) - - !python {model: res.company}: | + !python {model: res.company, id: False}: | #create the transit location for each company existing - company_ids = self.search(cr, uid, [('internal_transit_location_id', '=', False)], context=context) - for company in self.browse(cr, uid, company_ids, context=context): - self.create_transit_location(cr, uid, [company.id], context=context) + companies = self.search([('internal_transit_location_id', '=', False)]) + for company in companies: + company.create_transit_location() diff --git a/addons/stock/data/stock_demo.yml b/addons/stock/data/stock_demo.yml index 3c83076a0db..13d82adf10b 100644 --- a/addons/stock/data/stock_demo.yml +++ b/addons/stock/data/stock_demo.yml @@ -1,6 +1,6 @@ - - !python {model: ir.model.data}: | - chicago_warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock_warehouse_shop0'), context=context) + !python {model: ir.model.data, id: False}: | + chicago_warehouse = self.env['stock.warehouse'].browse(ref('stock_warehouse_shop0')) #create xml ids for demo data that are widely used in tests or in other codes, for more convenience xml_references = [ @@ -9,11 +9,11 @@ {'name':'stock_location_shop0','module':'stock', 'model':'stock.location','res_id': chicago_warehouse.lot_stock_id.id}, ] for xml_record in xml_references: - xml_ids = self.search(cr, uid, [('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])], context=context) + xml_ids = self.search([('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])]).ids if not xml_ids: - self.create(cr, uid, xml_record, context=context) + self.create(xml_record) #avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it - self._update_dummy(cr, uid, xml_record['model'], xml_record['module'], xml_record['name']) + self._update_dummy(xml_record['model'], xml_record['module'], xml_record['name']) - !record {model: stock.location, id: location_refrigerator_small}: name: Small Refrigerator @@ -331,11 +331,31 @@ location_id: stock.stock_location_shop0 location_dest_id: stock.stock_location_customers - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('outgoing_shipment_main_warehouse'),ref('outgoing_shipment_main_warehouse1'),ref('incomming_shipment2'),ref('incomming_shipment1'),ref('incomming_shipment3'),ref('outgoing_chicago_warehouse3'),ref('outgoing_chicago_warehouse2'),ref('outgoing_chicago_warehouse1'),ref('incomming_chicago_warehouse1'),ref('incomming_chicago_warehouse2'),ref('incomming_chicago_warehouse3')], context=context) - record = self.browse(cr, uid, ref('outgoing_shipment_main_warehouse1'), context=context) - record_chi_in = self.browse(cr, uid, ref('incomming_chicago_warehouse1'), context=context) - record_chi_out = self.browse(cr, uid, ref('outgoing_chicago_warehouse1'), context=context) + !python {model: stock.picking, id: False}: | + self.browse([ + ref('outgoing_shipment_main_warehouse'), + ref('outgoing_shipment_main_warehouse1'), + ref('incomming_shipment2'), + ref('incomming_shipment1'), + ref('incomming_shipment3'), + ref('outgoing_chicago_warehouse3'), + ref('outgoing_chicago_warehouse2'), + ref('outgoing_chicago_warehouse1'), + ref('incomming_chicago_warehouse1'), + ref('incomming_chicago_warehouse2'), + ref('incomming_chicago_warehouse3') + ]).action_confirm() + record = self.browse(ref('outgoing_shipment_main_warehouse1')) + record_chi_in = self.browse(ref('incomming_chicago_warehouse1')) + record_chi_out = self.browse(ref('outgoing_chicago_warehouse1')) if record.state != 'done' and record_chi_in.state != 'done' and record_chi_out.state != 'done': - self.force_assign(cr, uid, [ref('outgoing_shipment_main_warehouse'),ref('outgoing_chicago_warehouse3'),ref('outgoing_shipment_main_warehouse2')], context=context) - self.do_transfer(cr, uid, [ref('outgoing_shipment_main_warehouse1'),ref('incomming_chicago_warehouse1'),ref('outgoing_chicago_warehouse1')], context=context) + self.browse([ + ref('outgoing_shipment_main_warehouse'), + ref('outgoing_chicago_warehouse3'), + ref('outgoing_shipment_main_warehouse2') + ]).force_assign() + self.browse([ + ref('outgoing_shipment_main_warehouse1'), + ref('incomming_chicago_warehouse1'), + ref('outgoing_chicago_warehouse1') + ]).do_transfer() diff --git a/addons/stock/data/stock_demo_pre.yml b/addons/stock/data/stock_demo_pre.yml index c752ebc28da..bcec8635444 100644 --- a/addons/stock/data/stock_demo_pre.yml +++ b/addons/stock/data/stock_demo_pre.yml @@ -9,6 +9,9 @@ posx: 0 - - !python {model: ir.model.data}: | - main_warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('warehouse0'), context=context) - self.pool.get('stock.location').write(cr, uid, [ref('stock_location_14'), ref('stock_location_components')], {'location_id':main_warehouse.lot_stock_id.id}, context=context) + !python {model: ir.model.data, id: False}: | + main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0')) + self.env['stock.location'].browse([ + ref('stock_location_14'), + ref('stock_location_components') + ]).write({'location_id':main_warehouse.lot_stock_id.id}) diff --git a/addons/stock/data/stock_orderpoint_demo.yml b/addons/stock/data/stock_orderpoint_demo.yml index 3c4eb6e9961..7cd42b4fe8f 100644 --- a/addons/stock/data/stock_orderpoint_demo.yml +++ b/addons/stock/data/stock_orderpoint_demo.yml @@ -1,6 +1,6 @@ - - !python {model: stock.location}: | - main_warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('warehouse0'), context=context) + !python {model: stock.location, id: False}: | + main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0')) main_stock = main_warehouse.lot_stock_id.id - stowar_op_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [], context=context) - self.pool.get('stock.warehouse.orderpoint').write(cr,uid,stowar_op_ids,{'location_id':main_stock}, context=context) + stowar_ops = self.env['stock.warehouse.orderpoint'].search([]) + stowar_ops.write({'location_id':main_stock}) diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml index 155bab2f388..42538398312 100644 --- a/addons/stock/test/packing.yml +++ b/addons/stock/test/packing.yml @@ -28,55 +28,70 @@ - Confirm and assign picking and prepare partial - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('pick1')], context=context) - self.do_prepare_partial(cr, uid, [ref('pick1')], context=context) + !python {model: stock.picking, id: pick1}: | + self.action_confirm() + self.do_prepare_partial() - Put 120 pieces on Pallet 1 (package), 120 pieces on Pallet 2 with lot A and 60 pieces on Pallet 3 - - !python {model: stock.picking}: | + !python {model: stock.picking, id: pick1}: | #Change quantity of first to 120 and create 2 others quant operations - record = self.browse(cr, uid, ref('pick1'), context=context) - stock_pack = self.pool.get('stock.pack.operation') - stock_quant_pack = self.pool.get('stock.quant.package') + stock_pack = self.env['stock.pack.operation'] + stock_quant_pack = self.env['stock.quant.package'] #create lot A - lot_a = self.pool.get('stock.production.lot').create(cr, uid, {'name': 'Lot A', 'product_id': ref('product1')}, context=context) + lot_a = self.env['stock.production.lot'].create({'name': 'Lot A', 'product_id': ref('product1')}) #create package - package1 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 1'}, context=context) - package2 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 2'}, context=context) - package3 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 3'}, context=context) + package1 = stock_quant_pack.create({'name': 'Pallet 1'}) + package2 = stock_quant_pack.create({'name': 'Pallet 2'}) + package3 = stock_quant_pack.create({'name': 'Pallet 3'}) #Create package for each line and assign it as result_package_id #create pack operation - stock_pack.write(cr, uid, record.pack_operation_ids[0].id, {'result_package_id': package1, 'product_qty': 120}) - new_pack1 = stock_pack.create(cr, uid, {'product_id': ref('product1'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1'), 'pack_lot_ids': [(0, 0, {'lot_id': lot_a, 'qty': 120})], 'result_package_id': package2, 'product_qty': 120, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_stock')}, context=context) - new_pack2 = stock_pack.create(cr, uid, {'product_id': ref('product1'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1'), 'result_package_id': package3, 'product_qty': 60, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_stock')}, context=context) + self.pack_operation_ids[0].write({'result_package_id': package1.id, 'product_qty': 120}) + new_pack1 = stock_pack.create({ + 'product_id': ref('product1'), + 'product_uom_id': ref('product.product_uom_unit'), + 'picking_id': ref('pick1'), + 'pack_lot_ids': [(0, 0, {'lot_id': lot_a.id, 'qty': 120})], + 'result_package_id': package2.id, + 'product_qty': 120, + 'location_id': ref('stock_location_suppliers'), + 'location_dest_id': ref('stock_location_stock') + }) + new_pack2 = stock_pack.create({ + 'product_id': ref('product1'), + 'product_uom_id': ref('product.product_uom_unit'), + 'picking_id': ref('pick1'), + 'result_package_id': package3.id, + 'product_qty': 60, + 'location_id': ref('stock_location_suppliers'), + 'location_dest_id': ref('stock_location_stock') + }) - Transfer the receipt - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('pick1')], context=context) + !python {model: stock.picking, id: pick1}: | + self.do_transfer() - Check the system created 3 quants one with 120 pieces on pallet 1, one with 120 pieces on pallet 2 with lot A and 60 pieces on pallet 3 - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product1'))], context=context) - assert len(reco_id) == 3, "The number of quants created is not correct" - for rec in self.browse(cr, uid, reco_id, context=context): - if rec.package_id.name == 'Pallet 1': - assert rec.qty == 120, "Should have 120 pieces on pallet 1" - elif rec.package_id.name == 'Pallet 2': - assert rec.qty == 120, "Should have 120 pieces on pallet 2" - elif rec.package_id.name == 'Pallet 3': - assert rec.qty == 60, "Should have 60 pieces on pallet 3" + !python {model: stock.quant, id: False}: | + quants = self.search([('product_id','=',ref('product1'))]) + assert len(quants.ids) == 3, "The number of quants created is not correct" + for quant in quants: + if quant.package_id.name == 'Pallet 1': + assert quant.qty == 120, "Should have 120 pieces on pallet 1" + elif quant.package_id.name == 'Pallet 2': + assert quant.qty == 120, "Should have 120 pieces on pallet 2" + elif quant.package_id.name == 'Pallet 3': + assert quant.qty == 60, "Should have 60 pieces on pallet 3" - Check there is no backorder or extra moves created - - !python {model: stock.picking}: | - picking = self.browse(cr, uid, ref('pick1'), context=context) - backorder = self.search(cr, uid, [('backorder_id', '=', ref('pick1'))]) + !python {model: stock.picking, id: pick1}: | + backorder = self.search([('backorder_id', '=', ref('pick1'))]) assert not backorder, "" #Check extra moves created - assert len(picking.move_lines) == 1, "" + assert len(self.move_lines) == 1, "" - Make a delivery order of 300 pieces to the customer - @@ -92,33 +107,41 @@ - Assign and confirm - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order1')], context=context) - self.action_assign(cr, uid, [ref('delivery_order1')]) + !python {model: stock.picking, id: delivery_order1}: | + self.action_confirm() + self.action_assign() - Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 20 pieces from lot A and 10 pieces from pallet 3 - - !python {model: stock.picking}: | - stock_pack = self.pool.get('stock.pack.operation') - self.do_prepare_partial(cr, uid, [ref('delivery_order1')], context=context) - delivery_id = self.browse(cr, uid, ref('delivery_order1'), context=context) - for rec in delivery_id.pack_operation_ids: + !python {model: stock.picking, id: delivery_order1}: | + stock_pack = self.env['stock.pack.operation'] + self.do_prepare_partial() + for rec in self.pack_operation_ids: if rec.package_id.name == 'Pallet 2': - lot_ids = self.pool.get("stock.production.lot").search(cr, uid, [('product_id', '=', ref('product1')), ('name','=','Lot A')]) - stock_pack.write(cr, uid, [rec.id], {'product_id': ref('product1'), 'product_qty': 20, 'pack_lot_ids': [(0, 0, {'lot_id': lot_ids[0], 'qty': 20})], 'product_uom_id': ref('product.product_uom_unit')}, context=context) + lot = self.env["stock.production.lot"].search([('product_id', '=', ref('product1')), ('name','=','Lot A')], limit=1) + rec.write({ + 'product_id': ref('product1'), + 'product_qty': 20, + 'pack_lot_ids': [(0, 0, {'lot_id': lot.id, 'qty': 20})], + 'product_uom_id': ref('product.product_uom_unit') + }) if rec.package_id.name == 'Pallet 3': - stock_pack.write(cr, uid, [rec.id], {'product_id': ref('product1'),'product_qty': 10, 'product_uom_id': ref('product.product_uom_unit')}, context=context) + rec.write({ + 'product_id': ref('product1'), + 'product_qty': 10, + 'product_uom_id': ref('product.product_uom_unit') + }) - Process this picking - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order1')], context=context) + !python {model: stock.picking, id: delivery_order1 }: | + self.do_transfer() - Check the quants that you have 120 pieces pallet 1 in customers, 100 pieces pallet 2 in stock and 20 with customers and 50 in stock, 10 in customers from pallet 3 - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product1'))], context=context) - for rec in self.browse(cr, uid, reco_id, context=context): + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product1'))]) + for rec in records: if rec.package_id.name == 'Pallet 1' and rec.location_id.id == ref('stock_location_customers'): assert rec.qty == 120, "Should have 120 pieces on pallet 1, got " + str(rec.qty) elif rec.package_id.name == 'Pallet 2' and rec.location_id.id == ref('stock_location_stock'): @@ -134,25 +157,25 @@ - Check a backorder was created and on that backorder, prepare partial and process backorder - - !python {model: stock.picking}: | - backorder_ids = self.search(cr, uid, [('backorder_id', '=', ref('delivery_order1'))], context=context) - assert backorder_ids, "Backorder should have been created" - self.action_assign(cr, uid, backorder_ids, context=context) - self.do_prepare_partial(cr, uid, backorder_ids, context=context) - picking = self.browse(cr, uid, backorder_ids[0]) + !python {model: stock.picking, id: False}: | + backorders = self.search([('backorder_id', '=', ref('delivery_order1'))]) + assert backorders, "Backorder should have been created" + backorders.action_assign() + backorders.do_prepare_partial() + picking = backorders[0] assert len(picking.pack_operation_ids) == 2, "Wrong number of pack operation" for pack_op in picking.pack_operation_ids: assert pack_op.product_qty == 1, "Wrong quantity in pack operation (%s found instead of 1)" % (pack_op.product_qty) assert pack_op.package_id.name in ('Pallet 2', 'Pallet 3'), "Wrong pallet info in pack operation (%s found)" % (pack_op.package_id.name) - self.do_transfer(cr, uid, backorder_ids, context=context) + backorders.do_transfer() - Check there are still 0 pieces in stock - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product1')), ('location_id', '=', ref('stock_location_stock'))], context=context) + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product1')), ('location_id', '=', ref('stock_location_stock'))]) total_qty = 0 - for rec in self.browse(cr, uid, reco_id, context=context): + for rec in records: total_qty += rec.qty - product = self.pool.get("product.product").browse(cr, uid, ref('product1')) + product = self.env["product.product"].browse(ref('product1')) assert total_qty == 0, "Total quantity in stock should be 0 as the backorder took everything out of stock" assert product.qty_available == 0, "Quantity available should be 0 too"
\ No newline at end of file diff --git a/addons/stock/test/packingneg.yml b/addons/stock/test/packingneg.yml index 0406d6e6237..37ec32b0be9 100644 --- a/addons/stock/test/packingneg.yml +++ b/addons/stock/test/packingneg.yml @@ -28,32 +28,48 @@ - Confirm and assign picking and prepare partial - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('pick_neg')], context=context) + !python {model: stock.picking, id: pick_neg}: | + self.action_confirm() - Put 120 pieces on Palneg 1 (package), 120 pieces on Palneg 2 with lot A and 60 pieces on Palneg 3 - - !python {model: stock.picking}: | + !python {model: stock.picking, id: pick_neg}: | #Change quantity of first to 120 and create 2 others quant operations - record = self.browse(cr, uid, ref('pick_neg'), context=context) - stock_pack = self.pool.get('stock.pack.operation') - stock_quant_pack = self.pool.get('stock.quant.package') + stock_pack = self.env['stock.pack.operation'] + stock_quant_pack = self.env['stock.quant.package'] #create lot A - lot_a = self.pool.get('stock.production.lot').create(cr, uid, {'name': 'Lot neg', 'product_id': ref('product_neg')}, context=context) + lot_a = self.env['stock.production.lot'].create({'name': 'Lot neg', 'product_id': ref('product_neg')}) #create package - package1 = stock_quant_pack.create(cr, uid, {'name': 'Palneg 1'}, context=context) - package2 = stock_quant_pack.create(cr, uid, {'name': 'Palneg 2'}, context=context) - package3 = stock_quant_pack.create(cr, uid, {'name': 'Palneg 3'}, context=context) + package1 = stock_quant_pack.create({'name': 'Palneg 1'}) + package2 = stock_quant_pack.create({'name': 'Palneg 2'}) + package3 = stock_quant_pack.create({'name': 'Palneg 3'}) #Create package for each line and assign it as result_package_id #create pack operation - stock_pack.write(cr, uid, record.pack_operation_ids[0].id, {'result_package_id': package1, 'product_qty': 120}) - new_pack1 = stock_pack.create(cr, uid, {'product_id': ref('product_neg'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick_neg'), 'pack_lot_ids': [(0, 0, {'lot_id': lot_a, 'qty': 120})], 'result_package_id': package2, 'product_qty': 120, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_stock')}, context=context) - new_pack2 = stock_pack.create(cr, uid, {'product_id': ref('product_neg'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick_neg'), 'result_package_id': package3, 'product_qty': 60, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_stock')}, context=context) + self.pack_operation_ids[0].write({'result_package_id': package1.id, 'product_qty': 120}) + new_pack1 = stock_pack.create({ + 'product_id': ref('product_neg'), + 'product_uom_id': ref('product.product_uom_unit'), + 'picking_id': ref('pick_neg'), + 'pack_lot_ids': [(0, 0, {'lot_id': lot_a.id, 'qty': 120})], + 'result_package_id': package2.id, + 'product_qty': 120, + 'location_id': ref('stock_location_suppliers'), + 'location_dest_id': ref('stock_location_stock') + }) + new_pack2 = stock_pack.create({ + 'product_id': ref('product_neg'), + 'product_uom_id': ref('product.product_uom_unit'), + 'picking_id': ref('pick_neg'), + 'result_package_id': package3.id, + 'product_qty': 60, + 'location_id': ref('stock_location_suppliers'), + 'location_dest_id': ref('stock_location_stock') + }) - Transfer the receipt - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('pick_neg')], context=context) + !python {model: stock.picking, id: pick_neg}: | + self.do_transfer() - Make a delivery order of 300 pieces to the customer - @@ -69,33 +85,40 @@ - Assign and confirm - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order_neg')], context=context) - self.action_assign(cr, uid, [ref('delivery_order_neg')]) + !python {model: stock.picking, id: delivery_order_neg}: | + self.action_confirm() + self.action_assign() - Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 140 pieces from lot A/pallet 2 and 10 pieces from pallet 3 - - !python {model: stock.picking}: | - stock_pack = self.pool.get('stock.pack.operation') - delivery_id = self.browse(cr, uid, ref('delivery_order_neg'), context=context) - for rec in delivery_id.pack_operation_ids: + !python {model: stock.picking, id: delivery_order_neg}: | + for rec in self.pack_operation_ids: if rec.package_id.name == 'Palneg 2': - lot_ids = self.pool.get("stock.production.lot").search(cr, uid, [('product_id', '=', ref('product_neg')), ('name','=','Lot neg')]) - stock_pack.write(cr, uid, [rec.id], {'product_id': ref('product_neg'), 'product_qty': 140, 'pack_lot_ids': [(0, 0, {'lot_id': lot_ids[0], 'qty': 140})], 'product_uom_id': ref('product.product_uom_unit')}, context=context) + lot_id = self.env["stock.production.lot"].search([('product_id', '=', ref('product_neg')), ('name','=','Lot neg')], limit=1).id + rec.write({ + 'product_id': ref('product_neg'), + 'product_qty': 140, + 'pack_lot_ids': [(0, 0, {'lot_id': lot_id, 'qty': 140})], + 'product_uom_id': ref('product.product_uom_unit') + }) if rec.package_id.name == 'Palneg 3': - stock_pack.write(cr, uid, [rec.id], {'product_id': ref('product_neg'),'product_qty': 10, 'product_uom_id': ref('product.product_uom_unit')}, context=context) + rec.write({ + 'product_id': ref('product_neg'), + 'product_qty': 10, + 'product_uom_id': ref('product.product_uom_unit') + }) - Process this picking - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order_neg')], context=context) + !python {model: stock.picking, id: delivery_order_neg}: | + self.do_transfer() - Check the quants that you have 120 pieces pallet 1 in customers, -20 pieces pallet 2 in stock, 120 + 20 pieces 2 in customer with lot, and a total quantity of 50 in stock from pallet 3 (should be 20+30, as it has been split by reservation), finally 10 in customers from pallet 3 - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product_neg'))], context=context) + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product_neg'))]) pallet_3_stock_qty = 0 - for rec in self.browse(cr, uid, reco_id, context=context): + for rec in records: if rec.package_id.name == 'Palneg 1' and rec.location_id.id == ref('stock_location_customers'): assert rec.qty == 120, "Should have 120 pieces on pallet 1" elif rec.package_id.name == 'Palneg 2' and rec.location_id.id == ref('stock_location_stock'): @@ -125,21 +148,24 @@ - Receive 20 products with lot neg in stock with a new incoming shipment that should be on pallet 2 - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref("delivery_reconcile")]) - pick = self.browse(cr, uid, ref("delivery_reconcile")) - ops_obj = self.pool.get("stock.pack.operation") - pack_obj = self.pool.get("stock.quant.package") - lot_ids = self.pool.get("stock.production.lot").search(cr, uid, [('product_id', '=', ref('product_neg')), ('name','=','Lot neg')]) - pack_ids = pack_obj.search(cr, uid, [('name', '=', 'Palneg 2')]) - ops_obj.write(cr, uid, [pick.pack_operation_ids[0].id], {'pack_lot_ids': {'lot_id': lot_ids[0], 'qty': 20.0}, 'result_package_id': pack_ids[0]}) - self.do_transfer(cr, uid, [ref("delivery_reconcile")]) + !python {model: stock.picking, id: delivery_reconcile}: | + self.action_confirm() + pack_obj = self.env["stock.quant.package"] + lot = self.env["stock.production.lot"].search([('product_id', '=', ref('product_neg')), ('name','=','Lot neg')], limit=1) + pack = pack_obj.search([('name', '=', 'Palneg 2')], limit=1) + self.pack_operation_ids[0].write({'pack_lot_ids': {'lot_id': lot.id, 'qty': 20.0}, 'result_package_id': pack.id}) + self.do_transfer() - Check the negative quant was reconciled and the 20 pieces of lot neg at customers have the incoming shipments in the history_ids - - !python {model: stock.quant}: | - neg_quants = self.search(cr, uid, [('product_id','=', ref('product_neg')), ('qty', '<', 0)]) - assert len(neg_quants) == 0, "Negative quants should have been reconciled" - pick = self.pool.get('stock.picking').browse(cr, uid, ref('delivery_reconcile')) - customer_quant = self.search(cr, uid, [('product_id', '=', ref('product_neg')), ('location_id', '=', ref('stock_location_customers')), ('lot_id.name','=', 'Lot neg'), ('qty','=', 20)]) - assert pick.move_lines[0].id in [x.id for x in self.browse(cr, uid, customer_quant[0]).history_ids] + !python {model: stock.quant, id: False}: | + neg_quants = self.search([('product_id','=', ref('product_neg')), ('qty', '<', 0)]) + assert len(neg_quants.ids) == 0, "Negative quants should have been reconciled" + pick = self.env['stock.picking'].browse(ref('delivery_reconcile')) + customer_quant = self.search([ + ('product_id', '=', ref('product_neg')), + ('location_id', '=', ref('stock_location_customers')), + ('lot_id.name','=', 'Lot neg'), + ('qty','=', 20) + ]) + assert pick.move_lines[0].id in [x.id for x in customer_quant[0].history_ids] diff --git a/addons/stock/test/procrule.yml b/addons/stock/test/procrule.yml index c1985bda679..1d9d4f502d0 100644 --- a/addons/stock/test/procrule.yml +++ b/addons/stock/test/procrule.yml @@ -23,18 +23,22 @@ - Confirm delivery order. - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('pick_output')]) + !python {model: stock.picking, id: pick_output}: | + self.action_confirm() - I run the scheduler. - - !python {model: procurement.order}: | - self.run_scheduler(cr, uid) + !python {model: procurement.order, id: False}: | + self.run_scheduler() - Check a picking was created from stock to output. - - !python {model: stock.move }: | - picking = self.pool.get("stock.picking").browse(cr, uid, ref("pick_output")) - move_id = self.search(cr, uid, [('product_id', '=', ref('product.product_product_3')),('location_id', '=', ref('stock.stock_location_stock')), - ('location_dest_id', '=', ref('stock.stock_location_output')), ('move_dest_id', '=', picking.move_lines[0].id)]) - assert len(move_id) == 1, "It should have created a picking from Stock to Output with the original picking as destination" + !python {model: stock.move, id: False}: | + picking = self.env["stock.picking"].browse(ref("pick_output")) + moves = self.search([ + ('product_id', '=', ref('product.product_product_3')), + ('location_id', '=', ref('stock.stock_location_stock')), + ('location_dest_id', '=', ref('stock.stock_location_output')), + ('move_dest_id', '=', picking.move_lines[0].id) + ]) + assert len(moves.ids) == 1, "It should have created a picking from Stock to Output with the original picking as destination" diff --git a/addons/stock/test/wiseoperator.yml b/addons/stock/test/wiseoperator.yml index 27e874b6649..4471cd5048e 100644 --- a/addons/stock/test/wiseoperator.yml +++ b/addons/stock/test/wiseoperator.yml @@ -22,30 +22,40 @@ - Confirm and assign picking and prepare partial - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('pick1_wise')], context=context) - self.do_prepare_partial(cr, uid, [ref('pick1_wise')], context=context) + !python {model: stock.picking, id: pick1_wise}: | + self.action_confirm() + self.do_prepare_partial() - Put 6 pieces in shelf1 and 4 pieces in shelf2 - - !python {model: stock.picking}: | - record = self.browse(cr, uid, ref('pick1_wise'), context=context) - stock_pack = self.pool.get('stock.pack.operation') - stock_quant_pack = self.pool.get('stock.quant.package') - package1 = stock_quant_pack.create(cr, uid, {'name': 'Pack 1'}, context=context) - stock_pack.write(cr, uid, record.pack_operation_ids[0].id, {'result_package_id': package1, 'product_qty': 4, 'location_dest_id': ref('stock_location_components')}) - new_pack1 = stock_pack.create(cr, uid, {'product_id': ref('product_wise'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1_wise'), 'product_qty': 6.0, 'location_id': ref('stock_location_suppliers'), 'location_dest_id': ref('stock_location_14')}, context=context) + !python {model: stock.picking, id: pick1_wise}: | + stock_pack = self.env['stock.pack.operation'] + stock_quant_pack = self.env['stock.quant.package'] + package1 = stock_quant_pack.create({'name': 'Pack 1'}) + self.pack_operation_ids[0].write({ + 'result_package_id': package1.id, + 'product_qty': 4, + 'location_dest_id': ref('stock_location_components') + }) + new_pack1 = stock_pack.create({ + 'product_id': ref('product_wise'), + 'product_uom_id': ref('product.product_uom_unit'), + 'picking_id': ref('pick1_wise'), + 'product_qty': 6.0, + 'location_id': ref('stock_location_suppliers'), + 'location_dest_id': ref('stock_location_14') + }) - Transfer the receipt - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('pick1_wise')], context=context) + !python {model: stock.picking, id: pick1_wise}: | + self.do_transfer() - Check the system created 2 quants - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product_wise'))], context=context) - assert len(reco_id) == 2, "The number of quants created is not correct" + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product_wise'))]) + assert len(records.ids) == 2, "The number of quants created is not correct" - Make a delivery order of 5 pieces to the customer - @@ -61,9 +71,9 @@ - Assign and confirm - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order_wise1')], context=context) - self.action_assign(cr, uid, [ref('delivery_order_wise1')]) + !python {model: stock.picking, id: delivery_order_wise1}: | + self.action_confirm() + self.action_assign() - Make a delivery order of 5 pieces to the customer - @@ -79,48 +89,48 @@ - Assign and confirm - - !python {model: stock.picking}: | - self.action_confirm(cr, uid, [ref('delivery_order_wise2')], context=context) - self.action_assign(cr, uid, [ref('delivery_order_wise2')]) + !python {model: stock.picking, id: delivery_order_wise2}: | + self.action_confirm() + self.action_assign() - The operator is a wise guy and decides to do the opposite of what Odoo proposes. He uses the products reserved on picking 1 on picking 2 and vice versa - - !python {model: stock.picking}: | - stock_pack = self.pool.get('stock.pack.operation') - picking1 = self.browse(cr, uid, ref('delivery_order_wise1')) - picking2 = self.browse(cr, uid, ref('delivery_order_wise2')) + !python {model: stock.picking, id: False}: | + stock_pack = self.env['stock.pack.operation'] + picking1 = self.browse(ref('delivery_order_wise1')) + picking2 = self.browse(ref('delivery_order_wise2')) pack_ids1 = [x.id for x in picking1.pack_operation_ids] pack_ids2 = [x.id for x in picking2.pack_operation_ids] - stock_pack.write(cr, uid, pack_ids1, {'picking_id': picking2.id}) - stock_pack.write(cr, uid, pack_ids2, {'picking_id': picking1.id}) - link_obj = self.pool['stock.move.operation.link'] + self.env['stock.pack.operation'].browse(pack_ids1).write({'picking_id': picking2.id}) + self.env['stock.pack.operation'].browse(pack_ids2).write({'picking_id': picking1.id}) + link_obj = self.env['stock.move.operation.link'] # The recompute remaining qtys does not take into account that pack operations change picking - links = link_obj.search(cr, uid, [('operation_id', 'in', pack_ids1 + pack_ids2)]) - link_obj.unlink(cr, uid, links) + links = link_obj.search([('operation_id', 'in', pack_ids1 + pack_ids2)]) + links.unlink() - Process this picking - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order_wise1')], context=context) + !python {model: stock.picking, id: delivery_order_wise1}: | + self.do_transfer() - Check there was no negative quant created by this picking - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product_wise')), ('qty', '<', 0.0)], context=context) - assert len(reco_id) == 0, 'This should not have created a negative quant' + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product_wise')), ('qty', '<', 0.0)]) + assert len(records.ids) == 0, 'This should not have created a negative quant' - Check the other delivery order has changed its state back to partially available - - !python {model: stock.picking}: | - assert self.browse(cr, uid, ref('delivery_order_wise2')).state == 'partially_available', "Delivery order 2 should be back in confirmed state" + !python {model: stock.picking, id: delivery_order_wise2}: | + assert self.state == 'partially_available', "Delivery order 2 should be back in confirmed state" - Process the second picking - - !python {model: stock.picking}: | - self.do_transfer(cr, uid, [ref('delivery_order_wise2')], context=context) + !python {model: stock.picking, id: delivery_order_wise2}: | + self.do_transfer() - Check all quants are in Customers and there are no negative quants anymore - - !python {model: stock.quant}: | - reco_id = self.search(cr ,uid , [('product_id','=',ref('product_wise'))], context=context) - assert all([x.location_id.id==ref('stock_location_customers') and x.qty > 0.0 for x in self.browse(cr, uid, reco_id)]), "Negative quant or wrong location detected"
\ No newline at end of file + !python {model: stock.quant, id: False}: | + records = self.search([('product_id','=',ref('product_wise'))]) + assert all([x.location_id.id==ref('stock_location_customers') and x.qty > 0.0 for x in records]), "Negative quant or wrong location detected"
\ No newline at end of file diff --git a/addons/stock_account/data/stock_account_data_post_install.yml b/addons/stock_account/data/stock_account_data_post_install.yml index 5f039348054..a8ec89b65c8 100644 --- a/addons/stock_account/data/stock_account_data_post_install.yml +++ b/addons/stock_account/data/stock_account_data_post_install.yml @@ -1,43 +1,54 @@ - Setting journal and property field (if needed) - - !python {model: account.journal} : | + !python {model: account.journal, id: False} : | #if we already have a coa installed, create journal and set property field - company_obj = self.pool['res.company'] - company_ids = company_obj.search(cr, uid, [('chart_template_id', '!=', False)]) + company_obj = self.env['res.company'] + company_ids = company_obj.search([('chart_template_id', '!=', False)]).ids for company_id in company_ids: - from openerp.tools.translate import _ + from odoo.tools.translate import _ #Check if property exists for stock account journal exists - PropertyObj = self.pool.get('ir.property') - properties = PropertyObj.search(cr, uid, [('name', '=', 'property_stock_journal'), ('company_id', '=', company_id)]) + PropertyObj = self.env['ir.property'] + properties = PropertyObj.search([('name', '=', 'property_stock_journal'), ('company_id', '=', company_id)]) AccountJournal = self.pool.get('account.journal') #If not, check if you can find a journal that is already there with the same name, otherwise create one if not properties: - journal_ids = AccountJournal.search(cr, uid, [('name', '=', _('Stock Journal')), ('company_id', '=', company_id), ('type', '=', 'general')]) - if journal_ids: - journal_id = journal_ids[0] - else: - journal_id = AccountJournal.create(cr, uid, {'name': _('Stock Journal'), 'type': 'general', 'code': 'STJ', 'company_id': company_id, 'show_on_dashboard': False}) + journal_id = AccountJournal.search([('name', '=', _('Stock Journal')), ('company_id', '=', company_id), ('type', '=', 'general')], limit=1).id + if not journal_id: + journal_id = AccountJournal.create({ + 'name': _('Stock Journal'), + 'type': 'general', + 'code': 'STJ', + 'company_id': company_id, + 'show_on_dashboard': False + }).id vals = {'name': 'property_stock_journal', - 'fields_id': self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', 'property_stock_journal'), ('model', '=', 'product.category'), ('relation', '=', 'account.journal')], limit=1)[0], + 'fields_id': self.env['ir.model.fields'].search([ + ('name', '=', 'property_stock_journal'), + ('model', '=', 'product.category'), + ('relation', '=', 'account.journal')], limit=1).id, 'company_id': company_id, 'value': 'account.journal,' + str(journal_id)} - PropertyObj.create(cr, uid, vals) + PropertyObj.create(vals) todo_list = [ # Property Stock Accounts 'property_stock_account_input_categ_id', 'property_stock_account_output_categ_id', 'property_stock_valuation_account_id', ] - company = company_obj.browse(cr, uid, company_id) + company = company_obj.browse(company_id) for record in todo_list: account = getattr(company, record) value = account and 'account.account,' + str(account.id) or False if value: - field_id = self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', record), ('model', '=', 'product.category'), ('relation', '=', 'account.account')], limit=1)[0] + field_id = self.env['ir.model.fields'].search([ + ('name', '=', record), + ('model', '=', 'product.category'), + ('relation', '=', 'account.account') + ], limit=1).id vals = { 'name': record, 'company_id': company_id, @@ -45,7 +56,7 @@ 'value': value, 'res_id': 'product.category,'+str(ref('product.product_category_all')), } - properties = PropertyObj.search(cr, uid, [('name', '=', record), ('company_id', '=', company.id), ('value_reference', '!=', False)]) + properties = PropertyObj.search([('name', '=', record), ('company_id', '=', company.id), ('value_reference', '!=', False)]) if not properties: #create the property - PropertyObj.create(cr, uid, vals) + PropertyObj.create(vals) diff --git a/addons/stock_account/data/stock_account_demo.yml b/addons/stock_account/data/stock_account_demo.yml index d115ec78873..0621c20f949 100644 --- a/addons/stock_account/data/stock_account_demo.yml +++ b/addons/stock_account/data/stock_account_demo.yml @@ -1,16 +1,16 @@ - Setting property field - - !python {model: ir.model.data} : | - account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_stock_account')])]) - fields_id = self.pool.get('ir.model.fields').search(cr, uid, [('model','=','product.category'),('name','=','property_stock_valuation_account_id')]) + !python {model: ir.model.data, id: False} : | + account_id = self.env['account.account'].search([('tag_ids', 'in', [ref('account.demo_stock_account')])], limit=1).id + fields_id = self.env['ir.model.fields'].search([('model','=','product.category'),('name','=','property_stock_valuation_account_id')], limit=1).id if not account_id: - account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_current_assets'))]) + account_id = self.env['account.account'].search([('user_type_id', '=', ref('account.data_account_type_current_assets'))], limit=1).id if account_id: vals = { 'name': 'property_stock_valuation_account_id', - 'fields_id': fields_id[0], - 'value': 'account.account,'+str(account_id[0]), + 'fields_id': fields_id, + 'value': 'account.account,'+str(account_id), 'company_id': ref('base.main_company'), } - self._update(cr, uid, 'ir.property', 'stock_account', vals, 'property_stock_valuation_account_id') + self._update('ir.property', 'stock_account', vals, 'property_stock_valuation_account_id') diff --git a/addons/stock_dropshipping/test/cancellation_propagated.yml b/addons/stock_dropshipping/test/cancellation_propagated.yml index a658de1314a..a2663672c8f 100644 --- a/addons/stock_dropshipping/test/cancellation_propagated.yml +++ b/addons/stock_dropshipping/test/cancellation_propagated.yml @@ -21,10 +21,10 @@ - Set routes on product to be MTO and Buy - - !python {model: product.product}: | - route_warehouse0_buy = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).buy_pull_id.route_id.id - route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id - self.write(cr, uid, ref('product_mto'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_buy])]}, context=context ) + !python {model: product.product, id: product_mto}: | + route_warehouse0_buy = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).buy_pull_id.route_id.id + route_warehouse0_mto = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).mto_pull_id.route_id.id + self.write({'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_buy])]}) - Create a sales order with a line of 5 Units "My Product". - @@ -41,8 +41,8 @@ - Confirm the sale order - - !python {model: sale.order}: | - self.action_confirm(cr, uid, ref("sale_order_product_mto"), context=context) + !python {model: sale.order, id: sale_order_product_mto}: | + self.action_confirm() - Create another sales order with 2 Dozen of the same product - @@ -58,13 +58,13 @@ - Confirm the sale order - - !python {model: sale.order}: | - self.action_confirm(cr, uid, ref("sale_order_product_mto2"), context=context) + !python {model: sale.order, id: sale_order_product_mto2}: | + self.action_confirm() - I run scheduler. - - !python {model: procurement.order}: | - self.run_scheduler(cr, uid) + !python {model: procurement.order, id: False}: | + self.run_scheduler() - Check the propagation when we cancel the main procurement * Retrieve related procurements and check that there are all running @@ -72,36 +72,35 @@ * Cancel the main procurement * Check that all procurements related and the purchase order are well cancelled - - !python {model: procurement.order}: | + !python {model: procurement.order, id: False}: | # Retrieve related procurement - so1 = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_product_mto')) - so2 = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_product_mto2')) - procu_ids = self.browse(cr, uid, self.search(cr, uid, [('group_id.name', 'in', [so1.name, so2.name])])) - assert len(procu_ids)>0, 'No procurement found!' - + so1 = self.env['sale.order'].browse(ref('sale_order_product_mto')) + so2 = self.env['sale.order'].browse(ref('sale_order_product_mto2')) + procus = self.search([('group_id.name', 'in', [so1.name, so2.name])]) + assert len(procus.ids)>0, 'No procurement found!' # Check that all procurements are running - for procu in procu_ids: + for procu in procus: assert procu.state == u'running', 'Procurement with id: %d should be running but is with state : %s!' %(procu.id, procu.state) # Check that one purchase order has been created - purchase_ids = procu_ids.mapped('purchase_line_id').mapped('order_id') - assert len(purchase_ids) == 1, 'No purchase order found !' + purchases = procus.mapped('purchase_line_id').mapped('order_id') + assert len(purchases.ids) == 1, 'No purchase order found !' # Check the two purchase order lines - purchase_line = purchase_ids[0].order_line[0] + purchase_line = purchases[0].order_line[0] assert purchase_line.product_qty == 29.0, 'The product quantity of the first order line should be 5 and not %s' % (purchase_line.product_qty,) assert purchase_line.product_uom.id == ref("product.product_uom_unit"), 'The product UoM ID of the first order line should be %s and not %s' % (ref("product.product_uom_unit"), purchase_line.product_uom.id,) # Cancel the Sales Order 2 - self.cancel(cr, uid, [so2.order_line[0].procurement_ids[0].id], context=context) + so2.order_line[0].procurement_ids[0].cancel() assert so2.order_line[0].procurement_ids[0].state == u'cancel', 'Procurement 2 should be cancelled !' assert purchase_line.product_qty == 5.0, 'The product quantity of the first order line should be 5 and not %s' % (purchase_line.product_qty,) # Cancel the Sales Order 1 - self.cancel(cr, uid, [so1.order_line[0].procurement_ids[0].id], context=context) + so1.order_line[0].procurement_ids[0].cancel() assert so1.order_line[0].procurement_ids[0].state == u'cancel', 'Procurement 1 should be cancelled !' - assert len(purchase_ids.order_line) == 0, 'The PO line should have been unlinked!' + assert len(purchases.order_line) == 0, 'The PO line should have been unlinked!' # Check that all procurements related are cancelled - for procu in procu_ids: + for procu in procus: assert procu.state == u'cancel', 'Procurement %d should be cancelled but is with a state : %s!' %(procu.id, procu.state) diff --git a/addons/stock_dropshipping/test/crossdock.yml b/addons/stock_dropshipping/test/crossdock.yml index 7a90e66cae5..9f83ba26557 100644 --- a/addons/stock_dropshipping/test/crossdock.yml +++ b/addons/stock_dropshipping/test/crossdock.yml @@ -35,24 +35,23 @@ - product_id: cross_shop_product product_uom_qty: 100.00 - - !python {model: sale.order.line}: | - route_wh_pps_crossdock = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock_dropshipping.wh_pps')).crossdock_route_id.id - order = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_crossdock_shpng')) - line_ids = [x.id for x in order.order_line] - self.write(cr, uid, line_ids, {'route_id': route_wh_pps_crossdock}) + !python {model: sale.order.line, id: False}: | + route_wh_pps_crossdock = self.env['stock.warehouse'].browse(ref('stock_dropshipping.wh_pps')).crossdock_route_id.id + order = self.env['sale.order'].browse(ref('sale_order_crossdock_shpng')) + order.order_line.write({'route_id': route_wh_pps_crossdock}) - Confirm sales order. - - !python {model: sale.order}: | - self.action_confirm(cr, uid, ref("sale_order_crossdock_shpng"), context=context) + !python {model: sale.order, id: sale_order_crossdock_shpng}: | + self.action_confirm() - Run the scheduler. - - !python {model: procurement.order}: | - self.run_scheduler(cr, uid) + !python {model: procurement.order, id: False}: | + self.run_scheduler() - Check a quotation was created for the created supplier and confirm it. - - !python {model: purchase.order}: | - po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_crossdock')), ('state','=','draft')]) - self.button_confirm(cr, uid, po_id) + !python {model: purchase.order, id: False}: | + po = self.search([('partner_id', '=', ref('supplier_crossdock')), ('state','=','draft')]) + po.button_confirm() diff --git a/addons/stock_dropshipping/test/dropship.yml b/addons/stock_dropshipping/test/dropship.yml index 9c00aad923f..e501f378514 100644 --- a/addons/stock_dropshipping/test/dropship.yml +++ b/addons/stock_dropshipping/test/dropship.yml @@ -34,45 +34,45 @@ - Confirm sales order - - !python {model: sale.order}: | - self.action_confirm(cr, uid, ref("sale_order_drp_shpng"), context=context) + !python {model: sale.order, id: sale_order_drp_shpng}: | + self.action_confirm() - Check the sales order created a procurement group which has a procurement of 200 pieces - - !python {model: procurement.group}: | - sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng')) - assert self.browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0].product_qty == 200 + !python {model: procurement.group, id: False}: | + sale_record = self.env["sale.order"].browse(ref('sale_order_drp_shpng')) + assert sale_record.procurement_group_id.procurement_ids[0].product_qty == 200 - Check a quotation was created to a certain vendor and confirm so it becomes a confirmed purchase order - - !python {model: purchase.order}: | - from openerp import netsvc - sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng')) - procurement_order = self.pool.get("procurement.group").browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0] - purchase_id = procurement_order.purchase_line_id.order_id.id + !python {model: purchase.order, id: False}: | + from odoo import netsvc + sale_record = self.env["sale.order"].browse(ref('sale_order_drp_shpng')) + procurement_order = sale_record.procurement_group_id.procurement_ids[0] + purchase = procurement_order.purchase_line_id.order_id - self.button_confirm(cr, uid, purchase_id) - po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))]) - assert self.browse(cr, uid, purchase_id).state == 'purchase', 'Purchase order should be in the approved state' + purchase.button_confirm() + po_id = self.env['purchase.order'].search([('partner_id', '=', ref('supplier_dropship'))]) + assert purchase.state == 'purchase', 'Purchase order should be in the approved state' - Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces - - !python {model: purchase.order}: | - po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))]) + !python {model: purchase.order, id: False}: | + po_id = self.search([('partner_id', '=', ref('supplier_dropship'))]).ids assert len(po_id) == 1, 'There should be one picking' - Send the 200 pieces. - - !python {model: stock.picking}: | - po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))]) - assert po_id and len(po_id) == 1, 'Problem with the Purchase Order detected' - picking_ids = [pick.id for pick in self.pool.get('purchase.order').browse(cr, uid, po_id[0]).picking_ids] - self.do_transfer(cr, uid, picking_ids) + !python {model: stock.picking, id: False}: | + po = self.env['purchase.order'].search([('partner_id', '=', ref('supplier_dropship'))]) + assert po.ids and len(po.ids) == 1, 'Problem with the Purchase Order detected' + pickings = po[0].picking_ids + pickings.do_transfer() - Check one quant was created in Customers location with 200 pieces and one move in the history_ids - - !python {model: stock.quant}: | - quant_ids = self.search(cr, uid, [('location_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))]) - assert quant_ids, 'No Quant found' - assert len(quant_ids) == 1, 'There should be exactly one quant' - assert len(self.browse(cr, uid, quant_ids)[0].history_ids) == 1, 'The quant should have exactly 1 move in its history' + !python {model: stock.quant, id: False}: | + quants = self.search([('location_id', '=', ref('stock.stock_location_customers')), ('product_id', '=', ref("drop_shop_product"))]) + assert quants, 'No Quant found' + assert len(quants.ids) == 1, 'There should be exactly one quant' + assert len(quants[0].history_ids) == 1, 'The quant should have exactly 1 move in its history' diff --git a/addons/stock_dropshipping/test/lifo_price.yml b/addons/stock_dropshipping/test/lifo_price.yml index b3945d77d79..3cff45c24fa 100644 --- a/addons/stock_dropshipping/test/lifo_price.yml +++ b/addons/stock_dropshipping/test/lifo_price.yml @@ -1,8 +1,8 @@ - Set the company currency as EURO for the sake of repeatibility - - !python {model: res.company}: | - self.write(cr, uid, [ref('base.main_company')], {'currency_id':ref('base.EUR')}, context=context) + !python {model: res.company, id: base.main_company}: | + self.write({'currency_id':ref('base.EUR')}) - Set product category removal strategy as LIFO @@ -54,8 +54,8 @@ - I confirm the first purchase order - - !python {model: purchase.order}: | - self.button_confirm(cr, uid, [ref("purchase_order_lifo1")]) + !python {model: purchase.order, id: purchase_order_lifo1}: | + self.button_confirm() - I check the "Approved" status of purchase order 1 - @@ -64,30 +64,28 @@ - Process the receipt of purchase order 1 - - !python {model: stock.picking}: | - order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo1"), context=context).picking_ids[0] - order.do_transfer() + !python {model: purchase.order, id: purchase_order_lifo1}: | + self.picking_ids[0].do_transfer() - Check the standard price of the product (lifo icecream) - - !python {model: product.product}: | - assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 70.0, 'Standard price should not have changed!' + !python {model: product.product, id: product_lifo_icecream}: | + assert self.standard_price == 70.0, 'Standard price should not have changed!' - I confirm the second purchase order - - !python {model: purchase.order}: | - self.button_confirm(cr, uid, [ref("purchase_order_lifo2")]) + !python {model: purchase.order, id: purchase_order_lifo2}: | + self.button_confirm() - Process the receipt of purchase order 2 - - !python {model: stock.picking}: | - order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo2"), context=context).picking_ids[0] - order.do_transfer() + !python {model: purchase.order, id: purchase_order_lifo2}: | + self.picking_ids[0].do_transfer() - Check the standard price should not have changed - - !python {model: product.product}: | - assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 70.0, 'Standard price as lifo price of second receipt incorrect!' + !python {model: product.product, id: product_lifo_icecream}: | + assert self.standard_price == 70.0, 'Standard price as lifo price of second receipt incorrect!' - Let us send some goods - @@ -107,16 +105,15 @@ - I assign this outgoing shipment - - !python {model: stock.picking}: | - self.action_assign(cr, uid, [ref("outgoing_lifo_shipment")]) + !python {model: stock.picking, id: outgoing_lifo_shipment}: | + self.action_assign() - Process the delivery of the outgoing shipment - - !python {model: stock.picking}: | - pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_lifo_shipment"), context=context) - pick_order.do_transfer() + !python {model: stock.picking, id: outgoing_lifo_shipment}: | + self.do_transfer() - Check standard price became 80 euro - - !python {model: product.product}: | - assert self.browse(cr, uid, ref("product_lifo_icecream")).standard_price == 80.0, 'Price should have been 80 euro' + !python {model: product.product, id: product_lifo_icecream}: | + assert self.standard_price == 80.0, 'Price should have been 80 euro'
\ No newline at end of file diff --git a/addons/stock_dropshipping/test/procurementexception.yml b/addons/stock_dropshipping/test/procurementexception.yml index edf857603d6..cb737401161 100644 --- a/addons/stock_dropshipping/test/procurementexception.yml +++ b/addons/stock_dropshipping/test/procurementexception.yml @@ -22,16 +22,16 @@ - I confirm the sales order. - - !python {model: sale.order}: | - self.action_confirm(cr, uid, ref("sale_order_route_dropship01"), context=context) + !python {model: sale.order, id: sale_order_route_dropship01}: | + self.action_confirm() - I check there is a procurement in exception that has the procurement group of the sales order created before. - - !python {model: procurement.order}: | - self.run_scheduler(cr, uid) - sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_dropship01")) - proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')]) - assert proc_id, 'No Procurement!' + !python {model: procurement.order, id: False}: | + self.run_scheduler() + sale_order = self.env['sale.order'].browse(ref("sale_order_route_dropship01")) + procs = self.search([('group_id.name', '=', sale_order.name), ('state', '=', 'exception')]) + assert procs, 'No Procurement!' - I set the at least one supplier on the product. - @@ -43,22 +43,22 @@ - I run the Procurement. - - !python {model: procurement.order}: | - sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_dropship01")) - proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')]) - self.run(cr, uid, proc_id) + !python {model: procurement.order, id: False}: | + sale_order = self.env['sale.order'].browse(ref("sale_order_route_dropship01")) + procs = self.search([('group_id.name', '=', sale_order.name), ('state', '=', 'exception')]) + procs.run() - I check the status changed there is no procurement order in exception any more from that procurement group - - !python {model: procurement.order}: | - sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_dropship01")) - proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')]) - assert not proc_id, 'Procurement should be in running state' + !python {model: procurement.order, id: False}: | + sale_order = self.env['sale.order'].browse(ref("sale_order_route_dropship01")) + procs = self.search([('group_id.name', '=', sale_order.name), ('state', '=', 'exception')]) + assert not procs, 'Procurement should be in running state' - I check a purchase quotation was created. - - !python {model: procurement.order}: | - sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_dropship01")) - proc_ids = self.search(cr, uid, [('group_id.name', '=', sale_id.name)]) - purchase_id = [proc.purchase_line_id.order_id for proc in self.browse(cr, uid, proc_ids) if proc.purchase_line_id] + !python {model: procurement.order, id: False}: | + sale_order = self.env['sale.order'].browse(ref("sale_order_route_dropship01")) + procs = self.search([('group_id.name', '=', sale_order.name)]) + purchase_id = [proc.purchase_line_id.order_id for proc in procs if proc.purchase_line_id] assert purchase_id, 'No Purchase Quotation is created' diff --git a/addons/stock_landed_costs/test/stock_landed_costs.yml b/addons/stock_landed_costs/test/stock_landed_costs.yml index 4f848fde706..7ac619c6d09 100644 --- a/addons/stock_landed_costs/test/stock_landed_costs.yml +++ b/addons/stock_landed_costs/test/stock_landed_costs.yml @@ -71,15 +71,14 @@ - I compute the landed cost using Compute button - - !python {model: stock.landed.cost}: | - self.compute_landed_cost(cr, uid, [ref("stock_landed_cost_1")]) + !python {model: stock.landed.cost, id: stock_landed_cost_1}: | + self.compute_landed_cost() - I check the valuation adjustment lines - - !python {model: stock.landed.cost}: | - landed_cost = self.browse(cr, uid, ref("stock_landed_cost_1")) - for valuation in landed_cost.valuation_adjustment_lines: + !python {model: stock.landed.cost, id: stock_landed_cost_1}: | + for valuation in self.valuation_adjustment_lines: if valuation.cost_line_id.name == 'equal split': assert valuation.additional_landed_cost == 5 elif valuation.cost_line_id.name == 'split by quantity' and valuation.move_id.name == "move 1": @@ -99,8 +98,8 @@ - I confirm the landed cost - - !python {model: stock.landed.cost}: | - self.button_validate(cr, uid, [ref("stock_landed_cost_1")]) + !python {model: stock.landed.cost, id: stock_landed_cost_1}: | + self.button_validate() - I check that the landed cost is now "Closed" and that it has an accounting entry - diff --git a/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml b/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml index 2f237e6751a..b7e6a890610 100644 --- a/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml +++ b/addons/stock_landed_costs/test/stock_landed_costs_rounding.yml @@ -56,15 +56,14 @@ - I receive picking LC_pick_3, and check how many quants are created - - !python {model: stock.picking}: | - pick = self.browse(cr, uid, [ref("picking_landed_cost_3")], context=context) - pick.move_lines.price_unit = 1.0 + !python {model: stock.picking, id: picking_landed_cost_3}: | + self.move_lines.price_unit = 1.0 - self.action_confirm(cr, uid, [ref("picking_landed_cost_3")], context=context) - self.action_assign(cr, uid, [ref("picking_landed_cost_3")], context=context) - self.action_done(cr, uid, [ref("picking_landed_cost_3")], context=context) + self.action_confirm() + self.action_assign() + self.action_done() - quants = pick.move_lines.quant_ids + quants = self.move_lines.quant_ids assert len(quants) == 1 assert quants.qty == 13 assert quants.cost == 1.0 @@ -83,20 +82,19 @@ - I compute the landed cost using Compute button - - !python {model: stock.landed.cost}: | - self.compute_landed_cost(cr, uid, [ref("stock_landed_cost_2")]) + !python {model: stock.landed.cost, id: stock_landed_cost_2}: | + self.compute_landed_cost() - I check the valuation adjustment lines - - !python {model: stock.landed.cost}: | - landed_cost = self.browse(cr, uid, ref("stock_landed_cost_2")) - for valuation in landed_cost.valuation_adjustment_lines: + !python {model: stock.landed.cost, id: stock_landed_cost_2}: | + for valuation in self.valuation_adjustment_lines: assert valuation.additional_landed_cost == 15 - I confirm the landed cost - - !python {model: stock.landed.cost}: | - self.button_validate(cr, uid, [ref("stock_landed_cost_2")]) + !python {model: stock.landed.cost, id: stock_landed_cost_2}: | + self.button_validate() - I check that the landed cost is now "Closed" and that it has an accounting entry - @@ -106,9 +104,8 @@ - I check the quants quantity and cost - - !python {model: stock.landed.cost}: | - landed_cost = self.browse(cr, uid, ref("stock_landed_cost_2")) - for valuation in landed_cost.valuation_adjustment_lines: + !python {model: stock.landed.cost, id: stock_landed_cost_2}: | + for valuation in self.valuation_adjustment_lines: quants = valuation.move_id.quant_ids assert quants.mapped('qty') == [12.0, 1.0] assert quants.mapped('cost') == [2.15, 2.2] @@ -117,15 +114,14 @@ - I receive picking LC_pick_4, and check how many quants are created - - !python {model: stock.picking}: | - pick = self.browse(cr, uid, [ref("picking_landed_cost_4")], context=context) - pick.move_lines.price_unit = 17.0/12.0 + !python {model: stock.picking, id: picking_landed_cost_4}: | + self.move_lines.price_unit = 17.0/12.0 - self.action_confirm(cr, uid, [ref("picking_landed_cost_4")], context=context) - self.action_assign(cr, uid, [ref("picking_landed_cost_4")], context=context) - self.action_done(cr, uid, [ref("picking_landed_cost_4")], context=context) + self.action_confirm() + self.action_assign() + self.action_done() - quants = pick.move_lines.quant_ids + quants = self.move_lines.quant_ids assert len(quants) == 2 assert quants.mapped('qty') == [11.0, 1.0] assert [round(c, 2) for c in quants.mapped('cost')] == [1.42, 1.38] @@ -144,20 +140,19 @@ - I compute the landed cost using Compute button - - !python {model: stock.landed.cost}: | - self.compute_landed_cost(cr, uid, [ref("stock_landed_cost_3")]) + !python {model: stock.landed.cost, id: stock_landed_cost_3}: | + self.compute_landed_cost() - I check the valuation adjustment lines - - !python {model: stock.landed.cost}: | - landed_cost = self.browse(cr, uid, ref("stock_landed_cost_3")) - for valuation in landed_cost.valuation_adjustment_lines: + !python {model: stock.landed.cost, id: stock_landed_cost_3}: | + for valuation in self.valuation_adjustment_lines: assert valuation.additional_landed_cost == 11 - I confirm the landed cost - - !python {model: stock.landed.cost}: | - self.button_validate(cr, uid, [ref("stock_landed_cost_3")]) + !python {model: stock.landed.cost, id: stock_landed_cost_3}: | + self.button_validate() - I check that the landed cost is now "Closed" and that it has an accounting entry - @@ -167,9 +162,8 @@ - I check the quants quantity and cost - - !python {model: stock.landed.cost}: | - landed_cost = self.browse(cr, uid, ref("stock_landed_cost_3")) - for valuation in landed_cost.valuation_adjustment_lines: + !python {model: stock.landed.cost, id: stock_landed_cost_3}: | + for valuation in self.valuation_adjustment_lines: quants = valuation.move_id.quant_ids assert quants.mapped('qty') == [11.0, 1.0] assert [round(c, 2) for c in quants.mapped('cost')] == [2.34, 2.26] |
