Skip to content

Commit

Permalink
[ADD] pos_partner_alternative_pricelist_load_background
Browse files Browse the repository at this point in the history
  • Loading branch information
santostelmo committed Sep 30, 2024
1 parent f808797 commit 6f5bd8d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions pos_partner_alternative_pricelist_load_background/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Camptocamp (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "POS Partner Alternative Pricelist Load Background",
"summary": "Load partner alternative pricelist in background",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"category": "Point of Sale",
"depends": ["pos_partner_pricelist_load_background"],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pos_session
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models


class POSSession(models.Model):
_inherit = "pos.session"

def get_pos_ui_partner_pricelist_background(self, pricelist_id, product_ids):
params = self._loader_params_product_pricelist()
fnames = params["search_params"]['fields']
pricelist_rec = self.env['product.pricelist'].browse(pricelist_id)
pricelist = pricelist_rec.read(fnames)[0]
pricelist['items'] = []

Check warning on line 14 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L10-L14

Added lines #L10 - L14 were not covered by tests

products = self.env['product.product'].browse(product_ids) | pricelist_rec.item_ids.product_id
templates = products.product_tmpl_id | pricelist_rec.item_ids.product_tmpl_id
pricelist_item_domain = [

Check warning on line 18 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L16-L18

Added lines #L16 - L18 were not covered by tests
('pricelist_id', '=', pricelist_id),
'|', ('product_tmpl_id', '=', False), ('product_tmpl_id', 'in', templates.ids),
'|', ('product_id', '=', False), ('product_id', 'in', products.ids),
]
for item in self.env['product.pricelist.item'].search_read(pricelist_item_domain, self._product_pricelist_item_fields()):
pricelist['items'].append(item)

Check warning on line 24 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L24

Added line #L24 was not covered by tests

alternative_pricelists = []

Check warning on line 26 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L26

Added line #L26 was not covered by tests
for alt_pricelist_rec in pricelist_rec.alternative_pricelist_ids:
alternative_pricelists += self.get_pos_ui_partner_pricelist_background(alt_pricelist_rec.id, product_ids)

Check warning on line 28 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L28

Added line #L28 was not covered by tests
if alternative_pricelists:
return [pricelist] + alternative_pricelists
return [pricelist]

Check warning on line 31 in pos_partner_alternative_pricelist_load_background/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_partner_alternative_pricelist_load_background/models/pos_session.py#L30-L31

Added lines #L30 - L31 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Telmo Santos <telmo.santos@camptocamp.com>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When a customer is selected `pos_partner_pricelist_load_background` load pricelist defined in property_pricelist_id in background.
With this module, the price lists linked to the customer's price list are also loaded in the background.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
odoo-addon-pos_partner_pricelist_load_background@ git+https://github.com/OCA/pos.git@refs/pull/1243/head#subdirectory=setup/pos_partner_pricelist_load_background

0 comments on commit 6f5bd8d

Please sign in to comment.