Skip to content

Commit

Permalink
[IMP] delivery_purchase: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandeep committed Sep 12, 2024
1 parent c30900a commit c68e2b0
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 93 deletions.
63 changes: 34 additions & 29 deletions delivery_purchase/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ Delivery costs in purchases
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
:target: https://github.com/OCA/delivery-carrier/tree/16.0/delivery_purchase
:target: https://github.com/OCA/delivery-carrier/tree/17.0/delivery_purchase
:alt: OCA/delivery-carrier
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_purchase
:target: https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_purchase
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to use delivery methods defined in *delivery* module to
calculate purchase delivery costs.
This module allows to use delivery methods defined in *delivery* module
to calculate purchase delivery costs.

It reverses destinations in delivery pricelists to use them as sources when
applying the delivery method to purchases.
It reverses destinations in delivery pricelists to use them as sources
when applying the delivery method to purchases.

**Table of contents**

Expand All @@ -44,52 +44,57 @@ Usage

To use this module, you need to:

#. Go to *Purchase > Orders > Purchase Orders* and create a new Purchase Order.
#. Select a carrier in the field 'Delivery Method', fill out the rest
of the form, be sure you added lines with storable products
and save the form.
#. Confirm the purchase order.
#. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and
1. Go to *Purchase > Orders > Purchase Orders* and create a new Purchase
Order.
2. Select a carrier in the field 'Delivery Method', fill out the rest of
the form, be sure you added lines with storable products and save the
form.
3. Confirm the purchase order.
4. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and
you will see, under 'Additional info' tab, the same carrier selected
in the purchase order.
#. If necessary, you can change the carrier in the 'Receipt'. When
it is validated, the 'shipping cost' of the receipt will be
calculated according to that new selected Carrier.
#. It is possible to change the shipping cost in picking.
#. The shipping cost will appear in an internal note created
5. If necessary, you can change the carrier in the 'Receipt'. When it is
validated, the 'shipping cost' of the receipt will be calculated
according to that new selected Carrier.
6. It is possible to change the shipping cost in picking.
7. The shipping cost will appear in an internal note created
automatically when the 'Receipt' is validated.
#. A purchase order line will have been created for the cost of picking.
8. A purchase order line will have been created for the cost of picking.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_purchase%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_purchase%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~
-------

* Tecnativa

Contributors
~~~~~~~~~~~~
------------

* `Tecnativa <https://www.tecnativa.com>`_:
- `Tecnativa <https://www.tecnativa.com>`__:

* Ernesto Tejeda
* Pedro M. Baeza
* Vicent Cubells
* Carolina Fernandez
- Ernesto Tejeda
- Pedro M. Baeza
- Vicent Cubells
- Carolina Fernandez

- `Sodexis <https://www.sodexis.com>`__:

- Sandeep J

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -101,6 +106,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/16.0/delivery_purchase>`_ project on GitHub.
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/17.0/delivery_purchase>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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
3 changes: 3 additions & 0 deletions delivery_purchase/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions delivery_purchase/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [Tecnativa](https://www.tecnativa.com):
- Ernesto Tejeda
- Pedro M. Baeza
- Vicent Cubells
- Carolina Fernandez

- [Sodexis](https://www.sodexis.com):
- Sandeep J
6 changes: 0 additions & 6 deletions delivery_purchase/readme/CONTRIBUTORS.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This module allows to use delivery methods defined in *delivery* module to
calculate purchase delivery costs.
This module allows to use delivery methods defined in *delivery* module
to calculate purchase delivery costs.

It reverses destinations in delivery pricelists to use them as sources when
applying the delivery method to purchases.
It reverses destinations in delivery pricelists to use them as sources
when applying the delivery method to purchases.
19 changes: 19 additions & 0 deletions delivery_purchase/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
To use this module, you need to:

1. Go to *Purchase \> Orders \> Purchase Orders* and create a new
Purchase Order.
2. Select a carrier in the field 'Delivery Method', fill out the rest
of the form, be sure you added lines with storable products and save
the form.
3. Confirm the purchase order.
4. Go to the linked 'Receipt' by clicking on 'Receipt' smart-button and
you will see, under 'Additional info' tab, the same carrier selected
in the purchase order.
5. If necessary, you can change the carrier in the 'Receipt'. When it
is validated, the 'shipping cost' of the receipt will be calculated
according to that new selected Carrier.
6. It is possible to change the shipping cost in picking.
7. The shipping cost will appear in an internal note created
automatically when the 'Receipt' is validated.
8. A purchase order line will have been created for the cost of
picking.
17 changes: 0 additions & 17 deletions delivery_purchase/readme/USAGE.rst

This file was deleted.

44 changes: 23 additions & 21 deletions delivery_purchase/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,11 +368,11 @@ <h1 class="title">Delivery costs in purchases</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:db6d440113ff4fb7edc52ddbdffc7e177d3ff2925d96f349f39754bd0e00617f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/delivery-carrier/tree/16.0/delivery_purchase"><img alt="OCA/delivery-carrier" src="https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-delivery_purchase"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to use delivery methods defined in <em>delivery</em> module to
calculate purchase delivery costs.</p>
<p>It reverses destinations in delivery pricelists to use them as sources when
applying the delivery method to purchases.</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/delivery-carrier/tree/17.0/delivery_purchase"><img alt="OCA/delivery-carrier" src="https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/delivery-carrier-17-0/delivery-carrier-17-0-delivery_purchase"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to use delivery methods defined in <em>delivery</em> module
to calculate purchase delivery costs.</p>
<p>It reverses destinations in delivery pricelists to use them as sources
when applying the delivery method to purchases.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -391,17 +390,18 @@ <h1 class="title">Delivery costs in purchases</h1>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module, you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Purchase &gt; Orders &gt; Purchase Orders</em> and create a new Purchase Order.</li>
<li>Select a carrier in the field ‘Delivery Method’, fill out the rest
of the form, be sure you added lines with storable products
and save the form.</li>
<li>Go to <em>Purchase &gt; Orders &gt; Purchase Orders</em> and create a new Purchase
Order.</li>
<li>Select a carrier in the field ‘Delivery Method’, fill out the rest of
the form, be sure you added lines with storable products and save the
form.</li>
<li>Confirm the purchase order.</li>
<li>Go to the linked ‘Receipt’ by clicking on ‘Receipt’ smart-button and
you will see, under ‘Additional info’ tab, the same carrier selected
in the purchase order.</li>
<li>If necessary, you can change the carrier in the ‘Receipt’. When
it is validated, the ‘shipping cost’ of the receipt will be
calculated according to that new selected Carrier.</li>
<li>If necessary, you can change the carrier in the ‘Receipt’. When it is
validated, the ‘shipping cost’ of the receipt will be calculated
according to that new selected Carrier.</li>
<li>It is possible to change the shipping cost in picking.</li>
<li>The shipping cost will appear in an internal note created
automatically when the ‘Receipt’ is validated.</li>
Expand All @@ -413,7 +413,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/delivery-carrier/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_purchase%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_purchase%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -434,18 +434,20 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Carolina Fernandez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.sodexis.com">Sodexis</a>:<ul>
<li>Sandeep J</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/delivery-carrier/tree/16.0/delivery_purchase">OCA/delivery-carrier</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/delivery-carrier/tree/17.0/delivery_purchase">OCA/delivery-carrier</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
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
Loading

0 comments on commit c68e2b0

Please sign in to comment.