Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7ab4ea7
[11.0][ADD] sale_margin_sync: Recompute sale margin when related stoc…
carlosdauden Oct 29, 2019
fb0c7e3
[MIG] sale_margin_sync: Migration to 12.0
carlosdauden Oct 30, 2019
6b54b6b
[IMP] sale_margin_sync: Create a pricelist for testing to avoid crash…
sergio-teruel Nov 21, 2019
606b3d7
[IMP] sale_margin_sync: black, isort
sergio-teruel Sep 17, 2020
d0662a9
[MIG] sale_margin_sync: Migration to v13.0
sergio-teruel Sep 17, 2020
a77b6c0
[IMP] sale_margin_sync: Sync sale line purchase price from stock valu…
sergio-teruel Aug 30, 2021
2e94b2f
[IMP] sale_margin_sync: black, isort, prettier
rafamarpe Oct 15, 2022
0df7b2d
[MIG] sale_margin_sync: Migration to 14.0
rafamarpe Oct 15, 2022
a77f0de
[MIG] sale_margin_sync: Migration to 15.0
CarlosRoca13 Nov 23, 2022
f6eb630
[MIG] sale_margin_sync: Migration to 16.0
Yadier-Tecnativa Apr 17, 2023
867a664
Added translation using Weblate (Spanish)
Ivorra78 Aug 21, 2023
10896da
[IMP] sale_margin_sync: test performance improvement
josep-tecnativa Oct 20, 2023
74ff8e7
Added translation using Weblate (Italian)
mymage Jan 22, 2024
90e18b3
[IMP] sale_margin_sync: pre-commit auto fixes
carlos-lopez-tecnativa Feb 7, 2025
57bf295
[MIG] sale_margin_sync: Migration to version 18.0
carlos-lopez-tecnativa Feb 7, 2025
566ee95
[UPD] Update sale_margin_sync.pot
Feb 24, 2025
8f5971f
[BOT] post-merge updates
OCA-git-bot Feb 24, 2025
85b3f3e
Added translation using Weblate (Turkish)
bo-eska May 8, 2025
d8c1cdf
Added translation using Weblate (Japanese)
smorita7749 Mar 24, 2026
3725532
[MIG] sale_margin_sync: Migration to 19.0
dreispt Aug 18, 2026
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ addon | version | maintainers | summary
[account_invoice_margin](account_invoice_margin/) | 19.0.1.0.0 | <a href='https://github.com/sergio-teruel'><img src='https://github.com/sergio-teruel.png' width='32' height='32' style='border-radius:50%;' alt='sergio-teruel'/></a> | Show margin in invoices
[account_invoice_margin_sale](account_invoice_margin_sale/) | 19.0.1.0.0 | <a href='https://github.com/sergio-teruel'><img src='https://github.com/sergio-teruel.png' width='32' height='32' style='border-radius:50%;' alt='sergio-teruel'/></a> <a href='https://github.com/carlosdauden'><img src='https://github.com/carlosdauden.png' width='32' height='32' style='border-radius:50%;' alt='carlosdauden'/></a> | Set margin in invoices from sale orders
[product_standard_margin](product_standard_margin/) | 19.0.1.1.0 | <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | Product Margin and Margin Rate
[sale_margin_sync](sale_margin_sync/) | 19.0.1.0.0 | | Recompute sale margin when stock move cost price is changed

[//]: # (end addons)

Expand Down
85 changes: 85 additions & 0 deletions sale_margin_sync/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================
Sale margin sync
================

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

.. |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/license-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%2Fmargin--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/margin-analysis/tree/19.0/sale_margin_sync
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-19-0/margin-analysis-19-0-sale_margin_sync
: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/margin-analysis&target_branch=19.0
:alt: Try me on Runboat

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

Recompute sale margin when related stock move cost price is changed.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/margin-analysis/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/margin-analysis/issues/new?body=module:%20sale_margin_sync%0Aversion:%2019.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>`__:

- Carlos Dauden
- Sergio Teruel
- Carlos Roca
- Carlos Lopez

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/margin-analysis <https://github.com/OCA/margin-analysis/tree/19.0/sale_margin_sync>`_ 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_margin_sync/__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_margin_sync/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale margin sync",
"summary": "Recompute sale margin when stock move cost price is changed",
"version": "19.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/margin-analysis",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["sale_margin", "sale_stock"],
}
22 changes: 22 additions & 0 deletions sale_margin_sync/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_margin_sync
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-09-02 18:17+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\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: sale_margin_sync
#: model:ir.model,name:sale_margin_sync.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de stock"
22 changes: 22 additions & 0 deletions sale_margin_sync/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_margin_sync
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-29 17:38+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: sale_margin_sync
#: model:ir.model,name:sale_margin_sync.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"
20 changes: 20 additions & 0 deletions sale_margin_sync/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_margin_sync
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"

#. module: sale_margin_sync
#: model:ir.model,name:sale_margin_sync.model_stock_move
msgid "Stock Move"
msgstr ""
19 changes: 19 additions & 0 deletions sale_margin_sync/i18n/sale_margin_sync.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_margin_sync
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.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_margin_sync
#: model:ir.model,name:sale_margin_sync.model_stock_move
msgid "Stock Move"
msgstr ""
20 changes: 20 additions & 0 deletions sale_margin_sync/i18n/tr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_margin_sync
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: tr\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"

#. module: sale_margin_sync
#: model:ir.model,name:sale_margin_sync.model_stock_move
msgid "Stock Move"
msgstr ""
3 changes: 3 additions & 0 deletions sale_margin_sync/models/__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 stock_move
38 changes: 38 additions & 0 deletions sale_margin_sync/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _set_value(self, correction_quantity=None):
# Update purchase price from sale line linked to the move after the base
# value is set.
res = super()._set_value(correction_quantity=correction_quantity)
if not self.env.context.get("skip_sale_margin_sync", False):
self.sale_margin_sync()
return res

def write(self, vals):
res = super().write(vals)
# Update purchase price from sale line linked to the move
if "value" in vals and not self.env.context.get("skip_sale_margin_sync", False):
self.sale_margin_sync()
return res

def sale_margin_sync(self):
"""Only synchronize outgoing moves"""
for move in self.filtered(lambda m: m._is_out() and m.sale_line_id):
sale_line_id = move.sale_line_id
product_cost = move._get_price_unit()
if (
sale_line_id.product_uom_id
and sale_line_id.product_uom_id != move.product_id.uom_id
):
product_cost = move.product_id.uom_id._compute_price(
product_cost,
sale_line_id.product_uom_id,
)
sale_line_id.purchase_price = product_cost
3 changes: 3 additions & 0 deletions sale_margin_sync/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
6 changes: 6 additions & 0 deletions sale_margin_sync/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [Tecnativa](https://www.tecnativa.com):

> - Carlos Dauden
> - Sergio Teruel
> - Carlos Roca
> - Carlos Lopez
1 change: 1 addition & 0 deletions sale_margin_sync/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Recompute sale margin when related stock move cost price is changed.
Binary file added sale_margin_sync/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading