Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] stock_landed_costs_delivery: Migration to version 16.0 #1559

Merged
merged 8 commits into from
May 29, 2024
6 changes: 6 additions & 0 deletions setup/stock_landed_costs_delivery/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
102 changes: 102 additions & 0 deletions stock_landed_costs_delivery/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
===========================
Stock landed costs delivery
===========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a1ff3f74ed89cad18c0fd8fe165e2930769f00e48c602cf148cfe5fb6095b395
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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/16.0/stock_landed_costs_delivery
: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-16-0/stock-logistics-workflow-16-0-stock_landed_costs_delivery
: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/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

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

This addon adds a cost line with the carrier of the purchase order and the price.

**Table of contents**

.. contents::
:local:

Usage
=====

#. Go to Inventory > Configuration > Shipping methods
#. Create a record with Allow create landed cost lines option checked.
#. Go to Purchase > Orders > Requests for Quotation.
#. Create an order with 2 lines: storable product + service product (landed cost).
#. Set Custom carrier.
#. Confirm Order.
#. Receives products and done picking.
#. Go to Inventory > Operations > Landed Costs.
#. A record related to the delivery purchase order lines and a cost line was created with the shipping price.
#. Landed Cost will be validated when linked purchase picking are done.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_landed_costs_delivery%0Aversion:%2016.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>`_

* Pedro M. Baeza
* Víctor Martínez
* Carolina Fernandez

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

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/16.0/stock_landed_costs_delivery>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_landed_costs_delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_landed_costs_delivery/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Stock landed costs delivery",
"version": "16.0.1.0.0",
"category": "Inventory",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["delivery_purchase", "stock_landed_costs_purchase_auto"],
"data": ["views/delivery_carrier_view.xml"],
"installable": True,
"maintainers": ["victoralmau"],
}
47 changes: 47 additions & 0 deletions stock_landed_costs_delivery/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_landed_costs_delivery
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-19 15:37+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,field_description:stock_landed_costs_delivery.field_delivery_carrier__create_landed_cost_line
msgid "Allow create landed cost lines"
msgstr "Consente creazione righe costi accessori"

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_purchase_order
msgid "Purchase Order"
msgstr "Ordine di acquisto"

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_delivery_carrier
msgid "Shipping Methods"
msgstr "Metodi di spedizione"

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,field_description:stock_landed_costs_delivery.field_delivery_carrier__split_method_landed_cost_line
msgid "Split method"
msgstr "Metodo di divisione"

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,help:stock_landed_costs_delivery.field_delivery_carrier__split_method_landed_cost_line
msgid "Split method used in landed cost lines"
msgstr "Metodo di divisione utilizzato nelle righe costi accessori"

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"
44 changes: 44 additions & 0 deletions stock_landed_costs_delivery/i18n/stock_landed_costs_delivery.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_landed_costs_delivery
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,field_description:stock_landed_costs_delivery.field_delivery_carrier__create_landed_cost_line
msgid "Allow create landed cost lines"
msgstr ""

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_delivery_carrier
msgid "Shipping Methods"
msgstr ""

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,field_description:stock_landed_costs_delivery.field_delivery_carrier__split_method_landed_cost_line
msgid "Split method"
msgstr ""

#. module: stock_landed_costs_delivery
#: model:ir.model.fields,help:stock_landed_costs_delivery.field_delivery_carrier__split_method_landed_cost_line
msgid "Split method used in landed cost lines"
msgstr ""

#. module: stock_landed_costs_delivery
#: model:ir.model,name:stock_landed_costs_delivery.model_stock_picking
msgid "Transfer"
msgstr ""
4 changes: 4 additions & 0 deletions stock_landed_costs_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import delivery_carrier
from . import purchase_order
from . import stock_picking
22 changes: 22 additions & 0 deletions stock_landed_costs_delivery/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class DeliveryCarrier(models.Model):
_inherit = "delivery.carrier"

@api.model
def _get_selection_split_method_landed_cost_line(self):
model = self.env["stock.landed.cost.lines"]
return model.fields_get(allfields=["split_method"])["split_method"]["selection"]

create_landed_cost_line = fields.Boolean(
string="Allow create landed cost lines", default=True
)
split_method_landed_cost_line = fields.Selection(
selection="_get_selection_split_method_landed_cost_line",
string="Split method",
default="by_quantity",
help="Split method used in landed cost lines",
)
33 changes: 33 additions & 0 deletions stock_landed_costs_delivery/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021-2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

def _prepare_landed_cost_line_delivery_values(self, carrier, price_unit):
return {
"product_id": carrier.product_id.id,
"name": carrier.name,
"price_unit": price_unit,
"split_method": carrier.split_method_landed_cost_line,
}

def _create_delivery_line(self, carrier, price_unit):
"""Auto-add delivery line to first draft Landed cost.
We need to add the line to the first Landed cost due to the process:
1- A new landed cost is created, if applicable (backorder).
2- The _create_delivery_line() method is called."""
res = super()._create_delivery_line(carrier=carrier, price_unit=price_unit)
if carrier.create_landed_cost_line:
vals = self._prepare_landed_cost_line_delivery_values(carrier, price_unit)
lc = self.sudo().landed_cost_ids.filtered(lambda x: x.state == "draft")
# Use the context to identify which picking is being generated from and
# set cost lines in the correct Landed cost.
if self.env.context.get("from_picking"):
picking = self.env.context.get("from_picking")
lc = lc.filtered(lambda x: picking in x.picking_ids)
if lc:
lc[0].cost_lines = [(0, 0, vals)]
return res
30 changes: 30 additions & 0 deletions stock_landed_costs_delivery/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023-2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.tools import config


class StockPicking(models.Model):
_inherit = "stock.picking"

def _add_delivery_cost_to_po(self):
"""We add the context to identify in _create_delivery_line() method the picking."""
self.ensure_one()
self = self.with_context(from_picking=self)
return super()._add_delivery_cost_to_po()

def _action_done(self):
"""Validate Landed costs linked to the purchase and picking."""
res = super()._action_done()
if not config["test_enable"] or self.env.context.get(
"test_stock_landed_costs_delivery"
):
for item in self:
landed_cost = item.purchase_id.sudo().landed_cost_ids.filtered(
lambda x: item in x.picking_ids
and x.state == "draft"
and x.cost_lines
)
if landed_cost:
landed_cost.button_validate()
return res
5 changes: 5 additions & 0 deletions stock_landed_costs_delivery/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_

* Pedro M. Baeza
* Víctor Martínez
* Carolina Fernandez
1 change: 1 addition & 0 deletions stock_landed_costs_delivery/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This addon adds a cost line with the carrier of the purchase order and the price.
10 changes: 10 additions & 0 deletions stock_landed_costs_delivery/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#. Go to Inventory > Configuration > Shipping methods
#. Create a record with Allow create landed cost lines option checked.
#. Go to Purchase > Orders > Requests for Quotation.
#. Create an order with 2 lines: storable product + service product (landed cost).
#. Set Custom carrier.
#. Confirm Order.
#. Receives products and done picking.
#. Go to Inventory > Operations > Landed Costs.
#. A record related to the delivery purchase order lines and a cost line was created with the shipping price.
#. Landed Cost will be validated when linked purchase picking are done.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading