Skip to content

Commit

Permalink
[FIX] pos_order_to_sale_order: newsfragments is updated and setting d…
Browse files Browse the repository at this point in the history
…efault value for config paramenter is changed.
  • Loading branch information
geomer198 committed Oct 22, 2023
1 parent 0188833 commit fc3ab80
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
10 changes: 9 additions & 1 deletion pos_order_to_sale_order/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

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


class ResConfigSettings(models.TransientModel):
Expand Down Expand Up @@ -33,3 +33,11 @@ class ResConfigSettings(models.TransientModel):
default="product_pos",
config_parameter="pos_order_to_sale_order.sol_name_mode",
)

@api.model
def set_values(self):
result = super(ResConfigSettings, self).set_values()
ICPSudo = self.env["ir.config_parameter"].sudo()
value = self.sol_name_mode or "product_pos"
ICPSudo.set_param("pos_order_to_sale_order.sol_name_mode", value)
return result
2 changes: 1 addition & 1 deletion pos_order_to_sale_order/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* Go to Point Of Sale / Configuration / Point of Sale
* Check the box 'Create Sale Orders'
* Select the desired default behaviour
* Select the SO Line Name mode
* Select Sales Order Line name composition mode

.. figure:: ../static/description/res_config_settings_form.png
:width: 800 px

This file was deleted.

5 changes: 5 additions & 0 deletions pos_order_to_sale_order/readme/newsfragments/2928.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In Settings "Sales Order Line name composition mode" is added.
This mode regulates preparing sale order line description at creating Sale Order from Point of Sale.
Modes:
- Product name + POS Comment
- Sale Multiline Description
24 changes: 23 additions & 1 deletion pos_order_to_sale_order/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html


from odoo.tests import tagged
from odoo.tests import Form, tagged

from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon

Expand Down Expand Up @@ -75,3 +75,25 @@ def test_prepare_from_pos(self):
}
)
self.assertNotIn("name", vals.keys(), msg="Name key must be contain in dict")

def test_config_settings_sol_name_mode(self):
Settings = self.env["res.config.settings"].with_user(self.env.user).create({})
with Form(Settings) as form:
form.sol_name_mode = "product_pos"
Settings.set_values()
Config = self.env["ir.config_parameter"].sudo()
self.assertEqual(
Config.get_param("pos_order_to_sale_order.sol_name_mode"), "product_pos"
)
with Form(Settings) as form:
form.sol_name_mode = "multiline"
Settings.set_values()
self.assertEqual(
Config.get_param("pos_order_to_sale_order.sol_name_mode"), "multiline"
)
with Form(Settings) as form:
form.sol_name_mode = False
Settings.set_values()
self.assertEqual(
Config.get_param("pos_order_to_sale_order.sol_name_mode"), "product_pos"
)

0 comments on commit fc3ab80

Please sign in to comment.