def test_vendor_bill_flow_anglo_saxon_2(self): """In anglo saxon accounting, receive 10@10 and invoice with the addition of 1@50 as a landed costs and create a linked landed costs record. """ self.env.company.anglo_saxon_accounting = True # Create an RFQ for self.product1, 10@10 rfq = Form(self.env['purchase.order']) rfq.partner_id = self.vendor1 with rfq.order_line.new() as po_line: po_line.product_id = self.product1 po_line.price_unit = 10 po_line.product_qty = 10 po_line.taxes_id.clear() rfq = rfq.save() rfq.button_confirm() # Process the receipt receipt = rfq.picking_ids wiz = receipt.button_validate() wiz = self.env['stock.immediate.transfer'].browse( wiz['res_id']).process() self.assertEqual(rfq.order_line.qty_received, 10) input_aml = self._get_stock_input_move_lines()[-1] self.assertEqual(input_aml.debit, 0) self.assertEqual(input_aml.credit, 100) valuation_aml = self._get_stock_valuation_move_lines()[-1] self.assertEqual(valuation_aml.debit, 100) self.assertEqual(valuation_aml.credit, 0) # Create a vebdor bill for the RFQ and add to it the landed cost action = rfq.action_view_invoice() vb = Form(self.env['account.move'].with_context(action['context'])) with vb.invoice_line_ids.new() as inv_line: inv_line.product_id = self.productlc1 inv_line.price_unit = 50 inv_line.is_landed_costs_line = True vb = vb.save() vb.post() action = vb.button_create_landed_costs() lc = Form(self.env[action['res_model']].browse(action['res_id'])) lc.picking_ids.add(receipt) lc = lc.save() lc.button_validate() # Check reconciliation of input aml of lc lc_input_aml = lc.account_move_id.line_ids.filtered( lambda aml: aml.account_id == self.stock_input_account) self.assertTrue(len(lc_input_aml.full_reconcile_id), 1)
def test_date_planned_1(self): """Set a date planned on a PO, see that it is set on the PO lines. Try to edit the date planned of the PO line, see that it is not possible. Unset the date planned on the PO and edit the date planned on the PO lines. Validate the PO and see that it isn't possible to set the date planned on the PO nor on the PO lines. """ po = Form(self.env['purchase.order']) po.partner_id = self.vendor with po.order_line.new() as po_line: po_line.product_id = self.product_consu po_line.product_qty = 1 po_line.price_unit = 100 with po.order_line.new() as po_line: po_line.product_id = self.product_consu2 po_line.product_qty = 10 po_line.price_unit = 200 po = po.save() # Check there is no date planned on the PO and the same date planned on both PO lines. self.assertEqual(po.date_planned, False) self.assertNotEqual(po.order_line[0].date_planned, False) self.assertAlmostEqual(po.order_line[0].date_planned, po.order_line[1].date_planned, delta=timedelta(seconds=10)) orig_date_planned = po.order_line[0].date_planned # Set a date planned on a PO, see that it is set on the PO lines. new_date_planned = orig_date_planned + timedelta(hours=1) po.date_planned = new_date_planned self.assertAlmostEqual(po.order_line[0].date_planned, new_date_planned, delta=timedelta(seconds=10)) self.assertAlmostEqual(po.order_line[1].date_planned, new_date_planned, delta=timedelta(seconds=10)) # Try to edit the date planned of the PO line, see that it is not possible po = Form(po) with self.assertRaises(AssertionError): po.order_line.edit(0).date_planned = orig_date_planned with self.assertRaises(AssertionError): po.order_line.edit(1).date_planned = orig_date_planned po = po.save() self.assertAlmostEqual(po.order_line[0].date_planned, new_date_planned, delta=timedelta(seconds=10)) self.assertAlmostEqual(po.order_line[1].date_planned, new_date_planned, delta=timedelta(seconds=10)) # Unset the date planned on the PO and edit the date planned on the PO line. po = Form(po) po.date_planned = False with po.order_line.edit(0) as po_line: po_line.date_planned = orig_date_planned with po.order_line.edit(1) as po_line: po_line.date_planned = orig_date_planned po = po.save() self.assertAlmostEqual(po.order_line[0].date_planned, orig_date_planned, delta=timedelta(seconds=10)) self.assertAlmostEqual(po.order_line[1].date_planned, orig_date_planned, delta=timedelta(seconds=10)) # Validate the PO and see that it isn't possible to set the date planned on the PO # nor on the PO lines. po.button_confirm() po.button_done() po = Form(po) with self.assertRaises(AssertionError): po.date_planned = new_date_planned with self.assertRaises(AssertionError): with po.order_line.edit(0) as po_line: po_line.date_planned = orig_date_planned with self.assertRaises(AssertionError): with po.order_line.edit(1) as po_line: po_line.date_planned = orig_date_planned po.save()
def test_vendor_bill_flow_continental_1(self): """In continental accounting, receive 10@10 and invoice. Then invoice 1@50 as a landed costs and create a linked landed costs record. """ self.env.company.anglo_saxon_accounting = False # Create an RFQ for self.product1, 10@10 rfq = Form(self.env['purchase.order']) rfq.partner_id = self.vendor1 with rfq.order_line.new() as po_line: po_line.product_id = self.product1 po_line.price_unit = 10 po_line.product_qty = 10 po_line.taxes_id.clear() rfq = rfq.save() rfq.button_confirm() # Process the receipt receipt = rfq.picking_ids wiz = receipt.button_validate() wiz = self.env['stock.immediate.transfer'].browse( wiz['res_id']).process() self.assertEqual(rfq.order_line.qty_received, 10) input_aml = self._get_stock_input_move_lines()[-1] self.assertEqual(input_aml.debit, 0) self.assertEqual(input_aml.credit, 100) valuation_aml = self._get_stock_valuation_move_lines()[-1] self.assertEqual(valuation_aml.debit, 100) self.assertEqual(valuation_aml.credit, 0) # Create a vebdor bill for the RFQ action = rfq.action_view_invoice() vb = Form(self.env['account.move'].with_context(action['context'])) vb = vb.save() vb.post() expense_aml = self._get_expense_move_lines()[-1] self.assertEqual(expense_aml.debit, 100) self.assertEqual(expense_aml.credit, 0) payable_aml = self._get_payable_move_lines()[-1] self.assertEqual(payable_aml.debit, 0) self.assertEqual(payable_aml.credit, 100) # Create a vendor bill for a landed cost product, post it and validate a landed cost # linked to this vendor bill. LC; 1@50 lcvb = Form( self.env['account.move'].with_context(default_type='in_invoice')) lcvb.partner_id = self.vendor2 with lcvb.invoice_line_ids.new() as inv_line: inv_line.product_id = self.productlc1 inv_line.price_unit = 50 inv_line.is_landed_costs_line = True with lcvb.invoice_line_ids.edit(0) as inv_line: inv_line.tax_ids.clear() lcvb = lcvb.save() lcvb.post() expense_aml = self._get_expense_move_lines()[-1] self.assertEqual(expense_aml.debit, 50) self.assertEqual(expense_aml.credit, 0) payable_aml = self._get_payable_move_lines()[-1] self.assertEqual(payable_aml.debit, 0) self.assertEqual(payable_aml.credit, 50) action = lcvb.button_create_landed_costs() lc = Form(self.env[action['res_model']].browse(action['res_id'])) lc.picking_ids.add(receipt) lc = lc.save() lc.button_validate() self.assertEqual(lc.cost_lines.price_unit, 50) self.assertEqual(lc.cost_lines.product_id, self.productlc1) input_aml = self._get_stock_input_move_lines()[-1] self.assertEqual(input_aml.debit, 0) self.assertEqual(input_aml.credit, 50) valuation_aml = self._get_stock_valuation_move_lines()[-1] self.assertEqual(valuation_aml.debit, 50) self.assertEqual(valuation_aml.credit, 0) self.assertEqual(self.product1.quantity_svl, 10) self.assertEqual(self.product1.value_svl, 150)