Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import pricelist_cache_wizard

View File

@@ -0,0 +1,59 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import api, fields, models
class PricelistCacheWizard(models.TransientModel):
_name = "product.pricelist.cache.wizard"
_description = "Wizard for pricelist cache"
partner_id = fields.Many2one("res.partner")
pricelist_id = fields.Many2one("product.pricelist")
product_id = fields.Many2one("product.product")
display_cache_line_ids = fields.Many2many(
"product.pricelist.cache", string="Cached prices"
)
@api.onchange("partner_id")
def _onchange_partner_id(self):
if self.partner_id:
self.pricelist_id = self.partner_id.property_product_pricelist
else:
self.pricelist_id = False
@api.onchange("pricelist_id", "product_id")
def _onchange_product_pricelist(self):
pricelist = self.pricelist_id
product = self.product_id
partner = self.partner_id
if not pricelist:
self.display_cache_line_ids = False
return
if product:
products = product
else:
products = self.env["product.product"].search([])
if partner and not partner.property_product_pricelist == pricelist:
partner = False
cache_model = self.env["product.pricelist.cache"]
cache_selfs = cache_model.get_cached_prices_for_pricelist(
self.pricelist_id, products
)
# TODO fields are flushed when get_cached_prices_for_pricelist
# is called. I wonder is this is because of the use of flush()
# in the code.
# There's maybe a better way to keep those fields values.
data = {
"display_cache_line_ids": [(6, 0, cache_selfs.ids)],
"pricelist_id": pricelist.id,
"product_id": product.id if product else False,
"partner_id": partner.id if partner else False,
}
self.update(data)
def open_in_tree_view(self):
prices = self.display_cache_line_ids
cache_model = self.env["product.pricelist.cache"]
domain = [("id", "in", prices.ids)]
return cache_model._get_tree_view(domain)

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2021 Camptocamp SA
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="product_pricelist_cache_wizard_view_form" model="ir.ui.view">
<field name="name">product.pricelist.cache.wizard.form</field>
<field name="model">product.pricelist.cache.wizard</field>
<field name="arch" type="xml">
<form string="Pricelist Cache">
<sheet>
<group>
<field name="partner_id" />
<field name="pricelist_id" />
<field name="product_id" />
<field name="display_cache_line_ids" mode="list">
<list limit="80">
<field name="product_id" />
<field name="price" />
</list>
</field>
</group>
</sheet>
<footer>
<button
name="open_in_tree_view"
type="object"
string="Open"
class="btn-primary"
invisible="not display_cache_line_ids"
/>
<button special="cancel" string="Cancel" class="btn-default" />
</footer>
</form>
</field>
</record>
<record id="product_pricelist_cache_wizard_action" model="ir.actions.act_window">
<field name="name">Pricelist Cache</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.pricelist.cache.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="product_pricelist_cache_wizard_view_form" />
<field
name="context"
>{"withControlPanel": False, "no_breadcrumbs": True}</field>
</record>
<menuitem
action="product_pricelist_cache_wizard_action"
id="menuitem_pricelist_cache_wizard"
parent="sale.prod_config_main"
sequence="20"
/>
</odoo>