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] [FIX] sale_order_line_date: remove TypeError #3540

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

LuciaMarchalFactorLibre
Copy link

@LuciaMarchalFactorLibre LuciaMarchalFactorLibre commented Jan 20, 2025

FL-556-5216

There is no checking that commitment_date has a correct value, only that it is set.
File "sale-workflow/sale_order_line_date/models/sale_order_line.py", line 40, in write

    def write(self, vals):
        res = super().write(vals)
        moves_to_upd = set()
        if "commitment_date" in vals:
            for move in self.move_ids:
                if move.state not in ["cancel", "done"]:
                    moves_to_upd.add(move.id)
        if moves_to_upd:
            self.env["stock.move"].browse(moves_to_upd).write(
                {"date_deadline": vals.get("commitment_date")} # <-----------------------
            )
        return res

Translating an empty value is not done correctly in the stock module
File "/odoo-base/odoo-server/addons/stock/models/stock_move.py", line 698, in write

if 'date_deadline' in vals:
    self._set_date_deadline(vals.get('date_deadline')) # <---------------------

File "/odoo-base/odoo-server/addons/stock/models/stock_move.py", line 539, in _set_date_deadline

if move.date_deadline:
    delta = move.date_deadline - fields.Datetime.to_datetime(new_deadline) # <------------------------

@LuciaMarchalFactorLibre LuciaMarchalFactorLibre force-pushed the 16.0-fix-sale_order_line_date branch from 10dbc32 to 1ff8a13 Compare January 20, 2025 08:58
Copy link
Member

@mmequignon mmequignon left a comment

Choose a reason for hiding this comment

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

Why not doing everything in the if block, and checking that "commitment_date" is correctly set only once?

if vals.get("commitment_date"):
    moves_to_upd = set()
    for move in self.move_ids:
         [...]
    if moves_to_upd:
         [...]

@LuciaMarchalFactorLibre LuciaMarchalFactorLibre force-pushed the 16.0-fix-sale_order_line_date branch from 1ff8a13 to cb9542f Compare January 21, 2025 15:13
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants