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

[18.0] [MIG] partner shipping policy #1974

Open
wants to merge 7 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions partner_shipping_policy/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
=======================
Partner Shipping Policy
=======================

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

.. |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%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/18.0/partner_shipping_policy
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_shipping_policy
: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/partner-contact&target_branch=18.0
:alt: Try me on Runboat

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

A new field is introduced to specify the shipping policy for each
partner. In sales orders, the shipping policy will be set to the
delivery address contact shipping policy. If the field is empty, it
falls back to the shipping policy set in the main contact. If neither
the delivery address nor the customer contact has a shipping policy set,
it will be set with the configured default value.

**Table of contents**

.. contents::
:local:

Usage
=====

Fill in the shipping policy field for the contact in the contact form.
You can find this new field in the "Sales & Purchase" tab. When creating
a sales order the shipping policy will be set taking into account the
delivery address shipping policy or the main contact shipping policy.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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/partner-contact/issues/new?body=module:%20partner_shipping_policy%0Aversion:%2018.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
-------

* ForgeFlow

Contributors
------------

- Marina Alapont <[email protected]>

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.

This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/partner_shipping_policy>`_ 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 partner_shipping_policy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions partner_shipping_policy/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Partner Shipping Policy",
"summary": "Define shipping policy at partners level.",
"author": "ForgeFlow,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"category": "Sales",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"depends": ["sale_stock"],
"data": ["views/res_partner_views.xml"],
"installable": True,
"application": False,
}
54 changes: 54 additions & 0 deletions partner_shipping_policy/i18n/da_DK.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_shipping_policy
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-03 08:34+0000\n"
"PO-Revision-Date: 2024-04-03 08:34+0000\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: partner_shipping_policy
#: model:ir.model.fields.selection,name:partner_shipping_policy.selection__res_partner__picking_policy__direct
msgid "As soon as possible"
msgstr "Hurtigst muligt"

#. module: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_res_partner
msgid "Contact"
msgstr "Kontakt"

#. module: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_sale_order
msgid "Sales Order"
msgstr "Salgsordre"

#. module: partner_shipping_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_users__picking_policy
msgid "Shipping Policy"
msgstr "Afsendelses måde"

#. module: partner_shipping_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_users__picking_policy
msgid ""
"Shipping policy to use in this partner's sales orders. If you deliver all "
"products at once, the delivery order will be scheduled based on the greatest"
" product lead time. Otherwise, it will be based on the shortest."
msgstr ""
"Forsendelsespolitik til brug i denne partner salgsordrer. Hvis du levere alle "
"produkter samtidigt, vil leveringsordren blive planlagt ud fra den længste"
" produkt ledetid. Ellers vil den være baseret på den korteste."

#. module: partner_shipping_policy
#: model:ir.model.fields.selection,name:partner_shipping_policy.selection__res_partner__picking_policy__one
msgid "When all products are ready"
msgstr "Når alle produkter er klar"
58 changes: 58 additions & 0 deletions partner_shipping_policy/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_shipping_policy
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-08-26 12:06+0000\n"
"Last-Translator: mymage <[email protected]>\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 5.6.2\n"

#. module: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: partner_shipping_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_sale_order__picking_policy
msgid ""
"If you deliver all products at once, the delivery order will be scheduled "
"based on the greatest product lead time. Otherwise, it will be based on the "
"shortest."
msgstr ""
"Se tutti i prodotti vengono consegnati insieme, l'ordine di consegna verrà "
"pianificato in base al tempo di attraversamento maggiore. Altrimenti, verrà "
"utilizzato il più corto."

#. module: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#. module: partner_shipping_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_users__picking_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_sale_order__picking_policy
msgid "Shipping Policy"
msgstr "Politica di spedizione"

#. module: partner_shipping_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_users__picking_policy
msgid ""
"Shipping policy to use in this partner's sales orders. If you deliver all "
"products at once, the delivery order will be scheduled based on the greatest"
" product lead time. Otherwise, it will be based on the shortest."
msgstr ""
"La politica di spedizione da utilizzare negli ordini di vendita di questo "
"partner. Se si consegnano tutti i prodotti in una volta, l'ordine di "
"consegna verrà pianificato in base al lead time del prodotto più lungo. In "
"caso contrario, verrà basato sul più breve."
48 changes: 48 additions & 0 deletions partner_shipping_policy/i18n/partner_shipping_policy.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_shipping_policy
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_shipping_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_sale_order__picking_policy
msgid ""
"If you deliver all products at once, the delivery order will be scheduled "
"based on the greatest product lead time. Otherwise, it will be based on the "
"shortest."
msgstr ""

#. module: partner_shipping_policy
#: model:ir.model,name:partner_shipping_policy.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: partner_shipping_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_res_users__picking_policy
#: model:ir.model.fields,field_description:partner_shipping_policy.field_sale_order__picking_policy
msgid "Shipping Policy"
msgstr ""

#. module: partner_shipping_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_partner__picking_policy
#: model:ir.model.fields,help:partner_shipping_policy.field_res_users__picking_policy
msgid ""
"Shipping policy to use in this partner's sales orders. If you deliver all "
"products at once, the delivery order will be scheduled based on the greatest"
" product lead time. Otherwise, it will be based on the shortest."
msgstr ""
2 changes: 2 additions & 0 deletions partner_shipping_policy/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner
from . import sale_order
22 changes: 22 additions & 0 deletions partner_shipping_policy/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class Partner(models.Model):
_inherit = "res.partner"

picking_policy = fields.Selection(
selection="_get_picking_policy_selection",
string="Shipping Policy",
help="Shipping policy to use in this partner's sales orders. If you deliver "
"all products at once, the delivery order will be scheduled based on the "
"greatest product lead time. Otherwise, it will be based on the shortest.",
)

@api.model
def _get_picking_policy_selection(self):
return self.env["sale.order"].fields_get(["picking_policy"])["picking_policy"][
"selection"
]
23 changes: 23 additions & 0 deletions partner_shipping_policy/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

# Convert field to a computed
picking_policy = fields.Selection(
compute="_compute_picking_policy", store=True, readonly=False
)

@api.depends("partner_id")
def _compute_picking_policy(self):
for this in self:
picking_policy = (
this.partner_shipping_id.picking_policy
or this.partner_id.picking_policy
or self.default_get(["picking_policy"]).get("picking_policy")
)
this.picking_policy = picking_policy
3 changes: 3 additions & 0 deletions partner_shipping_policy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions partner_shipping_policy/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Marina Alapont \<<[email protected]>\>
6 changes: 6 additions & 0 deletions partner_shipping_policy/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A new field is introduced to specify the shipping policy for each
partner. In sales orders, the shipping policy will be set to the
delivery address contact shipping policy. If the field is empty, it
falls back to the shipping policy set in the main contact. If neither
the delivery address nor the customer contact has a shipping policy set,
it will be set with the configured default value.
4 changes: 4 additions & 0 deletions partner_shipping_policy/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fill in the shipping policy field for the contact in the contact form.
You can find this new field in the "Sales & Purchase" tab. When creating
a sales order the shipping policy will be set taking into account the
delivery address shipping policy or the main contact shipping policy.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading