-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Configure default stock_level_config on se.backend
- Loading branch information
Showing
8 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import product_product | ||
from . import se_backend | ||
from . import se_index | ||
from . import stock_move |
36 changes: 36 additions & 0 deletions
36
shopinvader_search_engine_product_stock/models/se_backend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2018 Akretion (http://www.akretion.com) | ||
# Copyright 2018 ACSONE SA/NV | ||
# Sébastien BEAU <[email protected]> | ||
# Copyright 2020 Camptocamp SA (http://www.camptocamp.com) | ||
# Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class SeBackend(models.Model): | ||
_inherit = "se.backend" | ||
|
||
# NOTE: this field right now has no effect on qty sync. | ||
# It's here to allow extending modules to define their own policies. | ||
# See example in `shopinvader_product_stock_state`. | ||
stock_level_config = fields.Selection( | ||
selection="_selection_stock_level_config", | ||
default="only_qty", | ||
required=True, | ||
help="Define stock level export policy", | ||
) | ||
show_stock_level_config = fields.Boolean(compute="_compute_show_stock_level_config") | ||
|
||
def _selection_stock_level_config(self): | ||
return [("only_qty", "Only Quantity")] | ||
|
||
@api.depends("index_ids", "index_ids.model_id") | ||
def _compute_show_stock_level_config(self): | ||
product_model_id = ( | ||
self.env["ir.model"].search([("model", "=", "product.product")]).id | ||
) | ||
for backend in self: | ||
backend.show_stock_level_config = ( | ||
product_model_id in backend.index_ids.mapped("model_id").ids | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
shopinvader_search_engine_product_stock/views/se_backend.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 ACSONE SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="se_backend_form_view"> | ||
<field | ||
name="name" | ||
>se.backend.form (in shopinvader_search_engine_product_stock)</field> | ||
<field name="model">se.backend</field> | ||
<field name="inherit_id" ref="connector_search_engine.se_backend_form_view" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='se']/group[@name='se-main']" postion="inside"> | ||
<field name="show_stock_level_config" invisible="1" /> | ||
<field | ||
name="stock_level_config" | ||
attrs="{'invisible': [('show_stock_level_config', '=', False)]}" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters