Skip to content

Commit

Permalink
[MIG] stock_landed_costs_purchase_auto: Migration to 15.0
Browse files Browse the repository at this point in the history
TT41587
  • Loading branch information
victoralmau committed Feb 9, 2023
1 parent 0dca490 commit d8b5a14
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
10 changes: 5 additions & 5 deletions stock_landed_costs_purchase_auto/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Stock landed costs purchase auto
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/13.0/stock_landed_costs_purchase_auto
:target: https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_landed_costs_purchase_auto
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-13-0/stock-logistics-workflow-13-0-stock_landed_costs_purchase_auto
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-stock_landed_costs_purchase_auto
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/154/13.0
:target: https://runbot.odoo-community.org/runbot/154/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_landed_costs_purchase_auto%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_landed_costs_purchase_auto%0Aversion:%2015.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.

Expand Down Expand Up @@ -91,6 +91,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/13.0/stock_landed_costs_purchase_auto>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_landed_costs_purchase_auto>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion stock_landed_costs_purchase_auto/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Stock landed costs purchase auto",
"version": "13.0.1.0.0",
"version": "15.0.1.0.0",
"category": "Inventory",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
11 changes: 7 additions & 4 deletions stock_landed_costs_purchase_auto/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2021-2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models

Expand Down Expand Up @@ -32,7 +32,7 @@ def _create_picking_with_stock_landed_cost(self, picking):
self.ensure_one()
landed_cost = (
self.env["stock.landed.cost"]
.with_context(force_company=self.company_id.id)
.with_company(self.company_id)
.create(self._prepare_landed_cost_values(picking))
)
self.write({"landed_cost_ids": [(4, landed_cost.id)]})
Expand All @@ -49,7 +49,9 @@ def _create_picking(self):
return res

def action_view_stock_landed_cost(self):
action = self.env.ref("stock_landed_costs.action_stock_landed_cost").read()[0]
action = self.env["ir.actions.act_window"]._for_xml_id(
"stock_landed_costs.action_stock_landed_cost"
)
action["context"] = {"search_default_purchase_id": self.id}
return action

Expand All @@ -59,10 +61,11 @@ class PurchaseOrderLine(models.Model):

def _create_or_update_picking(self):
all_pickings = self.mapped("order_id.picking_ids")
super()._create_or_update_picking()
res = super()._create_or_update_picking()
for order in self.mapped("order_id"):
order_pickings = order.picking_ids - all_pickings
if order_pickings:
order._create_picking_with_stock_landed_cost(
fields.first(order_pickings)
)
return res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Stock landed costs purchase auto</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock landed costs purchase auto</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/stock-logistics-workflow/tree/13.0/stock_landed_costs_purchase_auto"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-13-0/stock-logistics-workflow-13-0-stock_landed_costs_purchase_auto"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/154/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_landed_costs_purchase_auto"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-stock_landed_costs_purchase_auto"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/154/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This addon will auto-create a stock landed cost linked to the purchase order when it is
confirmed.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -400,7 +400,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_landed_costs_purchase_auto%0Aversion:%2013.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/stock-logistics-workflow/issues/new?body=module:%20stock_landed_costs_purchase_auto%0Aversion:%2015.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 Down Expand Up @@ -430,7 +430,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/13.0/stock_landed_costs_purchase_auto">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_landed_costs_purchase_auto">OCA/stock-logistics-workflow</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
4 changes: 2 additions & 2 deletions stock_landed_costs_purchase_auto/tests/test_purchase_order.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2021-2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo.tests import Form, common


class TestPurchaseOrder(common.SavepointCase):
class TestPurchaseOrder(common.TransactionCase):
def setUp(self):
super().setUp()
self.company = self.env.ref("base.main_company")
Expand Down

0 comments on commit d8b5a14

Please sign in to comment.