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] sale_pricelist_from_commitment_date: Migration to 16.0 #2656

Merged
74 changes: 74 additions & 0 deletions sale_pricelist_from_commitment_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
===================================
Sale Pricelist From Commitment Date
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/14.0/sale_pricelist_from_commitment_date
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_pricelist_from_commitment_date
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/14.0
:alt: Try me on Runbot

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

When the sale order commitment date is set,
this date is used by pricelist to compute price unit instead of using order date.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-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/sale-workflow/issues/new?body=module:%20sale_pricelist_from_commitment_date%0Aversion:%2014.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
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Julien Coux <[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/sale-workflow <https://github.com/OCA/sale-workflow/tree/14.0/sale_pricelist_from_commitment_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions sale_pricelist_from_commitment_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
13 changes: 13 additions & 0 deletions sale_pricelist_from_commitment_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale Pricelist From Commitment Date",
"summary": "Use sale order commitment date to compute line price from pricelist",
"version": "16.0.1.0.0",
"category": "Sale",
"website": "https://github.com/OCA/sale-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["sale"],
"installable": True,
}
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:
# * sale_pricelist_from_commitment_date
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: sale_pricelist_from_commitment_date
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_pricelist__display_name
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_product__display_name
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order__display_name
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order_line__display_name
msgid "Display Name"
msgstr ""

#. module: sale_pricelist_from_commitment_date
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_pricelist__id
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_product__id
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order__id
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order_line__id
msgid "ID"
msgstr ""

#. module: sale_pricelist_from_commitment_date
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_pricelist____last_update
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_product_product____last_update
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order____last_update
#: model:ir.model.fields,field_description:sale_pricelist_from_commitment_date.field_sale_order_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_pricelist_from_commitment_date
#: model:ir.model,name:sale_pricelist_from_commitment_date.model_product_pricelist
msgid "Pricelist"
msgstr ""

#. module: sale_pricelist_from_commitment_date
#: model:ir.model,name:sale_pricelist_from_commitment_date.model_product_product
msgid "Product"
msgstr ""

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

#. module: sale_pricelist_from_commitment_date
#: model:ir.model,name:sale_pricelist_from_commitment_date.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
5 changes: 5 additions & 0 deletions sale_pricelist_from_commitment_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import product_pricelist
from . import product_pricelist_item
from . import sale_order_line
15 changes: 15 additions & 0 deletions sale_pricelist_from_commitment_date/models/product_pricelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class ProductPricelist(models.Model):

_inherit = "product.pricelist"

def _get_product_rule(self, product, quantity, uom=None, date=False, **kwargs):
force_pricelist_date = self.env.context.get("force_pricelist_date")
if force_pricelist_date:
date = force_pricelist_date
return super()._get_product_rule(product, quantity, uom, date, **kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class ProductPricelistItem(models.Model):

_inherit = "product.pricelist.item"

def _compute_price(self, product, quantity, uom, date, currency=None):
force_pricelist_date = self.env.context.get("force_pricelist_date")
if force_pricelist_date:
date = force_pricelist_date
return super()._compute_price(product, quantity, uom, date, currency)
33 changes: 33 additions & 0 deletions sale_pricelist_from_commitment_date/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class SaleOrderLine(models.Model):

_inherit = "sale.order.line"

@api.depends(
"product_id", "product_uom", "product_uom_qty", "order_id.commitment_date"
)
def _compute_price_unit(self):
for line in self:
date = self.env.context.get(
"force_pricelist_date", line.order_id.commitment_date
)
line = line.with_context(force_pricelist_date=date)
super(SaleOrderLine, line)._compute_price_unit()
return True

@api.depends(
"product_id", "product_uom", "product_uom_qty", "order_id.commitment_date"
)
def _compute_pricelist_item_id(self):
for line in self:
date = self.env.context.get(
"force_pricelist_date", line.order_id.commitment_date
)
line = line.with_context(force_pricelist_date=date)
super(SaleOrderLine, line)._compute_pricelist_item_id()
return True
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Julien Coux <[email protected]>
2 changes: 2 additions & 0 deletions sale_pricelist_from_commitment_date/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
When the sale order commitment date is set,
this date is used by pricelist to compute price unit instead of using order date.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading