Merge lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina into lp:openerp-venezuela-localization
- l10n_ve_fiscal_req-debit_credit-dev_sabrina
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina |
Merge into: | lp:openerp-venezuela-localization |
Diff against target: |
1399 lines (+1242/-68) 4 files modified
l10n_ve_fiscal_requirements/__openerp__.py (+2/-0) l10n_ve_fiscal_requirements/test/account_customer_refund.yml (+602/-0) l10n_ve_fiscal_requirements/test/account_supplier_refund.yml (+622/-0) l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py (+16/-68) |
To merge this branch: | bzr merge lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sabrina Romero - http://www.vauxoo.com | Needs Resubmitting | ||
hbto [Vauxoo] http://www.vauxoo.com | Approve | ||
Review via email: mp+202785@code.launchpad.net |
Commit message
Description of the change
[FIX] Changes for compatibility with debit_credit_note dependency. Removing redundancy.
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) : | # |
- 975. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] Methods belonging to OVL were removed of debit_credit_note module.
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote : | # |
- 976. By Sabrina Romero - http://www.vauxoo.com
-
[ADD] Refund tests added for customer and supplier.
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote : | # |
[ADD] Refund tests added for customer and supplier.
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote : | # |
It LGTM,
I will make a last revision and after testing the whole OVL
with this new proposal and if everything goes fine I will
merge it today.
Best Regards.
- 977. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] amount_total correct assignment.
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote : | # |
LGTM
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote : | # |
Will be merged when AV70 fixess in Sabrina's branches are merged
- 978. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] Using browse method instead read and splitting date removed.
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote : | # |
[FIX] Using browse method instead read and splitting date removed.
Tested to review 978, working!
Unmerged revisions
- 978. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] Using browse method instead read and splitting date removed.
- 977. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] amount_total correct assignment.
- 976. By Sabrina Romero - http://www.vauxoo.com
-
[ADD] Refund tests added for customer and supplier.
- 975. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] Methods belonging to OVL were removed of debit_credit_note module.
- 974. By Sabrina Romero - http://www.vauxoo.com
-
[FIX] Changes for compatibility with debit_credit_note dependency.
Preview Diff
1 | === modified file 'l10n_ve_fiscal_requirements/__openerp__.py' | |||
2 | --- l10n_ve_fiscal_requirements/__openerp__.py 2014-01-20 13:03:50 +0000 | |||
3 | +++ l10n_ve_fiscal_requirements/__openerp__.py 2014-02-11 00:22:34 +0000 | |||
4 | @@ -96,6 +96,8 @@ | |||
5 | 96 | 'test': [ | 96 | 'test': [ |
6 | 97 | 'test/account_customer_invoice.yml', | 97 | 'test/account_customer_invoice.yml', |
7 | 98 | 'test/account_supplier_invoice.yml', | 98 | 'test/account_supplier_invoice.yml', |
8 | 99 | 'test/account_customer_refund.yml', | ||
9 | 100 | 'test/account_supplier_refund.yml', | ||
10 | 99 | 'test/fr_vat_search_test.yml', | 101 | 'test/fr_vat_search_test.yml', |
11 | 100 | 'test/fr_ut_test.yml', | 102 | 'test/fr_ut_test.yml', |
12 | 101 | 'test/fr_vat_test.yml', | 103 | 'test/fr_vat_test.yml', |
13 | 102 | 104 | ||
14 | === added file 'l10n_ve_fiscal_requirements/test/account_customer_refund.yml' | |||
15 | --- l10n_ve_fiscal_requirements/test/account_customer_refund.yml 1970-01-01 00:00:00 +0000 | |||
16 | +++ l10n_ve_fiscal_requirements/test/account_customer_refund.yml 2014-02-11 00:22:34 +0000 | |||
17 | @@ -0,0 +1,602 @@ | |||
18 | 1 | - | ||
19 | 2 | I set the context that will be used for the encoding of all the invoices of this file | ||
20 | 3 | - | ||
21 | 4 | !context | ||
22 | 5 | 'type': 'out_invoice' | ||
23 | 6 | - | ||
24 | 7 | 1.- In order to test account refund with "Create a draft refund" method | ||
25 | 8 | - | ||
26 | 9 | 1.1.- I create a customer invoice | ||
27 | 10 | - | ||
28 | 11 | !record {model: account.invoice, id: account_invoice_customer0, view: account.invoice_form}: &customer_invoice | ||
29 | 12 | payment_term: account.account_payment_term_advance | ||
30 | 13 | journal_id: account.sales_journal | ||
31 | 14 | partner_id: base.res_partner_3 | ||
32 | 15 | reference_type: none | ||
33 | 16 | name: 'Test Customer Invoice - debit_credit_note' | ||
34 | 17 | invoice_line: | ||
35 | 18 | - product_id: product.product_product_5 | ||
36 | 19 | price_unit: 850.0 | ||
37 | 20 | quantity: 1.0 | ||
38 | 21 | - | ||
39 | 22 | 1.2.- I check that Initially customer invoice state is "Draft" | ||
40 | 23 | - | ||
41 | 24 | !assert {model: account.invoice, id: account_invoice_customer0}: | ||
42 | 25 | - state == 'draft' | ||
43 | 26 | - | ||
44 | 27 | 1.3.- I check that the customer invoice is a "Customer Invoice" | ||
45 | 28 | - | ||
46 | 29 | !assert {model: account.invoice, id: account_invoice_customer0, string: This is not a customer invoice}: | ||
47 | 30 | - type == 'out_invoice' | ||
48 | 31 | - | ||
49 | 32 | 1.4.- I change the state of invoice to open by clicking Validate button | ||
50 | 33 | - | ||
51 | 34 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0} | ||
52 | 35 | - | ||
53 | 36 | 1.5.- I check that the invoice state is now "Open" | ||
54 | 37 | - | ||
55 | 38 | !assert {model: account.invoice, id: account_invoice_customer0}: | ||
56 | 39 | - state == 'open' | ||
57 | 40 | - | ||
58 | 41 | 1.6.- I create a customer refund using the method "Create a draft refund" and | ||
59 | 42 | check the state of the account invoice refund resulting | ||
60 | 43 | - | ||
61 | 44 | !python {model: account.invoice.refund}: | | ||
62 | 45 | import time | ||
63 | 46 | values = { | ||
64 | 47 | 'date': time.strftime('%Y-%m-%d'), | ||
65 | 48 | 'period': self.pool.get('account.period').find( | ||
66 | 49 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
67 | 50 | 'journal_id': ref('account.refund_expenses_journal'), | ||
68 | 51 | 'description': 'Desde el test', | ||
69 | 52 | 'filter_refund': 'refund', | ||
70 | 53 | } | ||
71 | 54 | wzr_id = self.create(cr, uid, values) | ||
72 | 55 | assert wzr_id, 'The wizard instance was not created.' | ||
73 | 56 | context['wzr_id'] = wzr_id | ||
74 | 57 | context['active_ids'] = [ref('account_invoice_customer0')] | ||
75 | 58 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
76 | 59 | assert rfnd_id, 'The refund was not created.' | ||
77 | 60 | context['rfnd_id'] = rfnd_id | ||
78 | 61 | obj_inv = self.pool.get('account.invoice') | ||
79 | 62 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
80 | 63 | assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.' | ||
81 | 64 | - | ||
82 | 65 | 1.7.- I check the correct asigning of parent_id in the customer refund created, for that | ||
83 | 66 | the customer refund must have the customer invoice id in the fiel parent_id | ||
84 | 67 | - | ||
85 | 68 | !python {model: account.invoice.refund}: | | ||
86 | 69 | obj_inv = self.pool.get('account.invoice') | ||
87 | 70 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
88 | 71 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer0')) | ||
89 | 72 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
90 | 73 | - | ||
91 | 74 | 2.- In order to test account refund with "Create refund and reconcile" method | ||
92 | 75 | - | ||
93 | 76 | 2.1.- I create a new customer invoice | ||
94 | 77 | - | ||
95 | 78 | !record {model: account.invoice, id: account_invoice_customer1, view: account.invoice_form }: | ||
96 | 79 | <<: *customer_invoice | ||
97 | 80 | - | ||
98 | 81 | 2.2.- I check that Initially customer invoice state is "Draft" | ||
99 | 82 | - | ||
100 | 83 | !assert {model: account.invoice, id: account_invoice_customer1}: | ||
101 | 84 | - state == 'draft' | ||
102 | 85 | - | ||
103 | 86 | 2.3.- I check that the customer invoice is a "Customer Invoice" | ||
104 | 87 | - | ||
105 | 88 | !assert {model: account.invoice, id: account_invoice_customer1, string: This is not a customer invoice}: | ||
106 | 89 | - type == 'out_invoice' | ||
107 | 90 | - | ||
108 | 91 | 2.4.- I change the state of invoice to open by clicking Validate button | ||
109 | 92 | - | ||
110 | 93 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer1} | ||
111 | 94 | - | ||
112 | 95 | 2.5.- I check that the invoice state is now "Open" | ||
113 | 96 | - | ||
114 | 97 | !assert {model: account.invoice, id: account_invoice_customer1}: | ||
115 | 98 | - state == 'open' | ||
116 | 99 | - | ||
117 | 100 | 2.6.- I create a customer refund using the method "Create refund and reconcile" and | ||
118 | 101 | check the state of the account invoice refund resulting | ||
119 | 102 | - | ||
120 | 103 | !python {model: account.invoice.refund}: | | ||
121 | 104 | import time | ||
122 | 105 | values = { | ||
123 | 106 | 'date': time.strftime('%Y-%m-%d'), | ||
124 | 107 | 'period': self.pool.get('account.period').find( | ||
125 | 108 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
126 | 109 | 'journal_id': ref('account.refund_expenses_journal'), | ||
127 | 110 | 'description': 'Desde el test', | ||
128 | 111 | 'filter_refund': 'cancel', | ||
129 | 112 | } | ||
130 | 113 | wzr_id = self.create(cr, uid, values) | ||
131 | 114 | assert wzr_id, 'The wizard instance was not created.' | ||
132 | 115 | context['wzr_id'] = wzr_id | ||
133 | 116 | context['active_ids'] = [ref('account_invoice_customer1')] | ||
134 | 117 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
135 | 118 | assert rfnd_id, 'The refund was not created.' | ||
136 | 119 | context['rfnd_id'] = rfnd_id | ||
137 | 120 | obj_inv = self.pool.get('account.invoice') | ||
138 | 121 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
139 | 122 | assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.' | ||
140 | 123 | - | ||
141 | 124 | 2.7.- I check the correct asigning of parent_id in the customer refund created, for that | ||
142 | 125 | the customer refund must have the customer invoice id in the fiel parent_id | ||
143 | 126 | - | ||
144 | 127 | !python {model: account.invoice.refund}: | | ||
145 | 128 | obj_inv = self.pool.get('account.invoice') | ||
146 | 129 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
147 | 130 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer1')) | ||
148 | 131 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
149 | 132 | - | ||
150 | 133 | 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice" | ||
151 | 134 | method | ||
152 | 135 | - | ||
153 | 136 | 3.1.- I create a new customer invoice | ||
154 | 137 | - | ||
155 | 138 | !record {model: account.invoice, id: account_invoice_customer2, view: account.invoice_form }: | ||
156 | 139 | <<: *customer_invoice | ||
157 | 140 | - | ||
158 | 141 | 3.2.- I check that Initially customer invoice state is "Draft" | ||
159 | 142 | - | ||
160 | 143 | !assert {model: account.invoice, id: account_invoice_customer2}: | ||
161 | 144 | - state == 'draft' | ||
162 | 145 | - | ||
163 | 146 | 3.3.- I check that the customer invoice is a "Customer Invoice" | ||
164 | 147 | - | ||
165 | 148 | !assert {model: account.invoice, id: account_invoice_customer2, string: This is not a customer invoice}: | ||
166 | 149 | - type == 'out_invoice' | ||
167 | 150 | - | ||
168 | 151 | 3.4.- I change the state of invoice to open by clicking Validate button | ||
169 | 152 | - | ||
170 | 153 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer2} | ||
171 | 154 | - | ||
172 | 155 | 3.5.- I check that the invoice state is now "Open" | ||
173 | 156 | - | ||
174 | 157 | !assert {model: account.invoice, id: account_invoice_customer2}: | ||
175 | 158 | - state == 'open' | ||
176 | 159 | - | ||
177 | 160 | 3.6.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and | ||
178 | 161 | check the state of the account invoice refund resulting | ||
179 | 162 | - | ||
180 | 163 | !python {model: account.invoice.refund}: | | ||
181 | 164 | import time | ||
182 | 165 | values = { | ||
183 | 166 | 'date': time.strftime('%Y-%m-%d'), | ||
184 | 167 | 'period': self.pool.get('account.period').find( | ||
185 | 168 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
186 | 169 | 'journal_id': ref('account.refund_expenses_journal'), | ||
187 | 170 | 'description': 'Desde el test', | ||
188 | 171 | 'filter_refund': 'modify', | ||
189 | 172 | } | ||
190 | 173 | wzr_id = self.create(cr, uid, values) | ||
191 | 174 | assert wzr_id, 'The wizard instance was not created.' | ||
192 | 175 | context['wzr_id'] = wzr_id | ||
193 | 176 | context['active_ids'] = [ref('account_invoice_customer2')] | ||
194 | 177 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
195 | 178 | assert rfnd_id, 'The refund was not created.' | ||
196 | 179 | context['rfnd_id'] = rfnd_id | ||
197 | 180 | obj_inv = self.pool.get('account.invoice') | ||
198 | 181 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
199 | 182 | assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.' | ||
200 | 183 | - | ||
201 | 184 | 3.7.- I check the correct asigning of parent_id in the customer refund created, for that | ||
202 | 185 | the customer refund must have the customer invoice id in the fiel parent_id | ||
203 | 186 | - | ||
204 | 187 | !python {model: account.invoice.refund}: | | ||
205 | 188 | obj_inv = self.pool.get('account.invoice') | ||
206 | 189 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
207 | 190 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer2')) | ||
208 | 191 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
209 | 192 | - | ||
210 | 193 | 3.8.- I check that the new customer invoice was created in Draft state | ||
211 | 194 | - | ||
212 | 195 | !python {model: account.invoice.refund}: | | ||
213 | 196 | obj_inv = self.pool.get('account.invoice') | ||
214 | 197 | inv_src = obj_inv.search(cr, uid, [], order='id') | ||
215 | 198 | customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1]) | ||
216 | 199 | assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.' | ||
217 | 200 | - | ||
218 | 201 | 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice | ||
219 | 202 | - | ||
220 | 203 | 4.1.- I create a new partner | ||
221 | 204 | - | ||
222 | 205 | !record {model: 'res.partner', id: res_partner8}: | ||
223 | 206 | name: Juan Perez | ||
224 | 207 | use_parent_address: True | ||
225 | 208 | function: Tests | ||
226 | 209 | email: juan@perez.com | ||
227 | 210 | - | ||
228 | 211 | 4.2.- I create a Sale Journal. | ||
229 | 212 | - | ||
230 | 213 | !record {model: account.journal, id: sale_journal_debit}: | ||
231 | 214 | code: sjou_test | ||
232 | 215 | company_id: base.main_company | ||
233 | 216 | name: Sale Journal For Debit Credit Note Tests | ||
234 | 217 | sequence_id: account.sequence_sale_journal | ||
235 | 218 | type: sale | ||
236 | 219 | - | ||
237 | 220 | 4.3.- I create a new customer invoice | ||
238 | 221 | - | ||
239 | 222 | !record {model: account.invoice, id: account_invoice_customer3}: | ||
240 | 223 | account_id: account.a_recv | ||
241 | 224 | company_id: base.main_company | ||
242 | 225 | currency_id: base.EUR | ||
243 | 226 | invoice_line: | ||
244 | 227 | - account_id: account.a_sale | ||
245 | 228 | name: '[PCSC234] PC Assemble SC234' | ||
246 | 229 | price_unit: 450.0 | ||
247 | 230 | quantity: 1.0 | ||
248 | 231 | product_id: product.product_product_3 | ||
249 | 232 | uos_id: product.product_uom_unit | ||
250 | 233 | journal_id: sale_journal_debit | ||
251 | 234 | partner_id: res_partner8 | ||
252 | 235 | - | ||
253 | 236 | 4.4.- I check that Initially customer invoice state is "Draft" | ||
254 | 237 | - | ||
255 | 238 | !assert {model: account.invoice, id: account_invoice_customer3}: | ||
256 | 239 | - state == 'draft' | ||
257 | 240 | - | ||
258 | 241 | 4.5.- I check that the customer invoice is a "Customer Invoice" | ||
259 | 242 | - | ||
260 | 243 | !assert {model: account.invoice, id: account_invoice_customer3, string: This is not a customer invoice}: | ||
261 | 244 | - type == 'out_invoice' | ||
262 | 245 | - | ||
263 | 246 | 4.6.- I change the state of invoice to open by clicking Validate button | ||
264 | 247 | - | ||
265 | 248 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer3} | ||
266 | 249 | - | ||
267 | 250 | 4.7.- I check that the invoice state is now "Open" | ||
268 | 251 | - | ||
269 | 252 | !assert {model: account.invoice, id: account_invoice_customer3}: | ||
270 | 253 | - state == 'open' | ||
271 | 254 | - | ||
272 | 255 | 4.8.- I check that a payment entry gets created in the account.move.line | ||
273 | 256 | - | ||
274 | 257 | !python {model: account.invoice}: | | ||
275 | 258 | acc_id=self.browse(cr, uid, ref("account_invoice_customer3")) | ||
276 | 259 | assert(acc_id.move_id) | ||
277 | 260 | - | ||
278 | 261 | 4.9.- I create a Cash Journal. | ||
279 | 262 | - | ||
280 | 263 | !record {model: account.journal, id: cash_journal_debit}: | ||
281 | 264 | code: cjou_test | ||
282 | 265 | company_id: base.main_company | ||
283 | 266 | name: Cash Journal For Debit Credit Note Tests | ||
284 | 267 | sequence_id: account.sequence_cash_journal | ||
285 | 268 | type: cash | ||
286 | 269 | - | ||
287 | 270 | 4.10.- I will create and post an account voucher with the amount total | ||
288 | 271 | of the customer invoice created for the partner Juan Perez. | ||
289 | 272 | - | ||
290 | 273 | !python {model: account.voucher}: | | ||
291 | 274 | import netsvc | ||
292 | 275 | import time | ||
293 | 276 | vals = {} | ||
294 | 277 | amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer3')], context=None)[0].amount_total | ||
295 | 278 | journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None) | ||
296 | 279 | res = self.onchange_partner_id(cr, uid, [], ref("res_partner8"), journal_id, 0.0, 1, ttype='receipt', date=False) | ||
297 | 280 | vals = { | ||
298 | 281 | 'account_id': ref('account.cash'), | ||
299 | 282 | 'amount': amount_total, | ||
300 | 283 | 'company_id': ref('base.main_company'), | ||
301 | 284 | 'journal_id': ref('cash_journal_debit'), | ||
302 | 285 | 'partner_id': ref('res_partner8'), | ||
303 | 286 | 'period_id': self.pool.get('account.period').find( | ||
304 | 287 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
305 | 288 | 'type': 'receipt', | ||
306 | 289 | } | ||
307 | 290 | if not res['value']['line_cr_ids']: | ||
308 | 291 | res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}] | ||
309 | 292 | res['value']['line_cr_ids'][0]['amount'] = amount_total | ||
310 | 293 | vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']] | ||
311 | 294 | id = self.create(cr, uid, vals) | ||
312 | 295 | voucher_id = self.browse(cr, uid, id) | ||
313 | 296 | assert (voucher_id.state=='draft'), "Voucher is not in draft state" | ||
314 | 297 | wf_service = netsvc.LocalService("workflow") | ||
315 | 298 | wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr) | ||
316 | 299 | - | ||
317 | 300 | 4.11.- I check if the state of the invoice is "Paid" | ||
318 | 301 | - | ||
319 | 302 | !assert {model: account.invoice, id: account_invoice_customer3}: | ||
320 | 303 | - state == 'paid' | ||
321 | 304 | - | ||
322 | 305 | 4.12.- I modified the sale journal record so it can cancel invoice | ||
323 | 306 | - | ||
324 | 307 | !record {model: account.journal, id: sale_journal_debit}: | ||
325 | 308 | update_posted: 1 | ||
326 | 309 | - | ||
327 | 310 | 4.13.- I modified the cash journal record so it can cancel invoice | ||
328 | 311 | - | ||
329 | 312 | !record {model: account.journal, id: cash_journal_debit}: | ||
330 | 313 | update_posted: 1 | ||
331 | 314 | - | ||
332 | 315 | 4.14.- I create a Sale Refund Journal. | ||
333 | 316 | - | ||
334 | 317 | !record {model: account.journal, id: sale_refund_journal_debit}: | ||
335 | 318 | code: csrjou_test | ||
336 | 319 | company_id: base.main_company | ||
337 | 320 | name: Sale Refund Journal For Debit Credit Note Tests | ||
338 | 321 | sequence_id: account.sequence_refund_sales_journal | ||
339 | 322 | type: sale_refund | ||
340 | 323 | - | ||
341 | 324 | 4.15.- I create a customer refund using the method "Create a draft refund" and | ||
342 | 325 | check the state of the account invoice refund resulting | ||
343 | 326 | - | ||
344 | 327 | !python {model: account.invoice.refund}: | | ||
345 | 328 | import time | ||
346 | 329 | values = { | ||
347 | 330 | 'date': time.strftime('%Y-%m-%d'), | ||
348 | 331 | 'period': self.pool.get('account.period').find( | ||
349 | 332 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
350 | 333 | 'journal_id': ref('sale_refund_journal_debit'), | ||
351 | 334 | 'description': 'Desde el test', | ||
352 | 335 | 'filter_refund': 'refund', | ||
353 | 336 | } | ||
354 | 337 | wzr_id = self.create(cr, uid, values) | ||
355 | 338 | assert wzr_id, 'The wizard instance was not created.' | ||
356 | 339 | context['wzr_id'] = wzr_id | ||
357 | 340 | context['active_ids'] = [ref('account_invoice_customer3')] | ||
358 | 341 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
359 | 342 | assert rfnd_id, 'The refund was not created.' | ||
360 | 343 | context['rfnd_id'] = rfnd_id | ||
361 | 344 | obj_inv = self.pool.get('account.invoice') | ||
362 | 345 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
363 | 346 | assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.' | ||
364 | 347 | - | ||
365 | 348 | 4.16.- I check the correct asigning of parent_id in the customer refund created, for that | ||
366 | 349 | the customer refund must have the customer invoice id in the fiel parent_id | ||
367 | 350 | - | ||
368 | 351 | !python {model: account.invoice.refund}: | | ||
369 | 352 | obj_inv = self.pool.get('account.invoice') | ||
370 | 353 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
371 | 354 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer3')) | ||
372 | 355 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
373 | 356 | - | ||
374 | 357 | 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice | ||
375 | 358 | - | ||
376 | 359 | 5.1.- I create a new partner | ||
377 | 360 | - | ||
378 | 361 | !record {model: 'res.partner', id: res_partner7}: | ||
379 | 362 | name: Pedro Perez | ||
380 | 363 | use_parent_address: True | ||
381 | 364 | function: Tests | ||
382 | 365 | email: pedro@perez.com | ||
383 | 366 | - | ||
384 | 367 | 5.2.- I create a new customer invoice | ||
385 | 368 | - | ||
386 | 369 | !record {model: account.invoice, id: account_invoice_customer4}: | ||
387 | 370 | account_id: account.a_recv | ||
388 | 371 | company_id: base.main_company | ||
389 | 372 | currency_id: base.EUR | ||
390 | 373 | invoice_line: | ||
391 | 374 | - account_id: account.a_sale | ||
392 | 375 | name: '[PCSC234] PC Assemble SC234' | ||
393 | 376 | price_unit: 450.0 | ||
394 | 377 | quantity: 1.0 | ||
395 | 378 | product_id: product.product_product_3 | ||
396 | 379 | uos_id: product.product_uom_unit | ||
397 | 380 | journal_id: sale_journal_debit | ||
398 | 381 | partner_id: res_partner7 | ||
399 | 382 | - | ||
400 | 383 | 5.3.- I check that Initially customer invoice state is "Draft" | ||
401 | 384 | - | ||
402 | 385 | !assert {model: account.invoice, id: account_invoice_customer4}: | ||
403 | 386 | - state == 'draft' | ||
404 | 387 | - | ||
405 | 388 | 5.4.- I check that the customer invoice is a "Customer Invoice" | ||
406 | 389 | - | ||
407 | 390 | !assert {model: account.invoice, id: account_invoice_customer4, string: This is not a customer invoice}: | ||
408 | 391 | - type == 'out_invoice' | ||
409 | 392 | - | ||
410 | 393 | 5.5.- I change the state of invoice to open by clicking Validate button | ||
411 | 394 | - | ||
412 | 395 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer4} | ||
413 | 396 | - | ||
414 | 397 | 5.6.- I check that the invoice state is now "Open" | ||
415 | 398 | - | ||
416 | 399 | !assert {model: account.invoice, id: account_invoice_customer4}: | ||
417 | 400 | - state == 'open' | ||
418 | 401 | - | ||
419 | 402 | 5.7.- I check that a payment entry gets created in the account.move.line | ||
420 | 403 | - | ||
421 | 404 | !python {model: account.invoice}: | | ||
422 | 405 | acc_id=self.browse(cr, uid, ref("account_invoice_customer4")) | ||
423 | 406 | assert(acc_id.move_id) | ||
424 | 407 | - | ||
425 | 408 | 5.8.- I will create and post an account voucher with the amount total | ||
426 | 409 | of the customer invoice created for the partner Pedro Perez. | ||
427 | 410 | - | ||
428 | 411 | !python {model: account.voucher}: | | ||
429 | 412 | import netsvc | ||
430 | 413 | import time | ||
431 | 414 | vals = {} | ||
432 | 415 | amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer4')], context=None)[0].amount_total | ||
433 | 416 | journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None) | ||
434 | 417 | res = self.onchange_partner_id(cr, uid, [], ref("res_partner7"), journal_id, 0.0, 1, ttype='receipt', date=False) | ||
435 | 418 | vals = { | ||
436 | 419 | 'account_id': ref('account.cash'), | ||
437 | 420 | 'amount': amount_total, | ||
438 | 421 | 'company_id': ref('base.main_company'), | ||
439 | 422 | 'journal_id': ref('cash_journal_debit'), | ||
440 | 423 | 'partner_id': ref('res_partner7'), | ||
441 | 424 | 'period_id': self.pool.get('account.period').find( | ||
442 | 425 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
443 | 426 | 'type': 'receipt', | ||
444 | 427 | } | ||
445 | 428 | if not res['value']['line_cr_ids']: | ||
446 | 429 | res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}] | ||
447 | 430 | res['value']['line_cr_ids'][0]['amount'] = amount_total | ||
448 | 431 | vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']] | ||
449 | 432 | id = self.create(cr, uid, vals) | ||
450 | 433 | voucher_id = self.browse(cr, uid, id) | ||
451 | 434 | assert (voucher_id.state=='draft'), "Voucher is not in draft state" | ||
452 | 435 | wf_service = netsvc.LocalService("workflow") | ||
453 | 436 | wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr) | ||
454 | 437 | - | ||
455 | 438 | 5.9.- I check if the state of the invoice is "Paid" | ||
456 | 439 | - | ||
457 | 440 | !assert {model: account.invoice, id: account_invoice_customer4}: | ||
458 | 441 | - state == 'paid' | ||
459 | 442 | - | ||
460 | 443 | 5.10.- I create a customer refund using the method "Create refund and reconcile" and | ||
461 | 444 | check the state of the account invoice refund resulting | ||
462 | 445 | - | ||
463 | 446 | !python {model: account.invoice.refund}: | | ||
464 | 447 | import time | ||
465 | 448 | values = { | ||
466 | 449 | 'date': time.strftime('%Y-%m-%d'), | ||
467 | 450 | 'period': self.pool.get('account.period').find( | ||
468 | 451 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
469 | 452 | 'journal_id': ref('sale_refund_journal_debit'), | ||
470 | 453 | 'description': 'Desde el test', | ||
471 | 454 | 'filter_refund': 'cancel', | ||
472 | 455 | } | ||
473 | 456 | wzr_id = self.create(cr, uid, values) | ||
474 | 457 | assert wzr_id, 'The wizard instance was not created.' | ||
475 | 458 | context['wzr_id'] = wzr_id | ||
476 | 459 | context['active_ids'] = [ref('account_invoice_customer4')] | ||
477 | 460 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
478 | 461 | assert rfnd_id, 'The refund was not created.' | ||
479 | 462 | context['rfnd_id'] = rfnd_id | ||
480 | 463 | obj_inv = self.pool.get('account.invoice') | ||
481 | 464 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
482 | 465 | assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.' | ||
483 | 466 | - | ||
484 | 467 | 5.11.- I check the correct asigning of parent_id in the customer refund created, for that | ||
485 | 468 | the customer refund must have the customer invoice id in the fiel parent_id | ||
486 | 469 | - | ||
487 | 470 | !python {model: account.invoice.refund}: | | ||
488 | 471 | obj_inv = self.pool.get('account.invoice') | ||
489 | 472 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
490 | 473 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer4')) | ||
491 | 474 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
492 | 475 | - | ||
493 | 476 | 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice" | ||
494 | 477 | method in a "Paid" invoice | ||
495 | 478 | - | ||
496 | 479 | 6.1.- I create a new partner | ||
497 | 480 | - | ||
498 | 481 | !record {model: 'res.partner', id: res_partner9}: | ||
499 | 482 | name: Maria Perez | ||
500 | 483 | use_parent_address: True | ||
501 | 484 | function: Tests | ||
502 | 485 | email: maria@perez.com | ||
503 | 486 | - | ||
504 | 487 | 6.2.- I create a new customer invoice | ||
505 | 488 | - | ||
506 | 489 | !record {model: account.invoice, id: account_invoice_customer5}: | ||
507 | 490 | account_id: account.a_recv | ||
508 | 491 | company_id: base.main_company | ||
509 | 492 | currency_id: base.EUR | ||
510 | 493 | invoice_line: | ||
511 | 494 | - account_id: account.a_sale | ||
512 | 495 | name: '[PCSC234] PC Assemble SC234' | ||
513 | 496 | price_unit: 450.0 | ||
514 | 497 | quantity: 1.0 | ||
515 | 498 | product_id: product.product_product_3 | ||
516 | 499 | uos_id: product.product_uom_unit | ||
517 | 500 | journal_id: sale_journal_debit | ||
518 | 501 | partner_id: res_partner9 | ||
519 | 502 | - | ||
520 | 503 | 6.3.- I check that Initially customer invoice state is "Draft" | ||
521 | 504 | - | ||
522 | 505 | !assert {model: account.invoice, id: account_invoice_customer5}: | ||
523 | 506 | - state == 'draft' | ||
524 | 507 | - | ||
525 | 508 | 6.4.- I check that the customer invoice is a "Customer Invoice" | ||
526 | 509 | - | ||
527 | 510 | !assert {model: account.invoice, id: account_invoice_customer5, string: This is not a customer invoice}: | ||
528 | 511 | - type == 'out_invoice' | ||
529 | 512 | - | ||
530 | 513 | 6.5.- I change the state of invoice to open by clicking Validate button | ||
531 | 514 | - | ||
532 | 515 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer5} | ||
533 | 516 | - | ||
534 | 517 | 6.6.- I check that the invoice state is now "Open" | ||
535 | 518 | - | ||
536 | 519 | !assert {model: account.invoice, id: account_invoice_customer5}: | ||
537 | 520 | - state == 'open' | ||
538 | 521 | - | ||
539 | 522 | 6.7.- I check that a payment entry gets created in the account.move.line | ||
540 | 523 | - | ||
541 | 524 | !python {model: account.invoice}: | | ||
542 | 525 | acc_id=self.browse(cr, uid, ref("account_invoice_customer5")) | ||
543 | 526 | assert(acc_id.move_id) | ||
544 | 527 | - | ||
545 | 528 | 6.8.- I will create and post an account voucher with the amount total | ||
546 | 529 | of the customer invoice created for the partner Maria Perez. | ||
547 | 530 | - | ||
548 | 531 | !python {model: account.voucher}: | | ||
549 | 532 | import netsvc | ||
550 | 533 | import time | ||
551 | 534 | vals = {} | ||
552 | 535 | amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer5')], context=None)[0].amount_total | ||
553 | 536 | journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None) | ||
554 | 537 | res = self.onchange_partner_id(cr, uid, [], ref("res_partner9"), journal_id, 0.0, 1, ttype='receipt', date=False) | ||
555 | 538 | vals = { | ||
556 | 539 | 'account_id': ref('account.cash'), | ||
557 | 540 | 'amount': amount_total, | ||
558 | 541 | 'company_id': ref('base.main_company'), | ||
559 | 542 | 'journal_id': ref('cash_journal_debit'), | ||
560 | 543 | 'partner_id': ref('res_partner9'), | ||
561 | 544 | 'period_id': self.pool.get('account.period').find( | ||
562 | 545 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
563 | 546 | 'type': 'receipt', | ||
564 | 547 | } | ||
565 | 548 | if not res['value']['line_cr_ids']: | ||
566 | 549 | res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}] | ||
567 | 550 | res['value']['line_cr_ids'][0]['amount'] = amount_total | ||
568 | 551 | vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']] | ||
569 | 552 | id = self.create(cr, uid, vals) | ||
570 | 553 | voucher_id = self.browse(cr, uid, id) | ||
571 | 554 | assert (voucher_id.state=='draft'), "Voucher is not in draft state" | ||
572 | 555 | wf_service = netsvc.LocalService("workflow") | ||
573 | 556 | wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr) | ||
574 | 557 | - | ||
575 | 558 | 6.9.- I check if the state of the invoice is "Paid" | ||
576 | 559 | - | ||
577 | 560 | !assert {model: account.invoice, id: account_invoice_customer5}: | ||
578 | 561 | - state == 'paid' | ||
579 | 562 | - | ||
580 | 563 | 6.10.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and | ||
581 | 564 | check the state of the account invoice refund resulting | ||
582 | 565 | - | ||
583 | 566 | !python {model: account.invoice.refund}: | | ||
584 | 567 | import time | ||
585 | 568 | values = { | ||
586 | 569 | 'date': time.strftime('%Y-%m-%d'), | ||
587 | 570 | 'period': self.pool.get('account.period').find( | ||
588 | 571 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
589 | 572 | 'journal_id': ref('sale_refund_journal_debit'), | ||
590 | 573 | 'description': 'Desde el test', | ||
591 | 574 | 'filter_refund': 'modify', | ||
592 | 575 | } | ||
593 | 576 | wzr_id = self.create(cr, uid, values) | ||
594 | 577 | assert wzr_id, 'The wizard instance was not created.' | ||
595 | 578 | context['wzr_id'] = wzr_id | ||
596 | 579 | context['active_ids'] = [ref('account_invoice_customer5')] | ||
597 | 580 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
598 | 581 | assert rfnd_id, 'The refund was not created.' | ||
599 | 582 | context['rfnd_id'] = rfnd_id | ||
600 | 583 | obj_inv = self.pool.get('account.invoice') | ||
601 | 584 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
602 | 585 | assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.' | ||
603 | 586 | - | ||
604 | 587 | 6.11.- I check the correct asigning of parent_id in the customer refund created, for that | ||
605 | 588 | the customer refund must have the customer invoice id in the fiel parent_id | ||
606 | 589 | - | ||
607 | 590 | !python {model: account.invoice.refund}: | | ||
608 | 591 | obj_inv = self.pool.get('account.invoice') | ||
609 | 592 | rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
610 | 593 | customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer5')) | ||
611 | 594 | assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.' | ||
612 | 595 | - | ||
613 | 596 | 6.12.- I check that the new customer invoice was created in Draft state | ||
614 | 597 | - | ||
615 | 598 | !python {model: account.invoice.refund}: | | ||
616 | 599 | obj_inv = self.pool.get('account.invoice') | ||
617 | 600 | inv_src = obj_inv.search(cr, uid, [], order='id') | ||
618 | 601 | customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1]) | ||
619 | 602 | assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.' | ||
620 | 0 | 603 | ||
621 | === added file 'l10n_ve_fiscal_requirements/test/account_supplier_refund.yml' | |||
622 | --- l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 1970-01-01 00:00:00 +0000 | |||
623 | +++ l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 2014-02-11 00:22:34 +0000 | |||
624 | @@ -0,0 +1,622 @@ | |||
625 | 1 | - | ||
626 | 2 | I set the context that will be used for the encoding of all the invoices of this file | ||
627 | 3 | - | ||
628 | 4 | !context | ||
629 | 5 | 'type': 'in_invoice' | ||
630 | 6 | - | ||
631 | 7 | 1.- In order to test account refund with "Create a draft refund" method | ||
632 | 8 | - | ||
633 | 9 | 1.1.- I create a supplier invoice | ||
634 | 10 | - | ||
635 | 11 | !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form }: &supplier_invoice | ||
636 | 12 | account_id: account.a_pay | ||
637 | 13 | company_id: base.main_company | ||
638 | 14 | currency_id: base.EUR | ||
639 | 15 | invoice_line: | ||
640 | 16 | - account_id: account.a_expense | ||
641 | 17 | name: '[PCSC234] PC Assemble SC234' | ||
642 | 18 | price_unit: 300.0 | ||
643 | 19 | product_id: product.product_product_3 | ||
644 | 20 | quantity: 10.0 | ||
645 | 21 | uos_id: product.product_uom_unit | ||
646 | 22 | journal_id: account.expenses_journal | ||
647 | 23 | partner_id: base.res_partner_12 | ||
648 | 24 | reference_type: none | ||
649 | 25 | type: 'in_invoice' | ||
650 | 26 | - | ||
651 | 27 | 1.2.- I check that Initially supplier invoice state is "Draft" | ||
652 | 28 | - | ||
653 | 29 | !assert {model: account.invoice, id: account_invoice_supplier0}: | ||
654 | 30 | - state == 'draft' | ||
655 | 31 | - | ||
656 | 32 | 1.3.- I check that the supplier invoice is a "Supplier Invoice" | ||
657 | 33 | - | ||
658 | 34 | !assert {model: account.invoice, id: account_invoice_supplier0, string: This is not a supplier invoice}: | ||
659 | 35 | - type == 'in_invoice' | ||
660 | 36 | - | ||
661 | 37 | 1.4.- I change the state of invoice to open by clicking Validate button | ||
662 | 38 | - | ||
663 | 39 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0} | ||
664 | 40 | - | ||
665 | 41 | 1.5.- I check that the invoice state is now "Open" | ||
666 | 42 | - | ||
667 | 43 | !assert {model: account.invoice, id: account_invoice_supplier0}: | ||
668 | 44 | - state == 'open' | ||
669 | 45 | - | ||
670 | 46 | 1.6.- I create a supplier refund using the method "Create a draft refund" and | ||
671 | 47 | check the state of the account invoice refund resulting | ||
672 | 48 | - | ||
673 | 49 | !python {model: account.invoice.refund}: | | ||
674 | 50 | import time | ||
675 | 51 | values = { | ||
676 | 52 | 'date': time.strftime('%Y-%m-%d'), | ||
677 | 53 | 'period': self.pool.get('account.period').find( | ||
678 | 54 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
679 | 55 | 'journal_id': ref('account.refund_expenses_journal'), | ||
680 | 56 | 'description': 'Desde el test', | ||
681 | 57 | 'nro_ctrl': 'Desde el test', | ||
682 | 58 | 'filter_refund': 'refund', | ||
683 | 59 | } | ||
684 | 60 | wzr_id = self.create(cr, uid, values) | ||
685 | 61 | context['wzr_id'] = wzr_id | ||
686 | 62 | context['active_ids'] = [ref('account_invoice_supplier0')] | ||
687 | 63 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
688 | 64 | context['rfnd_id'] = rfnd_id | ||
689 | 65 | obj_inv = self.pool.get('account.invoice') | ||
690 | 66 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
691 | 67 | assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.' | ||
692 | 68 | - | ||
693 | 69 | 1.7.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
694 | 70 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
695 | 71 | - | ||
696 | 72 | !python {model: account.invoice.refund}: | | ||
697 | 73 | obj_inv = self.pool.get('account.invoice') | ||
698 | 74 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
699 | 75 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier0')) | ||
700 | 76 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
701 | 77 | - | ||
702 | 78 | 2.- In order to test account refund with "Create refund and reconcile" method | ||
703 | 79 | - | ||
704 | 80 | 2.1.- I create a new supplier invoice | ||
705 | 81 | - | ||
706 | 82 | !record {model: account.invoice, id: account_invoice_supplier1, view: account.invoice_supplier_form }: | ||
707 | 83 | <<: *supplier_invoice | ||
708 | 84 | - | ||
709 | 85 | 2.2.- I check that Initially supplier invoice state is "Draft" | ||
710 | 86 | - | ||
711 | 87 | !assert {model: account.invoice, id: account_invoice_supplier1}: | ||
712 | 88 | - state == 'draft' | ||
713 | 89 | - | ||
714 | 90 | 2.3.- I check that the supplier invoice is a "Supplier Invoice" | ||
715 | 91 | - | ||
716 | 92 | !assert {model: account.invoice, id: account_invoice_supplier1, string: This is not a supplier invoice}: | ||
717 | 93 | - type == 'in_invoice' | ||
718 | 94 | - | ||
719 | 95 | 2.4.- I change the state of invoice to open by clicking Validate button | ||
720 | 96 | - | ||
721 | 97 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier1} | ||
722 | 98 | - | ||
723 | 99 | 2.5.- I check that the invoice state is now "Open" | ||
724 | 100 | - | ||
725 | 101 | !assert {model: account.invoice, id: account_invoice_supplier1}: | ||
726 | 102 | - state == 'open' | ||
727 | 103 | - | ||
728 | 104 | 2.6.- I create a supplier refund using the method "Create refund and reconcile" and | ||
729 | 105 | check the state of the account invoice refund resulting | ||
730 | 106 | - | ||
731 | 107 | !python {model: account.invoice.refund}: | | ||
732 | 108 | import time | ||
733 | 109 | values = { | ||
734 | 110 | 'date': time.strftime('%Y-%m-%d'), | ||
735 | 111 | 'period': self.pool.get('account.period').find( | ||
736 | 112 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
737 | 113 | 'journal_id': ref('account.refund_expenses_journal'), | ||
738 | 114 | 'description': 'Desde el test', | ||
739 | 115 | 'nro_ctrl': 'Desde el test', | ||
740 | 116 | 'filter_refund': 'cancel', | ||
741 | 117 | } | ||
742 | 118 | wzr_id = self.create(cr, uid, values) | ||
743 | 119 | context['wzr_id'] = wzr_id | ||
744 | 120 | context['active_ids'] = [ref('account_invoice_supplier1')] | ||
745 | 121 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
746 | 122 | context['rfnd_id'] = rfnd_id | ||
747 | 123 | obj_inv = self.pool.get('account.invoice') | ||
748 | 124 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
749 | 125 | assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.' | ||
750 | 126 | - | ||
751 | 127 | 2.7.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
752 | 128 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
753 | 129 | - | ||
754 | 130 | !python {model: account.invoice.refund}: | | ||
755 | 131 | obj_inv = self.pool.get('account.invoice') | ||
756 | 132 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
757 | 133 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier1')) | ||
758 | 134 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
759 | 135 | - | ||
760 | 136 | 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice" | ||
761 | 137 | method | ||
762 | 138 | - | ||
763 | 139 | 3.1.- I create a new supplier invoice | ||
764 | 140 | - | ||
765 | 141 | !record {model: account.invoice, id: account_invoice_supplier2, view: account.invoice_supplier_form }: | ||
766 | 142 | <<: *supplier_invoice | ||
767 | 143 | - | ||
768 | 144 | 3.2.- I check that Initially supplier invoice state is "Draft" | ||
769 | 145 | - | ||
770 | 146 | !assert {model: account.invoice, id: account_invoice_supplier2}: | ||
771 | 147 | - state == 'draft' | ||
772 | 148 | - | ||
773 | 149 | 3.3.- I check that the supplier invoice is a "Supplier Invoice" | ||
774 | 150 | - | ||
775 | 151 | !assert {model: account.invoice, id: account_invoice_supplier2, string: This is not a supplier invoice}: | ||
776 | 152 | - type == 'in_invoice' | ||
777 | 153 | - | ||
778 | 154 | 3.4.- I change the state of invoice to open by clicking Validate button | ||
779 | 155 | - | ||
780 | 156 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier2} | ||
781 | 157 | - | ||
782 | 158 | 3.5.- I check that the invoice state is now "Open" | ||
783 | 159 | - | ||
784 | 160 | !assert {model: account.invoice, id: account_invoice_supplier2}: | ||
785 | 161 | - state == 'open' | ||
786 | 162 | - | ||
787 | 163 | 3.6.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and | ||
788 | 164 | check the state of the account invoice refund resulting | ||
789 | 165 | - | ||
790 | 166 | !python {model: account.invoice.refund}: | | ||
791 | 167 | import time | ||
792 | 168 | values = { | ||
793 | 169 | 'date': time.strftime('%Y-%m-%d'), | ||
794 | 170 | 'period': self.pool.get('account.period').find( | ||
795 | 171 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
796 | 172 | 'journal_id': ref('account.refund_expenses_journal'), | ||
797 | 173 | 'description': 'Desde el test', | ||
798 | 174 | 'nro_ctrl': 'Desde el test', | ||
799 | 175 | 'filter_refund': 'modify', | ||
800 | 176 | } | ||
801 | 177 | wzr_id = self.create(cr, uid, values) | ||
802 | 178 | context['wzr_id'] = wzr_id | ||
803 | 179 | context['active_ids'] = [ref('account_invoice_supplier2')] | ||
804 | 180 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
805 | 181 | context['rfnd_id'] = rfnd_id | ||
806 | 182 | obj_inv = self.pool.get('account.invoice') | ||
807 | 183 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
808 | 184 | assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.' | ||
809 | 185 | - | ||
810 | 186 | 3.7.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
811 | 187 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
812 | 188 | - | ||
813 | 189 | !python {model: account.invoice.refund}: | | ||
814 | 190 | obj_inv = self.pool.get('account.invoice') | ||
815 | 191 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
816 | 192 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier2')) | ||
817 | 193 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
818 | 194 | - | ||
819 | 195 | 3.8.- I check that the new supplier invoice was created in Draft state | ||
820 | 196 | - | ||
821 | 197 | !python {model: account.invoice.refund}: | | ||
822 | 198 | obj_inv = self.pool.get('account.invoice') | ||
823 | 199 | inv_src = obj_inv.search(cr, uid, [], order='id') | ||
824 | 200 | supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1]) | ||
825 | 201 | assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.' | ||
826 | 202 | - | ||
827 | 203 | 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice | ||
828 | 204 | - | ||
829 | 205 | 4.1.- I create a new partner | ||
830 | 206 | - | ||
831 | 207 | !record {model: 'res.partner', id: res_partner10}: | ||
832 | 208 | name: Juan Garcia | ||
833 | 209 | use_parent_address: True | ||
834 | 210 | function: Tests | ||
835 | 211 | email: juan@garcia.com | ||
836 | 212 | supplier: True | ||
837 | 213 | - | ||
838 | 214 | 4.2.- I create a Purchase Journal. | ||
839 | 215 | - | ||
840 | 216 | !record {model: account.journal, id: purchase_journal_debit}: | ||
841 | 217 | code: pjou_test | ||
842 | 218 | company_id: base.main_company | ||
843 | 219 | name: Purchase Journal For Debit Credit Note Tests | ||
844 | 220 | sequence_id: account.sequence_purchase_journal | ||
845 | 221 | type: purchase | ||
846 | 222 | - | ||
847 | 223 | 4.3.- I create a new supplier invoice | ||
848 | 224 | - | ||
849 | 225 | !record {model: account.invoice, id: account_invoice_supplier3, view: account.invoice_supplier_form }: | ||
850 | 226 | account_id: account.a_pay | ||
851 | 227 | company_id: base.main_company | ||
852 | 228 | currency_id: base.EUR | ||
853 | 229 | invoice_line: | ||
854 | 230 | - account_id: account.a_expense | ||
855 | 231 | name: '[PCSC234] PC Assemble SC234' | ||
856 | 232 | price_unit: 300.0 | ||
857 | 233 | product_id: product.product_product_3 | ||
858 | 234 | quantity: 10.0 | ||
859 | 235 | uos_id: product.product_uom_unit | ||
860 | 236 | journal_id: purchase_journal_debit | ||
861 | 237 | partner_id: res_partner10 | ||
862 | 238 | reference_type: none | ||
863 | 239 | type: 'in_invoice' | ||
864 | 240 | - | ||
865 | 241 | 4.4.- I check that initially supplier invoice state is "Draft" | ||
866 | 242 | - | ||
867 | 243 | !assert {model: account.invoice, id: account_invoice_supplier3}: | ||
868 | 244 | - state == 'draft' | ||
869 | 245 | - | ||
870 | 246 | 4.5.- I check that the supplier invoice is a "Supplier Invoice" | ||
871 | 247 | - | ||
872 | 248 | !assert {model: account.invoice, id: account_invoice_supplier3, string: This is not a supplier invoice}: | ||
873 | 249 | - type == 'in_invoice' | ||
874 | 250 | - | ||
875 | 251 | 4.6.- I change the state of invoice to open by clicking Validate button | ||
876 | 252 | - | ||
877 | 253 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier3} | ||
878 | 254 | - | ||
879 | 255 | 4.7.- I check that the invoice state is now "Open" | ||
880 | 256 | - | ||
881 | 257 | !assert {model: account.invoice, id: account_invoice_supplier3}: | ||
882 | 258 | - state == 'open' | ||
883 | 259 | - | ||
884 | 260 | 4.8.- I check that a payment entry gets created in the account.move.line | ||
885 | 261 | - | ||
886 | 262 | !python {model: account.invoice}: | | ||
887 | 263 | acc_id=self.browse(cr, uid, ref("account_invoice_supplier3")) | ||
888 | 264 | assert(acc_id.move_id) | ||
889 | 265 | - | ||
890 | 266 | 4.9.- I create a Bank Journal. | ||
891 | 267 | - | ||
892 | 268 | !record {model: account.journal, id: bank_journal_debit}: | ||
893 | 269 | name: Bank Journal For Debit Credit Note Tests | ||
894 | 270 | code: bjou_test | ||
895 | 271 | type: bank | ||
896 | 272 | analytic_journal_id: account.sit | ||
897 | 273 | sequence_id: account.sequence_bank_journal | ||
898 | 274 | default_debit_account_id: account.cash | ||
899 | 275 | default_credit_account_id: account.cash | ||
900 | 276 | company_id: base.main_company | ||
901 | 277 | - | ||
902 | 278 | 4.10.- I will create and post an account voucher of amount 3450.00 for the partner Juan Garcia. | ||
903 | 279 | - | ||
904 | 280 | !record {model: account.voucher, id: account_voucher0, view: account_voucher.view_vendor_payment_form}: | ||
905 | 281 | type: payment | ||
906 | 282 | account_id: account.cash | ||
907 | 283 | amount: 3450.00 | ||
908 | 284 | company_id: base.main_company | ||
909 | 285 | journal_id: bank_journal_debit | ||
910 | 286 | name: Voucher x | ||
911 | 287 | narration: PC Assemble SC234 | ||
912 | 288 | line_dr_ids: | ||
913 | 289 | - account_id: account.cash | ||
914 | 290 | amount: 3450.00 | ||
915 | 291 | name: Voucher x | ||
916 | 292 | partner_id: res_partner10 | ||
917 | 293 | reference: none | ||
918 | 294 | - | ||
919 | 295 | 4.11.- I check that initially vendor voucher is in the "Draft" state | ||
920 | 296 | - | ||
921 | 297 | !assert {model: account.voucher, id: account_voucher0}: | ||
922 | 298 | - state == 'draft' | ||
923 | 299 | - | ||
924 | 300 | 4.12.- I create voucher by clicking on create button | ||
925 | 301 | - | ||
926 | 302 | !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher0} | ||
927 | 303 | - | ||
928 | 304 | 4.13.- I check that the voucher state is "Posted" | ||
929 | 305 | - | ||
930 | 306 | !assert {model: account.voucher, id: account_voucher0}: | ||
931 | 307 | - state == 'posted' | ||
932 | 308 | - | ||
933 | 309 | 4.14.- I check if the state of the invoice is "Paid" | ||
934 | 310 | - | ||
935 | 311 | !assert {model: account.invoice, id: account_invoice_supplier3}: | ||
936 | 312 | - state == 'paid' | ||
937 | 313 | - | ||
938 | 314 | 4.15.- I modified the sale journal record so it can cancel invoice | ||
939 | 315 | - | ||
940 | 316 | !record {model: account.journal, id: purchase_journal_debit}: | ||
941 | 317 | update_posted: 1 | ||
942 | 318 | - | ||
943 | 319 | 4.16.- I modified the cash journal record so it can cancel invoice | ||
944 | 320 | - | ||
945 | 321 | !record {model: account.journal, id: bank_journal_debit}: | ||
946 | 322 | update_posted: 1 | ||
947 | 323 | - | ||
948 | 324 | 4.17.- I create a Purchase Refund Journal. | ||
949 | 325 | - | ||
950 | 326 | !record {model: account.journal, id: purchase_refund_journal_debit}: | ||
951 | 327 | code: sprjou_test | ||
952 | 328 | company_id: base.main_company | ||
953 | 329 | name: Purchase Refund Journal For Debit Credit Note Tests | ||
954 | 330 | sequence_id: account.sequence_refund_purchase_journal | ||
955 | 331 | type: purchase_refund | ||
956 | 332 | - | ||
957 | 333 | 4.18.- I create a supplier refund using the method "Create a draft refund" and | ||
958 | 334 | check the state of the account invoice refund resulting | ||
959 | 335 | - | ||
960 | 336 | !python {model: account.invoice.refund}: | | ||
961 | 337 | import time | ||
962 | 338 | values = { | ||
963 | 339 | 'date': time.strftime('%Y-%m-%d'), | ||
964 | 340 | 'period': self.pool.get('account.period').find( | ||
965 | 341 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
966 | 342 | 'journal_id': ref('purchase_refund_journal_debit'), | ||
967 | 343 | 'description': 'Desde el test', | ||
968 | 344 | 'nro_ctrl': 'Desde el test', | ||
969 | 345 | 'filter_refund': 'refund', | ||
970 | 346 | } | ||
971 | 347 | wzr_id = self.create(cr, uid, values) | ||
972 | 348 | assert wzr_id, 'The wizard instance was not created.' | ||
973 | 349 | context['wzr_id'] = wzr_id | ||
974 | 350 | context['active_ids'] = [ref('account_invoice_supplier3')] | ||
975 | 351 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
976 | 352 | assert rfnd_id, 'The refund was not created.' | ||
977 | 353 | context['rfnd_id'] = rfnd_id | ||
978 | 354 | obj_inv = self.pool.get('account.invoice') | ||
979 | 355 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
980 | 356 | assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.' | ||
981 | 357 | - | ||
982 | 358 | 4.19.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
983 | 359 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
984 | 360 | - | ||
985 | 361 | !python {model: account.invoice.refund}: | | ||
986 | 362 | obj_inv = self.pool.get('account.invoice') | ||
987 | 363 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
988 | 364 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier3')) | ||
989 | 365 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
990 | 366 | - | ||
991 | 367 | 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice | ||
992 | 368 | - | ||
993 | 369 | 5.1.- I create a new partner | ||
994 | 370 | - | ||
995 | 371 | !record {model: 'res.partner', id: res_partner11}: | ||
996 | 372 | name: Maria Garcia | ||
997 | 373 | use_parent_address: True | ||
998 | 374 | function: Tests | ||
999 | 375 | email: maria@garcia.com | ||
1000 | 376 | supplier: True | ||
1001 | 377 | - | ||
1002 | 378 | 5.2.- I create a new supplier invoice | ||
1003 | 379 | - | ||
1004 | 380 | !record {model: account.invoice, id: account_invoice_supplier4, view: account.invoice_supplier_form }: | ||
1005 | 381 | account_id: account.a_pay | ||
1006 | 382 | company_id: base.main_company | ||
1007 | 383 | currency_id: base.EUR | ||
1008 | 384 | invoice_line: | ||
1009 | 385 | - account_id: account.a_expense | ||
1010 | 386 | name: '[PCSC234] PC Assemble SC234' | ||
1011 | 387 | price_unit: 300.0 | ||
1012 | 388 | product_id: product.product_product_3 | ||
1013 | 389 | quantity: 10.0 | ||
1014 | 390 | uos_id: product.product_uom_unit | ||
1015 | 391 | journal_id: purchase_journal_debit | ||
1016 | 392 | partner_id: res_partner11 | ||
1017 | 393 | reference_type: none | ||
1018 | 394 | type: 'in_invoice' | ||
1019 | 395 | - | ||
1020 | 396 | 5.3.- I check that initially supplier invoice state is "Draft" | ||
1021 | 397 | - | ||
1022 | 398 | !assert {model: account.invoice, id: account_invoice_supplier4}: | ||
1023 | 399 | - state == 'draft' | ||
1024 | 400 | - | ||
1025 | 401 | 5.4.- I check that the supplier invoice is a "Supplier Invoice" | ||
1026 | 402 | - | ||
1027 | 403 | !assert {model: account.invoice, id: account_invoice_supplier4, string: This is not a supplier invoice}: | ||
1028 | 404 | - type == 'in_invoice' | ||
1029 | 405 | - | ||
1030 | 406 | 5.5.- I change the state of invoice to open by clicking Validate button | ||
1031 | 407 | - | ||
1032 | 408 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier4} | ||
1033 | 409 | - | ||
1034 | 410 | 5.6.- I check that the invoice state is now "Open" | ||
1035 | 411 | - | ||
1036 | 412 | !assert {model: account.invoice, id: account_invoice_supplier4}: | ||
1037 | 413 | - state == 'open' | ||
1038 | 414 | - | ||
1039 | 415 | 5.7.- I check that a payment entry gets created in the account.move.line | ||
1040 | 416 | - | ||
1041 | 417 | !python {model: account.invoice}: | | ||
1042 | 418 | acc_id=self.browse(cr, uid, ref("account_invoice_supplier4")) | ||
1043 | 419 | assert(acc_id.move_id) | ||
1044 | 420 | - | ||
1045 | 421 | 5.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia. | ||
1046 | 422 | - | ||
1047 | 423 | !record {model: account.voucher, id: account_voucher1, view: account_voucher.view_vendor_payment_form}: | ||
1048 | 424 | type: payment | ||
1049 | 425 | account_id: account.cash | ||
1050 | 426 | amount: 3450.00 | ||
1051 | 427 | company_id: base.main_company | ||
1052 | 428 | journal_id: bank_journal_debit | ||
1053 | 429 | name: Voucher x | ||
1054 | 430 | narration: PC Assemble SC234 | ||
1055 | 431 | line_dr_ids: | ||
1056 | 432 | - account_id: account.cash | ||
1057 | 433 | amount: 3450.00 | ||
1058 | 434 | name: Voucher x | ||
1059 | 435 | partner_id: res_partner11 | ||
1060 | 436 | reference: none | ||
1061 | 437 | - | ||
1062 | 438 | 5.9.- I check that initially vendor voucher is in the "Draft" state | ||
1063 | 439 | - | ||
1064 | 440 | !assert {model: account.voucher, id: account_voucher1}: | ||
1065 | 441 | - state == 'draft' | ||
1066 | 442 | - | ||
1067 | 443 | 5.10.- I create voucher by clicking on create button | ||
1068 | 444 | - | ||
1069 | 445 | !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher1} | ||
1070 | 446 | - | ||
1071 | 447 | 5.11.- I check that the voucher state is "Posted" | ||
1072 | 448 | - | ||
1073 | 449 | !assert {model: account.voucher, id: account_voucher1}: | ||
1074 | 450 | - state == 'posted' | ||
1075 | 451 | - | ||
1076 | 452 | 5.12.- I check if the state of the invoice is "Paid" | ||
1077 | 453 | - | ||
1078 | 454 | !assert {model: account.invoice, id: account_invoice_supplier4}: | ||
1079 | 455 | - state == 'paid' | ||
1080 | 456 | - | ||
1081 | 457 | 5.13.- I create a supplier refund using the method "Create refund and reconcile" and | ||
1082 | 458 | check the state of the account invoice refund resulting | ||
1083 | 459 | - | ||
1084 | 460 | !python {model: account.invoice.refund}: | | ||
1085 | 461 | import time | ||
1086 | 462 | values = { | ||
1087 | 463 | 'date': time.strftime('%Y-%m-%d'), | ||
1088 | 464 | 'period': self.pool.get('account.period').find( | ||
1089 | 465 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
1090 | 466 | 'journal_id': ref('purchase_refund_journal_debit'), | ||
1091 | 467 | 'description': 'Desde el test', | ||
1092 | 468 | 'nro_ctrl': 'Desde el test', | ||
1093 | 469 | 'filter_refund': 'cancel', | ||
1094 | 470 | } | ||
1095 | 471 | wzr_id = self.create(cr, uid, values) | ||
1096 | 472 | assert wzr_id, 'The wizard instance was not created.' | ||
1097 | 473 | context['wzr_id'] = wzr_id | ||
1098 | 474 | context['active_ids'] = [ref('account_invoice_supplier4')] | ||
1099 | 475 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
1100 | 476 | assert rfnd_id, 'The refund was not created.' | ||
1101 | 477 | context['rfnd_id'] = rfnd_id | ||
1102 | 478 | obj_inv = self.pool.get('account.invoice') | ||
1103 | 479 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
1104 | 480 | assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.' | ||
1105 | 481 | - | ||
1106 | 482 | 5.14.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
1107 | 483 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
1108 | 484 | - | ||
1109 | 485 | !python {model: account.invoice.refund}: | | ||
1110 | 486 | obj_inv = self.pool.get('account.invoice') | ||
1111 | 487 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
1112 | 488 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier4')) | ||
1113 | 489 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
1114 | 490 | - | ||
1115 | 491 | 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice" | ||
1116 | 492 | method in a "Paid" invoice | ||
1117 | 493 | - | ||
1118 | 494 | 6.1.- I create a new partner | ||
1119 | 495 | - | ||
1120 | 496 | !record {model: 'res.partner', id: res_partner12}: | ||
1121 | 497 | name: Pablo Garcia | ||
1122 | 498 | use_parent_address: True | ||
1123 | 499 | function: Tests | ||
1124 | 500 | email: pablo@garcia.com | ||
1125 | 501 | supplier: True | ||
1126 | 502 | - | ||
1127 | 503 | 6.2.- I create a new supplier invoice | ||
1128 | 504 | - | ||
1129 | 505 | !record {model: account.invoice, id: account_invoice_supplier5, view: account.invoice_supplier_form }: | ||
1130 | 506 | account_id: account.a_pay | ||
1131 | 507 | company_id: base.main_company | ||
1132 | 508 | currency_id: base.EUR | ||
1133 | 509 | invoice_line: | ||
1134 | 510 | - account_id: account.a_expense | ||
1135 | 511 | name: '[PCSC234] PC Assemble SC234' | ||
1136 | 512 | price_unit: 300.0 | ||
1137 | 513 | product_id: product.product_product_3 | ||
1138 | 514 | quantity: 10.0 | ||
1139 | 515 | uos_id: product.product_uom_unit | ||
1140 | 516 | journal_id: purchase_journal_debit | ||
1141 | 517 | partner_id: res_partner12 | ||
1142 | 518 | reference_type: none | ||
1143 | 519 | type: 'in_invoice' | ||
1144 | 520 | - | ||
1145 | 521 | 6.3.- I check that initially supplier invoice state is "Draft" | ||
1146 | 522 | - | ||
1147 | 523 | !assert {model: account.invoice, id: account_invoice_supplier5}: | ||
1148 | 524 | - state == 'draft' | ||
1149 | 525 | - | ||
1150 | 526 | 6.4.- I check that the supplier invoice is a "Supplier Invoice" | ||
1151 | 527 | - | ||
1152 | 528 | !assert {model: account.invoice, id: account_invoice_supplier5, string: This is not a supplier invoice}: | ||
1153 | 529 | - type == 'in_invoice' | ||
1154 | 530 | - | ||
1155 | 531 | 6.5.- I change the state of invoice to open by clicking Validate button | ||
1156 | 532 | - | ||
1157 | 533 | !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier5} | ||
1158 | 534 | - | ||
1159 | 535 | 5.6.- I check that the invoice state is now "Open" | ||
1160 | 536 | - | ||
1161 | 537 | !assert {model: account.invoice, id: account_invoice_supplier5}: | ||
1162 | 538 | - state == 'open' | ||
1163 | 539 | - | ||
1164 | 540 | 6.7.- I check that a payment entry gets created in the account.move.line | ||
1165 | 541 | - | ||
1166 | 542 | !python {model: account.invoice}: | | ||
1167 | 543 | acc_id=self.browse(cr, uid, ref("account_invoice_supplier5")) | ||
1168 | 544 | assert(acc_id.move_id) | ||
1169 | 545 | - | ||
1170 | 546 | 6.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia. | ||
1171 | 547 | - | ||
1172 | 548 | !record {model: account.voucher, id: account_voucher2, view: account_voucher.view_vendor_payment_form}: | ||
1173 | 549 | type: payment | ||
1174 | 550 | account_id: account.cash | ||
1175 | 551 | amount: 3450.00 | ||
1176 | 552 | company_id: base.main_company | ||
1177 | 553 | journal_id: bank_journal_debit | ||
1178 | 554 | name: Voucher x | ||
1179 | 555 | narration: PC Assemble SC234 | ||
1180 | 556 | line_dr_ids: | ||
1181 | 557 | - account_id: account.cash | ||
1182 | 558 | amount: 3450.00 | ||
1183 | 559 | name: Voucher x | ||
1184 | 560 | partner_id: res_partner12 | ||
1185 | 561 | reference: none | ||
1186 | 562 | - | ||
1187 | 563 | 6.9.- I check that initially vendor voucher is in the "Draft" state | ||
1188 | 564 | - | ||
1189 | 565 | !assert {model: account.voucher, id: account_voucher2}: | ||
1190 | 566 | - state == 'draft' | ||
1191 | 567 | - | ||
1192 | 568 | 6.10.- I create voucher by clicking on create button | ||
1193 | 569 | - | ||
1194 | 570 | !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher2} | ||
1195 | 571 | - | ||
1196 | 572 | 6.11.- I check that the voucher state is "Posted" | ||
1197 | 573 | - | ||
1198 | 574 | !assert {model: account.voucher, id: account_voucher2}: | ||
1199 | 575 | - state == 'posted' | ||
1200 | 576 | - | ||
1201 | 577 | 6.12.- I check if the state of the invoice is "Paid" | ||
1202 | 578 | - | ||
1203 | 579 | !assert {model: account.invoice, id: account_invoice_supplier5}: | ||
1204 | 580 | - state == 'paid' | ||
1205 | 581 | - | ||
1206 | 582 | 6.13.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and | ||
1207 | 583 | check the state of the account invoice refund resulting | ||
1208 | 584 | - | ||
1209 | 585 | !python {model: account.invoice.refund}: | | ||
1210 | 586 | import time | ||
1211 | 587 | values = { | ||
1212 | 588 | 'date': time.strftime('%Y-%m-%d'), | ||
1213 | 589 | 'period': self.pool.get('account.period').find( | ||
1214 | 590 | cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0], | ||
1215 | 591 | 'journal_id': ref('purchase_refund_journal_debit'), | ||
1216 | 592 | 'description': 'Desde el test', | ||
1217 | 593 | 'nro_ctrl': 'Desde el test', | ||
1218 | 594 | 'filter_refund': 'modify', | ||
1219 | 595 | } | ||
1220 | 596 | wzr_id = self.create(cr, uid, values) | ||
1221 | 597 | assert wzr_id, 'The wizard instance was not created.' | ||
1222 | 598 | context['wzr_id'] = wzr_id | ||
1223 | 599 | context['active_ids'] = [ref('account_invoice_supplier5')] | ||
1224 | 600 | rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context) | ||
1225 | 601 | assert rfnd_id, 'The refund was not created.' | ||
1226 | 602 | context['rfnd_id'] = rfnd_id | ||
1227 | 603 | obj_inv = self.pool.get('account.invoice') | ||
1228 | 604 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2]) | ||
1229 | 605 | assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.' | ||
1230 | 606 | - | ||
1231 | 607 | 6.14.- I check the correct asigning of parent_id in the supplier refund created, for that | ||
1232 | 608 | the supplier refund must have the supplier invoice id in the fiel parent_id | ||
1233 | 609 | - | ||
1234 | 610 | !python {model: account.invoice.refund}: | | ||
1235 | 611 | obj_inv = self.pool.get('account.invoice') | ||
1236 | 612 | rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2]) | ||
1237 | 613 | supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier5')) | ||
1238 | 614 | assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.' | ||
1239 | 615 | - | ||
1240 | 616 | 6.15.- I check that the new supplier invoice was created in Draft state | ||
1241 | 617 | - | ||
1242 | 618 | !python {model: account.invoice.refund}: | | ||
1243 | 619 | obj_inv = self.pool.get('account.invoice') | ||
1244 | 620 | inv_src = obj_inv.search(cr, uid, [], order='id') | ||
1245 | 621 | supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1]) | ||
1246 | 622 | assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.' | ||
1247 | 0 | 623 | ||
1248 | === modified file 'l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py' | |||
1249 | --- l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-01-13 19:38:55 +0000 | |||
1250 | +++ l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-02-11 00:22:34 +0000 | |||
1251 | @@ -99,17 +99,7 @@ | |||
1252 | 99 | journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) | 99 | journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1) |
1253 | 100 | res['fields'][field]['selection'] = journal_select | 100 | res['fields'][field]['selection'] = journal_select |
1254 | 101 | return res | 101 | return res |
1266 | 102 | 102 | ||
1256 | 103 | def _get_orig(self, cr, uid, inv, ref, context={}): | ||
1257 | 104 | """ Return default origin value | ||
1258 | 105 | """ | ||
1259 | 106 | nro_ref = ref | ||
1260 | 107 | if inv.type == 'out_invoice': | ||
1261 | 108 | nro_ref = inv.number | ||
1262 | 109 | orig = 'Devolucion FACT:' +(nro_ref or '') + '- DE FECHA:' + (inv.date_invoice or '') + (' TOTAL:' + str(inv.amount_total) or '') | ||
1263 | 110 | return orig | ||
1264 | 111 | |||
1265 | 112 | |||
1267 | 113 | def cn_iva_validate(self, cr, uid,invoice,context=None): | 103 | def cn_iva_validate(self, cr, uid,invoice,context=None): |
1268 | 114 | """ Validates if retentions have been changes to move the state confirmed and done | 104 | """ Validates if retentions have been changes to move the state confirmed and done |
1269 | 115 | """ | 105 | """ |
1270 | @@ -159,20 +149,20 @@ | |||
1271 | 159 | res_users_obj = self.pool.get('res.users') | 149 | res_users_obj = self.pool.get('res.users') |
1272 | 160 | if context is None: | 150 | if context is None: |
1273 | 161 | context = {} | 151 | context = {} |
1275 | 162 | for form in self.read(cr, uid, ids, context=context): | 152 | for form in self.browse(cr, uid, ids, context=context): |
1276 | 163 | created_inv = [] | 153 | created_inv = [] |
1277 | 164 | date = False | 154 | date = False |
1278 | 165 | period = False | 155 | period = False |
1279 | 166 | description = False | 156 | description = False |
1280 | 167 | nroctrl = False | 157 | nroctrl = False |
1281 | 168 | company = res_users_obj.browse(cr, uid, uid, context=context).company_id | 158 | company = res_users_obj.browse(cr, uid, uid, context=context).company_id |
1283 | 169 | journal_brw = form.get('journal_id', False) | 159 | journal_brw = form.journal_id or False |
1284 | 170 | for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context): | 160 | for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context): |
1285 | 171 | if inv.state in ['draft', 'proforma2', 'cancel']: | 161 | if inv.state in ['draft', 'proforma2', 'cancel']: |
1286 | 172 | raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) | 162 | raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) |
1287 | 173 | if inv.reconciled and mode in ('cancel', 'modify'): | 163 | if inv.reconciled and mode in ('cancel', 'modify'): |
1288 | 174 | raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode)) | 164 | raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode)) |
1290 | 175 | period = form.get('period') and form.get('period')[0] or False | 165 | period = form.period.id or False |
1291 | 176 | if not period: | 166 | if not period: |
1292 | 177 | #Take period from the current date | 167 | #Take period from the current date |
1293 | 178 | period = self.pool.get('account.period').find(cr, uid, context=context) | 168 | period = self.pool.get('account.period').find(cr, uid, context=context) |
1294 | @@ -185,11 +175,11 @@ | |||
1295 | 185 | if not journal_brw: | 175 | if not journal_brw: |
1296 | 186 | journal_id = inv.journal_id.id | 176 | journal_id = inv.journal_id.id |
1297 | 187 | else: | 177 | else: |
1299 | 188 | journal_id=journal_brw[0] | 178 | journal_id=journal_brw.id |
1300 | 189 | 179 | ||
1304 | 190 | if form['date']: | 180 | if form.date: |
1305 | 191 | date = form['date'] | 181 | date = form.date |
1306 | 192 | if not form['period']: | 182 | if not form.period: |
1307 | 193 | cr.execute("select name from ir_model_fields \ | 183 | cr.execute("select name from ir_model_fields \ |
1308 | 194 | where model = 'account.period' \ | 184 | where model = 'account.period' \ |
1309 | 195 | and name = 'company_id'") | 185 | and name = 'company_id'") |
1310 | @@ -209,14 +199,14 @@ | |||
1311 | 209 | #Take current date | 199 | #Take current date |
1312 | 210 | #date = inv.date_invoice | 200 | #date = inv.date_invoice |
1313 | 211 | date = time.strftime('%Y-%m-%d') | 201 | date = time.strftime('%Y-%m-%d') |
1316 | 212 | if form['description']: | 202 | if form.description: |
1317 | 213 | description = form['description'] | 203 | description = form.description |
1318 | 214 | else: | 204 | else: |
1319 | 215 | description = inv.name | 205 | description = inv.name |
1320 | 216 | 206 | ||
1321 | 217 | if inv.type in ('in_invoice','in_refund'): | 207 | if inv.type in ('in_invoice','in_refund'): |
1324 | 218 | if form['nro_ctrl']: | 208 | if form.nro_ctrl: |
1325 | 219 | nroctrl = form['nro_ctrl'] | 209 | nroctrl = form.nro_ctrl |
1326 | 220 | else: | 210 | else: |
1327 | 221 | raise osv.except_osv(_('Control Number !'), \ | 211 | raise osv.except_osv(_('Control Number !'), \ |
1328 | 222 | _('Missing Control Number on Invoice Refund!')) | 212 | _('Missing Control Number on Invoice Refund!')) |
1329 | @@ -321,19 +311,7 @@ | |||
1330 | 321 | orig = self._get_orig(cr, uid, inv, inv.supplier_invoice_number, context) | 311 | orig = self._get_orig(cr, uid, inv, inv.supplier_invoice_number, context) |
1331 | 322 | inv_obj.write(cr,uid,created_inv[0],{'origin':inv.origin,'name':wzd_brw.description},context=context) | 312 | inv_obj.write(cr,uid,created_inv[0],{'origin':inv.origin,'name':wzd_brw.description},context=context) |
1332 | 323 | return result | 313 | return result |
1346 | 324 | 314 | ||
1334 | 325 | def validate_total_payment_inv(self, cr, uid, ids, context=None): | ||
1335 | 326 | """ Method that validate if invoice is totally paid. | ||
1336 | 327 | @param ids: list of invoices. | ||
1337 | 328 | return: True: if invoice is paid. | ||
1338 | 329 | False: if invoice is not paid. | ||
1339 | 330 | """ | ||
1340 | 331 | res = False | ||
1341 | 332 | inv_obj = self.pool.get('account.invoice') | ||
1342 | 333 | for inv in inv_obj.browse(cr, uid, ids, context=context): | ||
1343 | 334 | res = inv.reconciled | ||
1344 | 335 | return res | ||
1345 | 336 | |||
1347 | 337 | def validate_wh(self, cr, uid, ids, context=None): | 315 | def validate_wh(self, cr, uid, ids, context=None): |
1348 | 338 | """ Method that validate if invoice has non-yet processed withholds. | 316 | """ Method that validate if invoice has non-yet processed withholds. |
1349 | 339 | 317 | ||
1350 | @@ -345,36 +323,6 @@ | |||
1351 | 345 | """ | 323 | """ |
1352 | 346 | return True | 324 | return True |
1353 | 347 | 325 | ||
1354 | 348 | def unreconcile_paid_invoices(self, cr, uid, invoiceids, context=None): | ||
1355 | 349 | """ Method that unreconcile the payments of invoice. | ||
1356 | 350 | @param invoiceids: list of invoices. | ||
1357 | 351 | return: True: unreconcile successfully. | ||
1358 | 352 | False: unreconcile unsuccessfully. | ||
1359 | 353 | """ | ||
1360 | 354 | inv_obj = self.pool.get('account.invoice') | ||
1361 | 355 | moveline_obj = self.pool.get('account.move.line') | ||
1362 | 356 | voucher_pool = self.pool.get('account.voucher') | ||
1363 | 357 | res = True | ||
1364 | 358 | rec = [] | ||
1365 | 359 | mid = [] | ||
1366 | 360 | if self.validate_total_payment_inv(cr, uid, invoiceids, context=context): | ||
1367 | 361 | for inv in inv_obj.browse(cr, uid, invoiceids, context=context): | ||
1368 | 362 | movelineids = inv_obj.move_line_id_payment_get(cr, uid,[inv.id]) | ||
1369 | 363 | for moveline in moveline_obj.browse(cr, uid, movelineids,context=context): | ||
1370 | 364 | if moveline.reconcile_id: | ||
1371 | 365 | rec += [moveline.reconcile_id.id] | ||
1372 | 366 | if moveline.reconcile_partial_id: | ||
1373 | 367 | rec += [moveline.reconcile_partial_id.id] | ||
1374 | 368 | movelines = moveline_obj.search(cr, uid, [('|'),('reconcile_id','in',rec),('reconcile_partial_id','in',rec)],context=context) | ||
1375 | 369 | for mids in moveline_obj.browse(cr, uid, movelines, context=context): | ||
1376 | 370 | mid +=[mids.move_id.id] | ||
1377 | 371 | voucherids = voucher_pool.search(cr, uid,[('move_id','in',mid)]) | ||
1378 | 372 | if voucherids: | ||
1379 | 373 | voucher_pool.cancel_voucher(cr, uid, voucherids, context=context) | ||
1380 | 374 | else: | ||
1381 | 375 | res = False | ||
1382 | 376 | return res | ||
1383 | 377 | |||
1384 | 378 | def invoice_refund(self, cr, uid, ids, context=None): | 326 | def invoice_refund(self, cr, uid, ids, context=None): |
1385 | 379 | """ Create a invoice refund | 327 | """ Create a invoice refund |
1386 | 380 | """ | 328 | """ |
1387 | @@ -383,9 +331,9 @@ | |||
1388 | 383 | inv_obj = self.pool.get('account.invoice') | 331 | inv_obj = self.pool.get('account.invoice') |
1389 | 384 | period_obj = self.pool.get('account.period') | 332 | period_obj = self.pool.get('account.period') |
1390 | 385 | wzr_brw = self.browse(cr,uid,ids,context=context)[0] | 333 | wzr_brw = self.browse(cr,uid,ids,context=context)[0] |
1394 | 386 | date = wzr_brw.date and wzr_brw.date.split('-') | 334 | date = wzr_brw.date |
1395 | 387 | period = wzr_brw and wzr_brw.period and wzr_brw.period.id | 335 | period = wzr_brw and wzr_brw.period and wzr_brw.period.id |
1396 | 388 | period_ids = date and len(date) == 3 and period_obj.search(cr,uid,[('code','=','%s/%s'%(date[1],date[0]))],context=context) | 336 | period_ids = date and period_obj.search(cr,uid,[('date_start', '<=', date),('date_stop', '>=', date),('special', '=', False)],context=context) |
1397 | 389 | if period not in period_ids: | 337 | if period not in period_ids: |
1398 | 390 | raise osv.except_osv(_('Error !'), \ | 338 | raise osv.except_osv(_('Error !'), \ |
1399 | 391 | _('The date should be chosen to belong to the period')) | 339 | _('The date should be chosen to belong to the period')) |
[FIX] Methods belonging to OVL were removed of debit_credit_note module.