Skip to content
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
77 changes: 77 additions & 0 deletions sale_pricelist_margin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
==========================
Sale Pricelist Sale Margin
==========================

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

.. |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/16.0/sale_pricelist_margin
: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-16-0/sale-workflow-16-0-sale_pricelist_margin
: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/sale-workflow&target_branch=16.0
:alt: Try me on Runboat

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

This module allows to set a sale margin on the pricelist.
The margin is calculated as a percentage of the cost price, list price or other price list.

**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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_pricelist_margin%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
~~~~~~~

* Sidoo

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

* Julien Coux <julien.coux@camptocamp.com>

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/16.0/sale_pricelist_margin>`_ 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 sale_pricelist_margin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions sale_pricelist_margin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Sale Pricelist Sale Margin",
"summary": "Use sale margin for pricelist items",
"version": "16.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Sidoo, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["product"],
"data": [
"views/product_pricelist_item_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions sale_pricelist_margin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_pricelist_item
24 changes: 24 additions & 0 deletions sale_pricelist_margin/models/product_pricelist_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import api, fields, models


class ProductPricelistItem(models.Model):
_inherit = "product.pricelist.item"

discount_type = fields.Selection(
[("discount", "Discount"), ("sale_margin", "Sale Margin")],
default="discount",
)
price_discount = fields.Float(
readonly=False,
compute="_compute_price_discount",
)
sale_margin = fields.Float(
help="The margin percentage for sale price.",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. looks lighter !
I wonder if it's possible to :

  • remove discount_type :
  • keep visible price_discount AND sale_margin and make them computable depending on the other.

only a remarks. not a blocking point.

thanks !


@api.depends("sale_margin")
def _compute_price_discount(self):
for record in self:
record.price_discount = (
-1 * ((1 / (1 - (record.sale_margin / 100))) - 1) * 100
)
1 change: 1 addition & 0 deletions sale_pricelist_margin/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Julien Coux <julien.coux@camptocamp.com>
2 changes: 2 additions & 0 deletions sale_pricelist_margin/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to set a sale margin on the pricelist.
The margin is calculated as a percentage of the cost price, list price or other price list.
Loading