[FIX] account_anglo_saxon: fixed error in yaml test (no fiscal year defined for an...
[odoo/odoo.git] / addons / account_anglo_saxon / test / anglo_saxon_avg_fifo.yml
1 -
2   In order to test anglo_saxon Configure Different Accounts.
3 -
4   !record {model: account.account, id: account_anglo_stock_valuation_fifo}:
5     code: X3000f
6     name: Stock Valuation Account- (test)
7     parent_id: account.cas
8     type: other
9     user_type: account.data_account_type_asset
10 -
11   Configure Stock Interim account (Received).
12 -
13   !record {model: account.account, id: account_anglo_stock_input_fifo}:
14     code: X2800f
15     name: Stock Interim account (Received)
16     parent_id: account.cos
17     type: other
18     user_type: account.data_account_type_expense
19 -
20   Configure Stock Interim account (Delivered).
21 -
22   !record {model: account.account, id: account_anglo_stock_output_fifo}:
23     code: X2801f
24     name: Stock Interim account (Delivered)
25     parent_id: account.rev
26     type: other
27     user_type: account.data_account_type_income
28 -
29   Configure Price difference creditor Account.
30 -
31   !record {model: account.account, id: account_anglo_price_difference_fifo}:
32     code: X7095f
33     name: Price difference creditor Account
34     parent_id: account.cos
35     type: other
36     user_type: account.data_account_type_expense
37 -
38   Configure Cash Bank Account.
39 -
40   !record {model: account.account, id: account_anglo_cash_fifo}:
41     code: X5000f
42     name: Cash/Bank Account 
43     parent_id: account.cash  
44     type: other
45     user_type: account.data_account_type_asset
46 -
47   Configure Creditor Account Payable. 
48 -
49   !record {model: account.account, id: account_anglo_payable_fifo}:
50     code: X440001f
51     name: Creditor Account Payable 
52     parent_id: account.a_pay  
53     type: other
54     user_type: account.data_account_type_payable
55 -
56   Configure Debtor Account Receivable. 
57 -
58   !record {model: account.account, id: account_anglo_receivable_fifo}:
59     code: X400001f
60     name: Debtor Account Receivable 
61     parent_id: account.a_recv  
62     type: other
63     user_type: account.data_account_type_receivable
64 -
65   Configure Cost of Good sale Account.
66 -
67   !record {model: account.account, id: account_anglo_cogs_fifo}:
68     code: X7000f
69     name: Cost of goods sale account
70     parent_id: account.o_expense
71     type: other
72     user_type: account.data_account_type_expense
73 -
74   Configure Income Account.
75 -
76   !record {model: account.account, id: account_anglo_income_fifo}:
77     code: X8000f
78     name: Income Account
79     parent_id: account.o_income
80     type: other
81     user_type: account.data_account_type_income
82 -
83   I configure the account receivable of supplier
84 -
85   !record {model: res.partner, id: base.res_partner_3}:
86     property_account_payable: account_anglo_payable_fifo
87     property_account_receivable: account_anglo_receivable_fifo
88 -
89   I configure the account receivable of Customer.
90 -
91   !record {model: res.partner, id: base.res_partner_13}:
92     property_account_payable: account_anglo_payable_fifo
93     property_account_receivable: account_anglo_receivable_fifo
94 -
95   I configure the product category with stock valuation account.
96 -
97   !record {model: product.category, id: product.product_category_4}:
98     property_stock_valuation_account_id: account_anglo_stock_valuation_fifo
99 -
100   I create a product with required accounts, and cost method average (but same applies for fifo)
101 -
102   !record {model: product.product, id: product_fifo_anglo_saxon}: 
103     name: 'FIFO product for anglo saxon tests'
104     list_price: 20.00
105     standard_price: 0
106     categ_id: product.product_category_4
107     valuation: 'real_time'
108     property_account_income: account_anglo_income_fifo
109     property_account_expense: account_anglo_cogs_fifo
110     property_account_creditor_price_difference: account_anglo_price_difference_fifo
111     property_stock_account_input: account_anglo_stock_input_fifo
112     property_stock_account_output: account_anglo_stock_output_fifo
113     cost_method: 'average'
114 -
115   I create a draft Purchase Order.
116 -
117   !record {model: purchase.order, id: purchase_order_001_fifo}:
118     partner_id: base.res_partner_3
119     location_id: stock.stock_location_stock
120     pricelist_id: 1
121     order_line:
122       - product_id: product_fifo_anglo_saxon
123         product_qty: 1
124         price_unit: 9
125         date_planned: '2013-08-31'
126         taxes_id: []
127 -
128   I confirm the purchase order.
129 -
130   !workflow {model: purchase.order, ref: purchase_order_001_fifo, action: purchase_confirm}
131 -
132   Reception is ready for process so now done the reception.
133 -
134   !python {model: stock.picking}: |
135     picking_id = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids[0]
136     picking_id.do_transfer(context=context)
137 -
138   I check the Stock Interim account (Received) is credit successfully.
139 -
140   !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not credited successfully.}:
141     - credit == 9
142 -
143   I check the Stock valuation account is debit sucessfully.
144 -
145   !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not debited successfully.}:
146     - debit == 9
147 -
148   I Validate Invoice of Purchase Order after having changed the price to 10.
149 -
150   !python {model: purchase.order}: |
151     invoice_ids = [x.id for x in self.browse(cr, uid, ref("purchase_order_001_fifo")).invoice_ids]
152     line_ids = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id', 'in', invoice_ids)])
153     self.pool.get('account.invoice.line').write(cr, uid, line_ids, {'price_unit': 10})
154     self.pool.get('account.invoice').signal_invoice_open(cr, uid, invoice_ids)
155 -
156   I check the Stock Interim account (Received) is debited sucessfully when Invoice validated.
157 -
158   !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not debited successfully.}:
159     - debit == 9
160 -
161   I check the Price difference creditor Account is debited sucessfully when Invoice validated.
162 -
163   !assert {model: account.account, id : account_anglo_price_difference_fifo, string : Price difference creditor Account is not debited successfully.}:
164     - debit == 1
165 -
166   I check Payable(creditor) Account is Credited sucessfully when Invoice validated.
167 -
168   !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(creditor) Account is not Credited successfully.}:
169     - credit == 10
170 -
171   I pay the invoice.
172 -
173   !python {model: purchase.order}: |
174     invoice_ids = self.browse(cr, uid, ref("purchase_order_001_fifo")).invoice_ids
175     order = self.browse(cr, uid, ref("purchase_order_001_fifo"))
176     journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1)
177     for invoice in invoice_ids:
178         invoice.pay_and_reconcile(invoice.amount_total, ref('account_anglo_cash_fifo'), ref('account.period_8'), journal_ids[0], ref('account_anglo_cash_fifo'), ref('account.period_8'), journal_ids[0], name='test')
179 -
180   I check Payable(Creditors) Account is Debited sucessfully after invoice paid.
181 -
182   !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(Creditors) Account is not Debited successfully.}:
183     - debit == 10
184 -
185   I check Bank/Cash account is credited sucessfully after invoice paid.
186 -
187   !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not credited successfully.}:
188     - credit == 10
189 -
190   I create an Outgoing Picking order
191 -
192   !record {model: stock.picking, id: stock_picking_out001_fifo}:
193     partner_id: base.res_partner_13
194     move_lines:
195       - company_id: base.main_company
196         location_id: stock.stock_location_stock
197         product_id: product_fifo_anglo_saxon
198         product_qty: 1.0
199         location_dest_id: stock.stock_location_customers
200         invoice_state: 2binvoiced
201     move_type: direct
202     picking_type_id: stock.picking_type_out
203 -
204   I need to check the availability of the product, So I make my picking order for processing later.
205 -
206   !python {model: stock.picking}: |
207     self.action_confirm(cr, uid, [ref('stock_picking_out001_fifo')], context=context)
208 -
209   I check the product availability, Product is available in the stock and ready to be sent.
210 -
211   !python {model: stock.picking}: |
212     picking = self.browse(cr, uid, ref("stock_picking_out001_fifo"))
213     assert picking.state == "confirmed", "Picking should be confirmed."
214     for move_line in picking.move_lines:
215       assert move_line.state == "confirmed", "Move should be confirmed."
216 -
217   I process the delivery.
218 -
219   !python {model: stock.picking}: |
220     picking = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001_fifo"))
221     picking.do_transfer(context=context)
222
223   I check Stock Interim account (Delivery) is debited successfully.
224 -
225   !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not debited successfully.}:
226     - debit == 9
227 -
228   I check the Stock valuation account is credited sucessfully.
229 -
230   !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not credited successfully.}: 
231     - credit == 9
232 -
233   As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
234 -
235   !python {model: stock.invoice.onshipping}: |
236     import time
237     wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-03-04'), 'journal_id': ref('account.sales_journal')},
238       {'active_ids': [ref("stock_picking_out001_fifo")], "active_model": "stock.picking"})
239     self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US",
240       "search_default_available": 1, "tz": False, "active_model": "stock.picking",
241       "contact_display": "partner", "active_ids": [ref("stock_picking_out001_fifo")], "active_id": ref("stock_picking_out001_fifo")})
242 -
243   I check that the customer invoice is created successfully.
244 -
245   !python {model: account.invoice}: |
246     partner_id = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).partner_id.id
247     inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner_id)])
248     assert inv_ids, 'No Invoice is generated!'
249 -
250   I open the Invoice.
251 -
252   !python {model: stock.picking}: |
253     move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name
254     account_invoice = self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])
255     account_invoice_line = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id', 'in', account_invoice)])
256     self.pool.get('account.invoice.line').write(cr, uid, account_invoice_line, {'invoice_line_tax_id': [(6, 0, [])]})
257     self.pool.get('account.invoice').button_reset_taxes(cr, uid, account_invoice)
258     self.pool.get('account.invoice').signal_invoice_open(cr, uid, account_invoice)
259 -
260   I check Income Account is Credited sucessfully when Invoice validated.
261 -
262   !assert {model: account.account, id : account_anglo_income_fifo, string : Income Account is not Credited successfully.}:
263     - credit == 20
264 -
265   I check Cost of goods sold account for debit.
266 -
267   !assert {model: account.account, id : account_anglo_cogs_fifo, string : Cost of goods sale is not Debited successfully.}:
268     - debit == 9
269 -
270   I check Stock Interim account (Delivery)
271 -
272   !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not credited successfully.}:
273     - credit == 9
274 -
275   I check Receivable(Debtor) Account for debit.
276 -
277   !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Debited successfully.}: 
278     - debit == 20
279 -
280   I pay the invoice.
281 -
282   !python {model: account.invoice}: |
283     move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name
284     account_invoice= self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])
285     journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')], limit=1)
286     pay = self.pay_and_reconcile(cr, uid, account_invoice,
287                         20.0, ref('account_anglo_cash_fifo'), ref('account.period_8'),
288                         journal_ids[0], ref('account_anglo_cash_fifo'),
289                         ref('account.period_8'), journal_ids[0],
290                         name='Payment for test customer invoice')
291     assert (pay == True), "Incorrect Payment."
292 -
293   I check Receivable(Debtor) Account for credit.
294 -
295   !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Credited successfully.}: 
296     - credit == 20
297 -
298   I check Bank/Cash account is debited sucessfully after invoice paid.
299 -
300   !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not successfully credited.}:
301     - debit == 20