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_quotation_number: fix numbering to be compatible with sale_order_revision #3524

Open
wants to merge 1 commit into
base: 16.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
2 changes: 1 addition & 1 deletion sale_quotation_number/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Sale Quotation Numeration",
"summary": "Different sequence for sale quotations",
"version": "16.0.1.1.0",
"version": "16.0.1.1.1",
"category": "Sales Management",
"website": "https://github.com/OCA/sale-workflow",
"author": "Elico Corp, "
Expand Down
19 changes: 10 additions & 9 deletions sale_quotation_number/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ class SaleOrder(models.Model):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if self.is_using_quotation_number(vals):
company_id = vals.get("company_id", self.env.company.id)
sequence = (
self.with_company(company_id)
.env["ir.sequence"]
.next_by_code("sale.quotation")
)
vals["name"] = sequence or "/"
if not vals.get("name"):
if self.is_using_quotation_number(vals):
company_id = vals.get("company_id", self.env.company.id)
sequence = (
self.with_company(company_id)
.env["ir.sequence"]
.next_by_code("sale.quotation")
)
vals["name"] = sequence or "/"
return super().create(vals_list)

@api.model
def is_using_quotation_number(self, vals):
company = False
if "company_id" in vals:
if vals.get("company_id"):
company = self.env["res.company"].browse(vals.get("company_id"))
else:
company = self.env.company
Expand Down
6 changes: 6 additions & 0 deletions sale_quotation_number/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ def test_sequence_assignment(self):
next_name = sequence_id.get_next_char(sequence_id.number_next_actual)
self.order_company1.action_confirm()
self.assertEqual(next_name, self.order_company1.name)

def test_create_with_specific_name(self):
order = self.sale_order_model.create(
{"name": "CustomName", "partner_id": self.env.ref("base.res_partner_1").id}
)
self.assertEqual(order.name, "CustomName")
Loading