Skip to content

Commit

Permalink
[14.0][FIX] l10n_it_delivery_note shipping address
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Feb 26, 2024
1 parent ade0cc6 commit e151ae2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
5 changes: 3 additions & 2 deletions l10n_it_delivery_note/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ITA - Documento di trasporto
============================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -202,6 +202,7 @@ Contributors
* `PyTech-SRL <info@pytech.it>`_:
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
* Sebastiano Picchi <sebastiano.picchi@pytech.it>
* Sergio Corato <https://github.com/sergiocorato>

Maintainers
~~~~~~~~~~~
Expand All @@ -228,7 +229,7 @@ promote its widespread use.

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-MarcoCalcagni| |maintainer-aleuffre| |maintainer-renda-dev|
|maintainer-MarcoCalcagni| |maintainer-aleuffre| |maintainer-renda-dev|

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note>`_ project on GitHub.

Expand Down
2 changes: 1 addition & 1 deletion l10n_it_delivery_note/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions l10n_it_delivery_note/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
* `PyTech-SRL <info@pytech.it>`_:
* Alessandro Uffreduzzi <alessandro.uffreduzzi@pytech.it>
* Sebastiano Picchi <sebastiano.picchi@pytech.it>
* Sergio Corato <https://github.com/sergiocorato>
1 change: 1 addition & 0 deletions l10n_it_delivery_note/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ <h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
</dd>
</dl>
</li>
<li>Sergio Corato &lt;<a class="reference external" href="https://github.com/sergiocorato">https://github.com/sergiocorato</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
49 changes: 49 additions & 0 deletions l10n_it_delivery_note/tests/test_stock_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
#
Expand Down Expand Up @@ -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)

0 comments on commit e151ae2

Please sign in to comment.