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] pos_order_to_sale_order #1065

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions pos_order_to_sale_order/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ class ResConfigSettings(models.TransientModel):
pos_iface_create_invoiced_sale_order = fields.Boolean(
related="pos_config_id.iface_create_invoiced_sale_order", readonly=False
)

sol_name_mode = fields.Selection(
selection=[
("product_pos", "Product name + POS Comment"),
("multiline", "Sale Multiline Description"),
],
string="SO Line Name Mode",
default="product_pos",
Copy link
Member

Choose a reason for hiding this comment

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

What happens if user will remove selection value? So no option is selected

config_parameter="pos_order_to_sale_order.sol_name_mode",
)
20 changes: 13 additions & 7 deletions pos_order_to_sale_order/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ class SaleOrderLine(models.Model):

@api.model
def _prepare_from_pos(self, order_line_data):
ProductProduct = self.env["product.product"]
product = ProductProduct.browse(order_line_data["product_id"])
product_name = product.name
if order_line_data.get("customer_note"):
product_name += "\n" + order_line_data["customer_note"]
return {
vals = {
"product_id": order_line_data["product_id"],
"name": product_name,
"product_uom_qty": order_line_data["qty"],
"discount": order_line_data["discount"],
"price_unit": order_line_data["price_unit"],
"tax_id": order_line_data["tax_ids"],
}
if (
order_line_data.get("customer_note")
and self.env["ir.config_parameter"]
.sudo()
.get_param("pos_order_to_sale_order.sol_name_mode", "product_pos")
== "product_pos"
):
product = self.env["product.product"].browse(order_line_data["product_id"])
product_name = product.name
product_name += "\n" + order_line_data["customer_note"]
vals.update(name=product_name)
return vals
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm wrong, but it looks like if the previous condition is wrong, the vals returned doesn't contain any "name" value. Did I missed something ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I'm wrong, but it looks like if the previous condition is wrong, the vals returned doesn't contain any "name" value. Did I missed something ?

Thank you for you question!
Name field is auto complete after creating SOL. And this solution for the set custom value for SOL description.

1 change: 1 addition & 0 deletions pos_order_to_sale_order/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +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
Copy link
Member

Choose a reason for hiding this comment

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

Select Sales Order Lina name composition mode


.. figure:: ../static/description/res_config_settings_form.png
:width: 800 px
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sale order line description computed by default with adding Customer note.
Copy link
Member

Choose a reason for hiding this comment

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

This is not a bug. A feature is being added.
Add readable and clear feature description please

34 changes: 34 additions & 0 deletions pos_order_to_sale_order/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,37 @@ def test_pos_order_to_sale_order(self):
self.assertEqual(order.state, "sale")
self.assertEqual(order.delivery_status, "full")
self.assertEqual(order.invoice_status, "invoiced")

def test_prepare_from_pos(self):
self.partner = self.env["res.partner"].create({"name": "Test Partner"})
self.product = self.env["product.product"].create(
{"name": "Test Product", "default_code": "test_01"}
)

ICPSudo = self.env["ir.config_parameter"].sudo()
ICPSudo.set_param("pos_order_to_sale_order.sol_name_mode", "product_pos")
vals = self.env["sale.order.line"]._prepare_from_pos(
{
"product_id": self.product.id,
"qty": 100,
"discount": 0,
"price_unit": 14.2,
"customer_note": "Test Note",
"tax_ids": False,
}
)
self.assertEqual(
vals.get("name"), "Test Product\nTest Note", msg="Name must be the same"
)
ICPSudo.set_param("pos_order_to_sale_order.sol_name_mode", "multiline")
vals = self.env["sale.order.line"]._prepare_from_pos(
{
"product_id": self.product.id,
"qty": 100,
"discount": 0,
"price_unit": 14.2,
"customer_note": "Test Note",
"tax_ids": False,
}
)
self.assertNotIn("name", vals.keys(), msg="Name key must be contain in dict")
13 changes: 13 additions & 0 deletions pos_order_to_sale_order/views/view_res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
<label for="pos_iface_create_invoiced_sale_order" />
</div>
</div>

<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane" />
<div class="o_setting_right_pane">
<label for="sol_name_mode" />
<div class="text-muted">
Sales Order Line Name Composition Mode
</div>
<div class="content-group mt16">
<field name="sol_name_mode" />
</div>
</div>
</div>
</div>
</xpath>
</field>
Expand Down
Loading