Skip to content

Commit 3397d48

Browse files
committed
[ADD] pos_partner__pricelist_load_background
1 parent f808797 commit 3397d48

File tree

14 files changed

+729
-0
lines changed

14 files changed

+729
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
=====================================
2+
POS Partner Pricelist Load Background
3+
=====================================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-camptocamp%2Fpos-lightgray.png?logo=github
17+
:target: https://github.com/camptocamp/pos/tree/16.0/pos_partner_pricelist_load_background
18+
:alt: camptocamp/pos
19+
20+
|badge1| |badge2| |badge3|
21+
22+
This module allow you to load a pricelist for a customer in the background.
23+
24+
**Context**
25+
In the POS, we can configure a list of available pricelists. These price lists are loaded during start-up and only these can be chosen for any order.
26+
When a customer is selected, the POS will try to find the customer's pricelist (property_pricelist_id) among the available pricelists.
27+
If it's found, the pricelist is selected otherwise a default one will be selected instead.
28+
29+
**With this module**
30+
When a customer is selected, his pricelist (property_pricelist_id) is loaded and available to be chosen.
31+
32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
37+
Bug Tracker
38+
===========
39+
40+
Bugs are tracked on `GitHub Issues <https://github.com/camptocamp/pos/issues>`_.
41+
In case of trouble, please check there if your issue has already been reported.
42+
If you spotted it first, help us smashing it by providing a detailed and welcomed
43+
`feedback <https://github.com/camptocamp/pos/issues/new?body=module:%20pos_partner_pricelist_load_background%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
44+
45+
Do not contact contributors directly about support or help with technical issues.
46+
47+
Credits
48+
=======
49+
50+
Authors
51+
~~~~~~~
52+
53+
* Camptocamp
54+
55+
Contributors
56+
~~~~~~~~~~~~
57+
58+
* Telmo Santos <telmo.santos@camptocamp.com>
59+
* Iván Todorovich <ivan.todorovich@camptocamp.com>
60+
61+
Maintainers
62+
~~~~~~~~~~~
63+
64+
This module is part of the `camptocamp/pos <https://github.com/camptocamp/pos/tree/16.0/pos_partner_pricelist_load_background>`_ project on GitHub.
65+
66+
You are welcome to contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2024 Camptocamp (https://www.camptocamp.com).
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "POS Partner Pricelist Load Background",
6+
"summary": "Pos ",
7+
"version": "16.0.1.0.0",
8+
"author": "Camptocamp, Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/pos",
10+
"license": "AGPL-3",
11+
"category": "Point of Sale",
12+
"depends": ["point_of_sale"],
13+
"installable": True,
14+
"assets": {
15+
"point_of_sale.assets": [
16+
"pos_partner_pricelist_load_background/static/src/js/**/*.js",
17+
],
18+
},
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import pos_session
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2024 Camptocamp
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from odoo import models
4+
5+
6+
class POSSession(models.Model):
7+
_inherit = "pos.session"
8+
9+
def get_pos_ui_partner_pricelist_background(self, pricelist_id, product_ids):
10+
params = self._loader_params_product_pricelist()
11+
fnames = params["search_params"]["fields"]
12+
pricelist_rec = self.env["product.pricelist"].browse(pricelist_id)
13+
pricelist = pricelist_rec.read(fnames)[0]
14+
pricelist["items"] = []
15+
16+
products = (
17+
self.env["product.product"].browse(product_ids)
18+
| pricelist_rec.item_ids.product_id
19+
)
20+
templates = products.product_tmpl_id | pricelist_rec.item_ids.product_tmpl_id
21+
pricelist_item_domain = [
22+
("pricelist_id", "=", pricelist_id),
23+
"|",
24+
("product_tmpl_id", "=", False),
25+
("product_tmpl_id", "in", templates.ids),
26+
"|",
27+
("product_id", "=", False),
28+
("product_id", "in", products.ids),
29+
]
30+
for item in self.env["product.pricelist.item"].search_read(
31+
pricelist_item_domain, self._product_pricelist_item_fields()
32+
):
33+
pricelist["items"].append(item)
34+
return [pricelist]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Telmo Santos <telmo.santos@camptocamp.com>
2+
* Iván Todorovich <ivan.todorovich@camptocamp.com>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This module allow you to load a pricelist for a customer in the background.
2+
3+
**Context**
4+
In the POS, we can configure a list of available pricelists. These price lists are loaded during start-up and only these can be chosen for any order.
5+
When a customer is selected, the POS will try to find the customer's pricelist (property_pricelist_id) among the available pricelists.
6+
If it's found, the pricelist is selected otherwise a default one will be selected instead.
7+
8+
**With this module**
9+
When a customer is selected, his pricelist (property_pricelist_id) is loaded and available to be chosen.

0 commit comments

Comments
 (0)