Skip to content

Commit

Permalink
[MIG] delivery_purchase: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandeep committed Sep 11, 2024
1 parent fc4a4a0 commit cb082a2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions delivery_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

{
"name": "Delivery costs in purchases",
"version": "16.0.1.1.0",
"version": "17.0.1.1.0",
"development_status": "Production/Stable",
"category": "Operations/Purchase",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["purchase", "delivery"],
"depends": ["purchase", "stock_delivery"],
"data": ["views/purchase_order_view.xml", "views/stock_picking_view.xml"],
}
2 changes: 1 addition & 1 deletion delivery_purchase/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _purchase_get_price_available(self, order):
order = order.sudo()
weight = volume = quantity = 0
for line in order.order_line.filtered(
lambda l: l.state != "cancel" and bool(l.product_id)
lambda ln: ln.state != "cancel" and bool(ln.product_id)
):
qty = line.product_uom._compute_quantity(
line.product_uom_qty, line.product_id.uom_id
Expand Down
17 changes: 12 additions & 5 deletions delivery_purchase/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2021 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from markupsafe import Markup

from odoo import _, models


Expand Down Expand Up @@ -29,13 +31,18 @@ def purchase_send_to_shipper(self):
if res["tracking_number"]:
self.carrier_tracking_ref = res["tracking_number"]

Check warning on line 32 in delivery_purchase/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

delivery_purchase/models/stock_picking.py#L32

Added line #L32 was not covered by tests
order_currency = self.purchase_id.currency_id or self.company_id.currency_id
msg = _(
"Shipment sent to carrier %(carrier_name)s for shipping with tracking "
"number %(tracking_ref)s<br/>Cost: %(carrier_price)s %(currency_name)s"
) % (
{
msg = (
_(
"Shipment sent to carrier %(carrier_name)s for shipping with \
tracking number %(tracking_ref)s"
)
% {
"carrier_name": self.carrier_id.name,
"tracking_ref": self.carrier_tracking_ref,
}
+ Markup("<br/>")
+ _("Cost: %(carrier_price)s %(currency_name)s")
% {
"carrier_price": "%.2f" % self.carrier_price,
"currency_name": order_currency.name,
}
Expand Down
6 changes: 2 additions & 4 deletions delivery_purchase/tests/test_delivery_purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def setUpClass(cls):
cls.purchase_line = cls.purchase.order_line

def _action_picking_validate(self, picking):
res = picking.button_validate()
model = self.env[res["res_model"]].with_context(**res["context"])
model.create({}).process()
picking.button_validate()


class TestDeliveryPurchase(TestDeliveryPurchaseBase):
Expand Down Expand Up @@ -129,7 +127,7 @@ def test_picking_carrier_multi(self):
picking = self.purchase.picking_ids
picking.carrier_id = self.carrier_fixed
for move in picking.move_ids_without_package:
move.quantity_done = 1
move.quantity = 1
res = picking.button_validate()
model = self.env[res["res_model"]].with_context(**res["context"])
model.create({}).process_cancel_backorder()
Expand Down
4 changes: 2 additions & 2 deletions delivery_purchase/views/purchase_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
name="delivery_price"
widget='monetary'
options="{'currency_field': 'currency_id'}"
attrs="{'invisible': [('carrier_id', '=', False)]}"
invisible="not carrier_id"
/>
</div>
</div>
Expand All @@ -24,7 +24,7 @@
>
<field
name="delivery_picking_orig_id"
attrs="{'invisible': [('delivery_picking_orig_id', '=', False)]}"
invisible="not delivery_picking_orig_id"
/>
</xpath>
</field>
Expand Down
7 changes: 5 additions & 2 deletions delivery_purchase/views/stock_picking_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
<record id="view_picking_withcarrier_out_form" model="ir.ui.view">
<field name="name">delivery.stock.picking_withcarrier.form.view</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="delivery.view_picking_withcarrier_out_form" />
<field
name="inherit_id"
ref="stock_delivery.view_picking_withcarrier_out_form"
/>
<field name="arch" type="xml">
<field name="carrier_id" position="after">
<field name="purchase_id" invisible="1" />
<field
name="carrier_price"
force_save="1"
attrs="{'invisible': ['|', ('purchase_id', '=', False),('carrier_id', '=', False)]}"
invisible="(not purchase_id) or (not carrier_id)"
/>
</field>
</field>
Expand Down

0 comments on commit cb082a2

Please sign in to comment.