Skip to content
Closed
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
8 changes: 5 additions & 3 deletions sale_quotation_number/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# © 2020 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, models
from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

confirmed_before = fields.Boolean(copy=False)
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.

@aaladro-kernet Thanks for this. I would say this is a little bit too generic. Maybe quotation_number_set or something like that.

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.

Moreover, a little test and a migration script (that set that field for 'SQ' quotations) are welcome

Copy link
Copy Markdown
Author

@aaladro-kernet aaladro-kernet Jul 3, 2024

Choose a reason for hiding this comment

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

This field is simply to control the order, once confirmed, go back to draft and reconfirm. Do not assign a new sequence number. Are we agreed?

This allows us to modify the prefix of the quotation sequence as we wish.


@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
Expand Down Expand Up @@ -44,7 +46,7 @@ def copy(self, default=None):

def action_confirm(self):
for order in self:
if self.name[:2] != "SQ":
if order.confirmed_before:
continue
if order.state not in ("draft", "sent") or order.company_id.keep_name_so:
continue
Expand All @@ -57,5 +59,5 @@ def action_confirm(self):
.env["ir.sequence"]
.next_by_code("sale.order")
)
order.write({"origin": quo, "name": sequence})
order.write({"origin": quo, "name": sequence, "confirmed_before": True})
return super().action_confirm()