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