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
0f72644
[11.0][ADD] sale_margin_sync: Recompute sale margin when related stoc…
carlosdauden Oct 29, 2019
f611d6a
[MIG] sale_margin_sync: Migration to 12.0
carlosdauden Oct 30, 2019
537c085
[IMP] sale_margin_sync: Create a pricelist for testing to avoid crash…
sergio-teruel Nov 21, 2019
86d8d58
[IMP] sale_margin_sync: black, isort
sergio-teruel Sep 17, 2020
dc8338b
[MIG] sale_margin_sync: Migration to v13.0
sergio-teruel Sep 17, 2020
291ccda
[IMP] sale_margin_sync: Sync sale line purchase price from stock valu…
sergio-teruel Aug 30, 2021
d43292f
[IMP] sale_margin_sync: black, isort, prettier
rafamarpe Oct 15, 2022
2c5ccb7
[MIG] sale_margin_sync: Migration to 14.0
rafamarpe Oct 15, 2022
48f1a7a
[MIG] sale_margin_sync: Migration to 15.0
CarlosRoca13 Nov 23, 2022
6227229
[MIG] sale_margin_sync: Migration to 16.0
Yadier-Tecnativa Apr 17, 2023
92399c7
Added translation using Weblate (Spanish)
Ivorra78 Aug 21, 2023
96c8fac
[IMP] sale_margin_sync: test performance improvement
josep-tecnativa Oct 20, 2023
6c9b56e
Added translation using Weblate (Italian)
mymage Jan 22, 2024
2fd38ea
[IMP] sale_margin_sync: pre-commit auto fixes
carlos-lopez-tecnativa Feb 7, 2025
df30dc2
[MIG] sale_margin_sync: Migration to version 18.0
carlos-lopez-tecnativa Feb 7, 2025
3711d61
[UPD] Update sale_margin_sync.pot
Feb 24, 2025
69852cc
[BOT] post-merge updates
OCA-git-bot Feb 24, 2025
6189252
Added translation using Weblate (Turkish)
bo-eska May 8, 2025
0e639b4
Added translation using Weblate (Japanese)
smorita7749 Mar 24, 2026
a183fd8
[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
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
34 changes: 34 additions & 0 deletions sale_margin_sync/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 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 moves that deliver goods to customers (deliveries
and dropshipments)"""
moves = self.filtered(
lambda m: (m._is_out() or m._is_dropshipped()) and m.sale_line_id
)
for move in moves:
sale_line = move.sale_line_id
product_cost = move._get_price_unit()
if (
sale_line.product_uom_id
and sale_line.product_uom_id != move.product_id.uom_id
):
product_cost = move.product_id.uom_id._compute_price(
product_cost,
sale_line.product_uom_id,
)
sale_line.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