Skip to content
Snippets Groups Projects
Commit bdebbaee authored by William Henrotin's avatar William Henrotin
Browse files

[FIX] point_of_sale: apply cogs on delivery picking only

Commit 1e82e273 adds cogs account move lines for 'ship later'
config at the picking validation. The issue appears if the delivery flow
is in multiple steps. The account move lines will be created for each
pickings.

This commit ensure the last one actually create the aml only

Opw: 3324972
Part-of: odoo/odoo#123152
parent 74dbae6b
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,8 @@ class StockPicking(models.Model):
def _action_done(self):
res = super(StockPicking, self)._action_done()
for rec in self:
if rec.picking_type_id.code != 'outgoing':
continue
if rec.pos_order_id.to_ship and not rec.pos_order_id.to_invoice:
order_cost = sum(line.total_cost for line in rec.pos_order_id.lines)
move_vals = {
......
......@@ -226,11 +226,15 @@ class TestAngloSaxonFlow(TestAngloSaxonCommon):
def test_cogs_with_ship_later_no_invoicing(self):
# This test will check that the correct journal entries are created when a product in real time valuation
# is sold using the ship later option and no invoice is created in a company using anglo-saxon
self.pos_config.open_session_cb(check_coa=False)
current_session = self.pos_config.current_session_id
self.cash_journal.loss_account_id = self.account
current_session.set_cashbox_pos(0, None)
# 2 step delivery method
self.warehouse.delivery_steps = 'pick_ship'
# I create a PoS order with 1 unit of New product at 450 EUR
self.pos_order_pos0 = self.PosOrder.create({
'company_id': self.company.id,
......@@ -272,6 +276,7 @@ class TestAngloSaxonFlow(TestAngloSaxonCommon):
current_session_id.close_session_from_ui()
self.assertEqual(current_session_id.state, 'closed', 'Check that session is closed')
self.assertEqual(len(current_session.picking_ids), 2, "There should be 2 pickings")
current_session.picking_ids.move_ids_without_package.quantity_done = 1
current_session.picking_ids.button_validate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment