diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst index 76feb1832966..b5e552db3680 100644 --- a/l10n_it_delivery_note/README.rst +++ b/l10n_it_delivery_note/README.rst @@ -2,7 +2,7 @@ ITA - Documento di trasporto ============================ -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! @@ -202,6 +202,7 @@ Contributors * `PyTech-SRL `_: * Alessandro Uffreduzzi * Sebastiano Picchi +* Sergio Corato Maintainers ~~~~~~~~~~~ @@ -228,7 +229,7 @@ promote its widespread use. Current `maintainers `__: -|maintainer-MarcoCalcagni| |maintainer-aleuffre| |maintainer-renda-dev| +|maintainer-MarcoCalcagni| |maintainer-aleuffre| |maintainer-renda-dev| This module is part of the `OCA/l10n-italy `_ project on GitHub. diff --git a/l10n_it_delivery_note/models/stock_picking.py b/l10n_it_delivery_note/models/stock_picking.py index f73f07b220ce..34e9be89902b 100644 --- a/l10n_it_delivery_note/models/stock_picking.py +++ b/l10n_it_delivery_note/models/stock_picking.py @@ -351,7 +351,7 @@ def _create_delivery_note(self): { "company_id": self.company_id.id, "partner_sender_id": partners[0].id, - "partner_id": self.sale_id.partner_id.id + "partner_id": self.sale_id.partner_invoice_id.id if self.sale_id else partners[0].id, "partner_shipping_id": partners[1].id, diff --git a/l10n_it_delivery_note/readme/CONTRIBUTORS.rst b/l10n_it_delivery_note/readme/CONTRIBUTORS.rst index 6447f31e0d37..375f4b367a22 100644 --- a/l10n_it_delivery_note/readme/CONTRIBUTORS.rst +++ b/l10n_it_delivery_note/readme/CONTRIBUTORS.rst @@ -14,3 +14,4 @@ * `PyTech-SRL `_: * Alessandro Uffreduzzi * Sebastiano Picchi +* Sergio Corato diff --git a/l10n_it_delivery_note/static/description/index.html b/l10n_it_delivery_note/static/description/index.html index b6248aaaf4c4..57ad2ffbd1da 100644 --- a/l10n_it_delivery_note/static/description/index.html +++ b/l10n_it_delivery_note/static/description/index.html @@ -539,6 +539,7 @@

Contributors

+
  • Sergio Corato <https://github.com/sergiocorato>
  • diff --git a/l10n_it_delivery_note/tests/test_stock_delivery_note.py b/l10n_it_delivery_note/tests/test_stock_delivery_note.py index 5caa5ee19bad..e5c5ee23d399 100644 --- a/l10n_it_delivery_note/tests/test_stock_delivery_note.py +++ b/l10n_it_delivery_note/tests/test_stock_delivery_note.py @@ -10,6 +10,15 @@ class StockDeliveryNote(StockDeliveryNoteCommon): + def setUp(self): + super().setUp() + self.partner_shipping = self.create_partner( + 'Shipping Address') + self.partner_shipping.write({ + 'parent_id': self.recipient.id, + 'type': 'delivery', + }) + # ⇒ "Ordine singolo: consegna parziale" def test_partial_delivering_single_so(self): # @@ -220,3 +229,43 @@ def test_delivery_action_confirm_without_ref(self): delivery_note_id.partner_ref = "Reference #1234" delivery_note_id.action_confirm() + + # ⇒ "Ordine singolo: consegna a indirizzo diverso" + def test_partner_shipping_delivering_single_so(self): + use_adv_notes_group_id = self.env.ref( + "l10n_it_delivery_note.use_advanced_delivery_notes").id + self.env.user.write({'groups_id': [(3, use_adv_notes_group_id)]}) + + StockPicking = self.env["stock.picking"] + StockBackorderConfirmationWizard = self.env['stock.backorder.confirmation'] + sales_order = self.create_sales_order( + [ + self.large_desk_line, # 1 + self.desk_combination_line, # 1 + ], + ) + self.assertEqual(len(sales_order.order_line), 2) + sales_order.action_confirm() + self.assertEqual(len(sales_order.picking_ids), 1) + picking = sales_order.picking_ids + self.assertEqual(len(picking.move_lines), 2) + + # deliver only the first product + picking.move_lines[0].quantity_done = 1 + + backorder_wiz_id = picking.button_validate()['res_id'] + backorder_wiz = StockBackorderConfirmationWizard.browse(backorder_wiz_id) + backorder_wiz.process() + self.assertTrue(picking.delivery_note_id) + self.assertEqual(picking.delivery_note_id.partner_id, self.recipient) + self.assertEqual(picking.delivery_note_id.partner_shipping_id, + self.partner_shipping) + picking_backorder = StockPicking.search([("backorder_id", "=", picking.id)]) + self.assertEqual(len(picking_backorder.move_lines), 1) + picking_backorder.move_lines[0].quantity_done = 1 + picking_backorder.button_validate() + self.assertTrue(picking_backorder.delivery_note_id) + self.assertEqual(picking_backorder.delivery_note_id.partner_id, + self.recipient) + self.assertEqual(picking_backorder.delivery_note_id.partner_shipping_id, + self.partner_shipping)