Skip to content
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
95 changes: 95 additions & 0 deletions sale_order_type_quotation_number/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
================================
Sale Order Type Quotation Number
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:aed9621c7132552e2656b5a9fa1b9b7a47d7f9aad353a430cc389e3a675d1f6c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_order_type_quotation_number
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_type_quotation_number
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to set a quotation sequence depending on the sale order type. It also makes compatible the modules sale_order_type and sale_quotation_number, so both a sale order sequence and a quotation sequence can be set in a sale order type.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module you need to

* Go to Sales > Configuration > Sale Order Types and select an order type
* Select a sequence in "Quotation Sequence" field. If the field is left blank, the default quoation sequence will be used.

Usage
=====

When the quotation sequence applied to a quotation has changed, click on the "Recompute Quotation Seq." in order to generate the new quotation number.

Known issues / Roadmap
======================

* This module does not apply quotation sequences to orders created from website.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_type_quotation_number%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Sygel

Contributors
~~~~~~~~~~~~

* `Sygel <https://sygel.es>`_:
* Manuel Regidor <manuel.regidor@sygel.es>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_order_type_quotation_number>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_order_type_quotation_number/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions sale_order_type_quotation_number/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale Order Type Quotation Number",
"summary": "Use quotation sequence depending on sale type",
"version": "16.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Sygel, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"sale_order_type",
"sale_quotation_number",
],
"data": ["views/sale_order_type_view.xml", "views/sale_views.xml"],
}
58 changes: 58 additions & 0 deletions sale_order_type_quotation_number/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_type_quotation_number
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-25 13:46+0000\n"
"PO-Revision-Date: 2023-10-25 15:49+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 2.3\n"

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order__applied_quotation_seq_id
msgid "Applied Quotation Seq"
msgstr "Secuencia de presupuesto aplicada"

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order_type__quotation_sequence_id
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_sale_order_type_search_view
msgid "Quotation Sequence"
msgstr "Secuencia de presupuesto"

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order__recompute_quotation_seq
msgid "Recompute Quotation Seq"
msgstr "Recomputar secuencia presupuesto"

#. module: sale_order_type_quotation_number
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_view_order_form
msgid "Recompute Quotation Seq."
msgstr "Recomputar secuencia presupuesto"

#. module: sale_order_type_quotation_number
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_view_order_form
msgid ""
"Recomputing the quotation sequence will generate a gap in the previous "
"sequence. Would you like to proceed?"
msgstr ""
"Recomputar la secuencia de presupuesto generará saltos en la secuencia "
"anterior. ¿Desea continuar?"

#. module: sale_order_type_quotation_number
#: model:ir.model,name:sale_order_type_quotation_number.model_sale_order
msgid "Sales Order"
msgstr "Pedido de venta"

#. module: sale_order_type_quotation_number
#: model:ir.model,name:sale_order_type_quotation_number.model_sale_order_type
msgid "Type of sale order"
msgstr "Tipo de pedido de venta"
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_type_quotation_number
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order__applied_quotation_seq_id
msgid "Applied Quotation Seq"
msgstr ""

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order_type__quotation_sequence_id
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_sale_order_type_search_view
msgid "Quotation Sequence"
msgstr ""

#. module: sale_order_type_quotation_number
#: model:ir.model.fields,field_description:sale_order_type_quotation_number.field_sale_order__recompute_quotation_seq
msgid "Recompute Quotation Seq"
msgstr ""

#. module: sale_order_type_quotation_number
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_view_order_form
msgid "Recompute Quotation Seq."
msgstr ""

#. module: sale_order_type_quotation_number
#: model_terms:ir.ui.view,arch_db:sale_order_type_quotation_number.quotation_sot_view_order_form
msgid ""
"Recomputing the quotation sequence will generate a gap in the previous "
"sequence. Would you like to proceed?"
msgstr ""

#. module: sale_order_type_quotation_number
#: model:ir.model,name:sale_order_type_quotation_number.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_order_type_quotation_number
#: model:ir.model,name:sale_order_type_quotation_number.model_sale_order_type
msgid "Type of sale order"
msgstr ""
2 changes: 2 additions & 0 deletions sale_order_type_quotation_number/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sale_order
from . import sale_order_type
80 changes: 80 additions & 0 deletions sale_order_type_quotation_number/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


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

