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

[15.0][REF] product_cost_price_avco_sync: Refactoring for handling all the changes at once #1697

Open
wants to merge 2 commits into
base: 15.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
1 change: 1 addition & 0 deletions product_cost_price_avco_sync/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import product_product
from . import stock_move_line
from . import stock_picking
from . import stock_valuation_layer
15 changes: 15 additions & 0 deletions product_cost_price_avco_sync/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import models
from odoo.tools import config


class ProductProduct(models.Model):
_inherit = "product.product"

def _run_fifo_vacuum(self, company=None):
"""Overwrite method to do nothing when remaining quantity is negative."""
if self.env.context.get("force_run_fifo_vacuum") or config["test_enable"]:
return super()._run_fifo_vacuum(company=company)
return

Check warning on line 15 in product_cost_price_avco_sync/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_cost_price_avco_sync/models/product_product.py#L15

Added line #L15 was not covered by tests
6 changes: 4 additions & 2 deletions product_cost_price_avco_sync/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class StockMoveLine(models.Model):

@api.model
def _create_correction_svl(self, move, diff):
if move.product_id.cost_method != "average" or self.env.context.get(
"new_stock_move_create", False
if (
move.product_id.cost_method != "average"
or self.env.context.get("new_stock_move_create")
or not diff
):
return super()._create_correction_svl(move, diff)
for svl in move.stock_valuation_layer_ids.filtered(
Expand Down
Loading
Loading