[FIX] test: avoid getting error when trying to send an email to the newly created...
[odoo/odoo.git] / addons / account / test / account_change_currency.yml
1 -
2   In order to test change currency wizard I create an invoice with currency "EUR" and change it to "USD" using the wizard
3 -
4   !record {model: account.invoice, id: account_invoice_currency}:
5     account_id: account.a_recv
6     company_id: base.main_company
7     currency_id: base.EUR
8     invoice_line:
9       - account_id: account.a_sale
10         name: '[PCSC234] PC Assemble SC234'
11         price_unit: 450.0
12         quantity: 1.0
13         product_id: product.product_product_3
14         uos_id: product.product_uom_unit
15     journal_id: account.sales_journal
16     partner_id: base.res_partner_12
17     reference_type: none
18
19 -
20   I check that Initially customer invoice is in the draft state
21 -
22   !assert {model: account.invoice, id: account_invoice_currency, string: Customer Invoice is in Draft state}:
23     - state == 'draft'
24 -
25   Now I select USD as new currency
26 -
27   !record {model: account.change.currency, id: account_change_currency_0}:
28     currency_id: base.USD
29 -
30   I clicked on Change Currency button to change the currency
31 -
32   !python {model: account.change.currency}: |
33     self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
34       "active_model": "account.invoice", "tz": False, "active_ids":
35       [ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
36     })
37     self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
38       "active_model": "account.invoice", "tz": False, "active_ids":
39       [ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
40     })
41 -
42   I change the state of invoice to proforma2 by clicking PRO-FORMA button
43 -
44   !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_currency}
45 -
46   I check that now customer invoice is in the "proforma2" state
47 -
48   !assert {model: account.invoice, id: account_invoice_currency}:
49     - state == 'proforma2'
50 -
51   I can't change the currency of invoice when it is not in draft state so I change the state to cancel
52 -
53   !workflow {model: account.invoice, action: invoice_cancel, ref: account_invoice_currency}
54 -
55   I change the state to "Draft"
56 -
57   !python {model: account.invoice}: |
58     self.action_cancel_draft(cr, uid, [ref("account_invoice_currency")], {"lang": 'en_US',
59       "tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("account.menu_action_invoice_tree1")],
60       "type": "out_invoice", "active_id": ref("account.menu_action_invoice_tree1"),
61       })
62 -
63   I change the currency.
64 -
65   !record {model: account.change.currency, id: account_change_currency_0}:
66     currency_id: base.USD
67 -
68   I clicked on Change Currency button to change the currency
69 -
70   !python {model: account.change.currency}: |
71     self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
72       "active_model": "account.invoice", "tz": False, "active_ids":
73       [ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
74       })
75 -
76   I check that the currency is changed successfully
77 -
78   !assert {model: account.invoice, id: account_invoice_currency, string: Currency changed from EUR to USD}:
79     - currency_id.id == ref("base.USD")