applied_quotation_seq_id = fields.Many2one(
comodel_name="ir.sequence", readonly=True
)
recompute_quotation_seq = fields.Boolean(
compute="_compute_recompute_quotation_seq",
store=True,
)

@api.model_create_multi
def create(self, vals_list):
orders = self.browse()
for vals in vals_list:
orders |= super(
SaleOrder, self.with_context(type_id=vals.get("type_id"))
).create([vals])
for order in orders.filtered(lambda a: a.quotation_seq_used):
order.applied_quotation_seq_id = order.get_quotation_seq_id()
return orders

@api.depends("type_id", "type_id.quotation_sequence_id", "state")
def _compute_recompute_quotation_seq(self):
for sel in self:
res = False
if (
sel.state in ["draft", "sent"]
and sel.type_id.quotation_sequence_id
and sel.type_id.quotation_sequence_id != sel.applied_quotation_seq_id
):
res = True
sel.recompute_quotation_seq = res

def action_recompute_quotation_seq(self):
for sel in self.filtered(
lambda a: a.state in ["draft", "sent"] and a.recompute_quotation_seq
):
sel.write(
{
"name": sel.type_id.quotation_sequence_id.next_by_id(),
"applied_quotation_seq_id": sel.type_id.quotation_sequence_id.id,
}
)

def get_quotation_seq_id(self):
self.ensure_one()
seq_id = False
if not self.company_id.keep_name_so:
seq_id = self.type_id.quotation_sequence_id or self.env[
"ir.sequence"
].search([("code", "=", "sale.quotation")], limit=1)
return seq_id

@api.model
def get_quotation_seq(self):
seq = ""
type_id = False

Check warning on line 64 in sale_order_type_quotation_number/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_type_quotation_number/models/sale_order.py#L63-L64

Added lines #L63 - L64 were not covered by tests
if self.env.context.get("type_id"):
type_id = self.env["sale.order.type"].browse(

Check warning on line 66 in sale_order_type_quotation_number/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_type_quotation_number/models/sale_order.py#L66

Added line #L66 was not covered by tests
self.env.context.get("type_id")
)
if type_id and type_id.quotation_sequence_id:
seq = type_id.quotation_sequence_id.next_by_id()

Check warning on line 70 in sale_order_type_quotation_number/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_type_quotation_number/models/sale_order.py#L70

Added line #L70 was not covered by tests
else:
seq = super().get_quotation_seq()
return seq

Check warning on line 73 in sale_order_type_quotation_number/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_type_quotation_number/models/sale_order.py#L72-L73

Added lines #L72 - L73 were not covered by tests

def get_sale_order_seq(self):
if self.type_id and self.type_id.sequence_id:
seq = self.type_id.sequence_id.next_by_id()
else:
seq = super().get_sale_order_seq()

Check warning on line 79 in sale_order_type_quotation_number/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_order_type_quotation_number/models/sale_order.py#L79

Added line #L79 was not covered by tests
return seq
20 changes: 20 additions & 0 deletions sale_order_type_quotation_number/models/sale_order_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


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

@api.model
def _get_quotation_domain_sequence_id(self):
seq_type = self.env.ref("sale_quotation_number.seq_sale_quotation")
return [("code", "=", seq_type.code)]

quotation_sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Quotation Sequence",
copy=False,
domain=_get_quotation_domain_sequence_id,
)
4 changes: 4 additions & 0 deletions sale_order_type_quotation_number/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To configure this module you need to

* Go to Sales > Configuration > Sale Order Types and select an order type
* Select a sequence in "Quotation Sequence" field. If the field is left blank, the default quoation sequence will be used.
2 changes: 2 additions & 0 deletions sale_order_type_quotation_number/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* `Sygel <https://sygel.es>`_:
* Manuel Regidor <manuel.regidor@sygel.es>
1 change: 1 addition & 0 deletions sale_order_type_quotation_number/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to set a quotation sequence depending on the sale order type. It also makes compatible the modules sale_order_type and sale_quotation_number, so both a sale order sequence and a quotation sequence can be set in a sale order type.
1 change: 1 addition & 0 deletions sale_order_type_quotation_number/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* This module does not apply quotation sequences to orders created from website.
1 change: 1 addition & 0 deletions sale_order_type_quotation_number/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When the quotation sequence applied to a quotation has changed, click on the "Recompute Quotation Seq." in order to generate the new quotation number.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading