Skip to content

[18.0][MIG] sale_order_line_input: Migration to 18.0#3458

Closed
Naraka wants to merge 25 commits intoOCA:18.0from
Naraka:18.0-mig-sale_order_line_input
Closed

[18.0][MIG] sale_order_line_input: Migration to 18.0#3458
Naraka wants to merge 25 commits intoOCA:18.0from
Naraka:18.0-mig-sale_order_line_input

Conversation

@Naraka
Copy link
Copy Markdown
Contributor

@Naraka Naraka commented Dec 4, 2024

Migration to 18.0

carlosdauden and others added 23 commits December 4, 2024 11:22
[UPD] README.rst

[UPD] Update sale_order_line_input.pot
[UPD] Update sale_order_line_input.pot

[UPD] README.rst

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_order_line_input/
Currently translated at 100.0% (17 of 17 strings)

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_order_line_input/zh_CN/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-12.0/sale-workflow-12.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_order_line_input/
[UPD] Update sale_order_line_input.pot

[UPD] README.rst
to solve a pypi upload issue
Since v13 the customer field on res.partner model has been disappeared,
so when we try to add a value on the field order_partner_id we get an
error.

sale_order_line_input 13.0.1.1.0
[MIG] sale_order_line_input: Migration to 14.0
[UPD] Update sale_order_line_input.pot

[UPD] README.rst

[IMP] update dotfiles [ci skip]

[UPD] README.rst

[UPD] README.rst
Currently translated at 100.0% (22 of 22 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_line_input/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: sale-workflow-17.0/sale-workflow-17.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_order_line_input/
Currently translated at 100.0% (18 of 18 strings)

Translation: sale-workflow-17.0/sale-workflow-17.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_order_line_input/it/
Currently translated at 100.0% (18 of 18 strings)

Translation: sale-workflow-17.0/sale-workflow-17.0-sale_order_line_input
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-17-0/sale-workflow-17-0-sale_order_line_input/it/
@pedrobaeza
Copy link
Copy Markdown
Member

/ocabot migration sale_order_line_input

for onchange_method in new_so._onchange_methods["partner_id"]:
onchange_method(new_so)
order_vals = new_so._convert_to_write(new_so._cache)
self.order_id = SaleOrder.create(order_vals)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still reluctant to creates in onchanges...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, you mean that create shouldn't be used in onchange. Perhaps using @api.depends could solve this problem?

    order_id = fields.Many2one("sale.order", string="Sale Order", compute="_compute_order_id", store=True)

    @api.depends("order_partner_id")
    def _compute_order_id(self):
        """Create order automatically when order_partner_id changes"""
        for line in self:
            if line.order_partner_id and not line.order_id:
                SaleOrder = self.env["sale.order"]
                new_so = SaleOrder.new({"partner_id": line.order_partner_id.id})
                # Apply the onchange methods (e.g., computing taxes)
                for onchange_method in new_so._onchange_methods["partner_id"]:
                    onchange_method(new_so)
                order_vals = new_so._convert_to_write(new_so._cache)
                line.order_id = SaleOrder.create(order_vals)

I also have a question that is not clear to me regarding the process, shouldn't these types of changes be handled in a section other than migration? Thanks!

@Naraka Naraka force-pushed the 18.0-mig-sale_order_line_input branch from 5725a9b to a611d1f Compare December 5, 2024 12:02
@Naraka Naraka force-pushed the 18.0-mig-sale_order_line_input branch 3 times, most recently from aae2633 to 3f1a309 Compare December 9, 2024 15:17
@Naraka Naraka force-pushed the 18.0-mig-sale_order_line_input branch from 3f1a309 to 0ac5b5c Compare December 9, 2024 15:53
Copy link
Copy Markdown
Contributor

@carlosdauden carlosdauden left a comment

Choose a reason for hiding this comment

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

Maybe we can remove the button as clicking on the order_id gives the same result.

Comment on lines +37 to +45
options='{"no_open": True, "no_create": True}'
/>
<button
title="Open order"
name="action_sale_order_form"
type="object"
icon="fa-external-link"
class="oe_stat_button"
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
options='{"no_open": True, "no_create": True}'
/>
<button
title="Open order"
name="action_sale_order_form"
type="object"
icon="fa-external-link"
class="oe_stat_button"
/>
options='{"no_create": True}'
/>

Comment on lines +54 to +57

def action_sale_order_form(self):
self.ensure_one()
return self.order_id.get_formview_action()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
def action_sale_order_form(self):
self.ensure_one()
return self.order_id.get_formview_action()

@victoralmau
Copy link
Copy Markdown
Member

Superseded by #3795

@pedrobaeza pedrobaeza closed this Jul 7, 2025
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.