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

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). 🤖

Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

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

Same as #3364, except that one includes a test, and it handles empty values better it seems.

@StefanRijnhart
Copy link
Member

Next time you add a fix, please check any open PR for the same module.

@ljsalvatierra-factorlibre
Copy link
Contributor

Same as #3364, except that one includes a test, and it handles empty values better it seems.

Yes, but a different solution.

@StefanRijnhart
Copy link
Member

Same as #3364, except that one includes a test, and it handles empty values better it seems.

Yes, but a different solution.

I'm sorry if you feel me closing this PR was too swift or unjust. Do you want to argue in favor of your solution?

@ljsalvatierra-factorlibre
Copy link
Contributor

Same as #3364, except that one includes a test, and it handles empty values better it seems.

Yes, but a different solution.

I'm sorry if you feel me closing this PR was too swift or unjust. Do you want to argue in favor of your solution?

Oh don't worry. What do you think @LuciaMarchalFactorLibre ? Please review #3364

@StefanRijnhart
Copy link
Member

OK, thanks! BTW #3364 is merged now, but if you want you can review my port to 18 in #3565.

@LuciaMarchalFactorLibre
Copy link
Author

I think it is good to leave this PR closed because #3364 is more complete and is already merged

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

Successfully merging this pull request may close these issues.

6 participants