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][ADD] pos_partner_alternative_pricelist_load_background #1244

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
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
59 changes: 59 additions & 0 deletions pos_partner_alternative_pricelist_load_background/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
=================================================
POS Partner Alternative Pricelist Load Background
=================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-camptocamp%2Fpos-lightgray.png?logo=github
:target: https://github.com/camptocamp/pos/tree/16.0/pos_partner_alternative_pricelist_load_background
:alt: camptocamp/pos

|badge1| |badge2| |badge3|

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.


**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/camptocamp/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/camptocamp/pos/issues/new?body=module:%20pos_partner_alternative_pricelist_load_background%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
~~~~~~~

* Camptocamp

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

* Telmo Santos <telmo.santos@camptocamp.com>

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

This module is part of the `camptocamp/pos <https://github.com/camptocamp/pos/tree/16.0/pos_partner_alternative_pricelist_load_background>`_ project on GitHub.

You are welcome to contribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions pos_partner_alternative_pricelist_load_background/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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_product_pricelist_alternative",
"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,24 @@
# 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):
pricelists = super().get_pos_ui_partner_pricelist_background(

Check warning on line 10 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

Added line #L10 was not covered by tests
pricelist_id, product_ids
)
# By design we do not calculate alternative prices on base pricelits

Choose a reason for hiding this comment

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

why not a kw arg instead? It would be more explicit.

if self.env.context.get("base_pricelist"):
return pricelists
pricelist_rec = self.env["product.pricelist"].browse(pricelist_id)
alternative_pricelists = []

Check warning on line 17 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#L15-L17

Added lines #L15 - L17 were not covered by tests
for alt_pricelist_rec in pricelist_rec.alternative_pricelist_ids:
alternative_pricelists += self.get_pos_ui_partner_pricelist_background(

Check warning on line 19 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#L19

Added line #L19 was not covered by tests
alt_pricelist_rec.id, product_ids
)
if alternative_pricelists:
return pricelists + alternative_pricelists
return pricelists

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#L23-L24

Added lines #L23 - L24 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.

Loading
Loading