How to use cost method in lisa

Best Python code snippet using lisa_python

test_stock_landed_costs_rounding.py

Source:test_stock_landed_costs_rounding.py Github

copy

Full Screen

...88 stock_landed_cost_2.cost_lines.price_unit = 1589 vals = stock_landed_cost_2._convert_to_write(stock_landed_cost_2._cache)90 stock_landed_cost_2 = self.env['stock.landed.cost'].create(vals)91 # I compute the landed cost using Compute button92 stock_landed_cost_2.compute_landed_cost()93 # I check the valuation adjustment lines94 for valuation in stock_landed_cost_2.valuation_adjustment_lines:95 self.assertEqual(valuation.additional_landed_cost, 15)96 # I confirm the landed cost97 stock_landed_cost_2.button_validate()98 # I check that the landed cost is now "Closed" and that it has an accounting entry99 self.assertEqual(stock_landed_cost_2.state, 'done')100 self.assertTrue(stock_landed_cost_2.account_move_id)101 # We perform all the tests for LC_pick_4102 # I receive picking LC_pick_4, and check how many quants are created103 picking_landed_cost_4.move_lines.price_unit = 17.0/12.0104 picking_landed_cost_4.action_confirm()105 picking_landed_cost_4.action_assign()106 picking_landed_cost_4._action_done()107 # I create a landed cost for picking 4108 default_vals = self.env['stock.landed.cost'].default_get(list(self.env['stock.landed.cost'].fields_get()))109 default_vals.update({110 'picking_ids': [picking_landed_cost_4.id],111 'account_journal_id': self.expenses_journal,112 'cost_lines': [(0, 0, {'product_id': virtual_interior_design.id})],113 'valuation_adjustment_lines': [],114 })115 stock_landed_cost_3 = self.env['stock.landed.cost'].new(default_vals)116 stock_landed_cost_3.cost_lines.onchange_product_id()117 stock_landed_cost_3.cost_lines.name = 'equal split'118 stock_landed_cost_3.cost_lines.split_method = 'equal'119 stock_landed_cost_3.cost_lines.price_unit = 11120 vals = stock_landed_cost_3._convert_to_write(stock_landed_cost_3._cache)121 stock_landed_cost_3 = self.env['stock.landed.cost'].create(vals)122 # I compute the landed cost using Compute button123 stock_landed_cost_3.compute_landed_cost()124 # I check the valuation adjustment lines125 for valuation in stock_landed_cost_3.valuation_adjustment_lines:126 self.assertEqual(valuation.additional_landed_cost, 11)127 # I confirm the landed cost128 stock_landed_cost_3.button_validate()129 # I check that the landed cost is now "Closed" and that it has an accounting entry130 self.assertEqual(stock_landed_cost_3.state, 'done')131 self.assertTrue(stock_landed_cost_3.account_move_id)132 def test_stock_landed_costs_rounding_02(self):133 """ The landed costs should be correctly computed, even when the decimal accuracy134 of the deciaml price is increased. """135 self.env.ref("product.decimal_price").digits = 4136 fifo_pc = self.env['product.category'].create({137 'name': 'Fifo Category',138 'parent_id': self.env.ref("product.product_category_all").id,139 'property_valuation': 'real_time',140 'property_cost_method': 'fifo',141 })142 products = self.Product.create([{143 'name': 'Super Product %s' % price,144 'categ_id': fifo_pc.id,145 'type': 'product',146 'standard_price': price,147 } for price in [0.91, 0.93, 75.17, 20.54]])148 landed_product = self.Product.create({149 'name': 'Landed Costs',150 'type': 'service',151 'landed_cost_ok': True,152 'split_method_landed_cost': 'by_quantity',153 'standard_price': 1000.0,154 })155 po = self.env['purchase.order'].create({156 'partner_id': self.partner_a.id,157 'order_line': [(0, 0, {158 'product_id': product.id,159 'product_qty': qty,160 'price_unit': product.standard_price,161 }) for product, qty in zip(products, [6, 6, 3, 6])]162 })163 po.button_confirm()164 res_dict = po.picking_ids.button_validate()165 validate_wizard = Form(self.env[(res_dict.get('res_model'))].with_context(res_dict.get('context'))).save()166 validate_wizard.process()167 lc_form = Form(self.LandedCost)168 lc_form.picking_ids.add(po.picking_ids)169 with lc_form.cost_lines.new() as line:170 line.product_id = landed_product171 lc = lc_form.save()172 lc.compute_landed_cost()...

Full Screen

Full Screen

test_stock_landed_costs.py

Source:test_stock_landed_costs.py Github

copy

Full Screen

...108 cost_line.price_unit = cost_lines_values['price_unit'][index]109 vals = stock_landed_cost_1._convert_to_write(stock_landed_cost_1._cache)110 stock_landed_cost_1 = self.env['stock.landed.cost'].create(vals)111 # I compute the landed cost using Compute button112 stock_landed_cost_1.compute_landed_cost()113 # I check the valuation adjustment lines114 for valuation in stock_landed_cost_1.valuation_adjustment_lines:115 if valuation.cost_line_id.name == 'equal split':116 self.assertEqual(valuation.additional_landed_cost, 5)117 elif valuation.cost_line_id.name == 'split by quantity' and valuation.move_id.name == "move 1":118 self.assertEqual(valuation.additional_landed_cost, 50)119 elif valuation.cost_line_id.name == 'split by quantity' and valuation.move_id.name == "move 2":120 self.assertEqual(valuation.additional_landed_cost, 100)121 elif valuation.cost_line_id.name == 'split by weight' and valuation.move_id.name == "move 1":122 self.assertEqual(valuation.additional_landed_cost, 50)123 elif valuation.cost_line_id.name == 'split by weight' and valuation.move_id.name == "move 2":124 self.assertEqual(valuation.additional_landed_cost, 200)125 elif valuation.cost_line_id.name == 'split by volume' and valuation.move_id.name == "move 1":126 self.assertEqual(valuation.additional_landed_cost, 5)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful