Skip to content

Commit

Permalink
shopfloor: add option to exclude package types in product info
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Feb 9, 2024
1 parent c114af4 commit 9b5d826
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
1 change: 1 addition & 0 deletions shopfloor/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"data": [
"data/shopfloor_scenario_data.xml",
"security/groups.xml",
"views/res_config_settings.xml",
"views/shopfloor_menu.xml",
"views/stock_picking_type.xml",
"views/stock_location.xml",
Expand Down
12 changes: 10 additions & 2 deletions shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,17 @@ def _product_parser(self):
("seller_ids:supplier_code", self._product_supplier_code),
]

def _product_packaging(self, rec, field):
def _product_packaging(self, rec, field, apply_excluded=True):
packagings = rec.packaging_ids.filtered(lambda x: x.qty)
if apply_excluded:
excluded_packaging_types = (
self.env.user.company_id.shopfloor_excluded_product_packaging_ids
)
packagings = packagings.filtered(
lambda x: x.packaging_type_id not in excluded_packaging_types
)
return self._jsonify(
rec.packaging_ids.filtered(lambda x: x.qty),
packagings,
self._packaging_parser,
multi=True,
)
Expand Down
2 changes: 2 additions & 0 deletions shopfloor/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from . import priority_postpone_mixin
from . import res_company
from . import res_config_settings
from . import shopfloor_menu
from . import shopfloor_app
from . import stock_picking_type
Expand Down
17 changes: 17 additions & 0 deletions shopfloor/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

shopfloor_excluded_product_packaging_ids = fields.Many2many(
comodel_name="product.packaging.type",
string="Packagings Excluded from Product Information",
help=(
"Used to prevent certain package types from being returned "
"to the shopfloor app when querying for product information."
),
)
13 changes: 13 additions & 0 deletions shopfloor/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

shopfloor_excluded_product_packaging_ids = fields.Many2many(
related="company_id.shopfloor_excluded_product_packaging_ids",
readonly=False,
)
41 changes: 41 additions & 0 deletions shopfloor/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Camptocamp SA
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
-->
<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.shopfloor</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@data-key='stock']" position="inside">
<h2>Shopfloor</h2>
<div
class="row mt16 o_settings_container"
id="shopfloor_excluded_product_packaging_ids"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="shopfloor_excluded_product_packaging_ids" />
<div class="text-muted">
Used to prevent certain package types from being returned
to the shopfloor app when querying for product information.
</div>
<div class="content-group">
<div class="mt16">
<field
name="shopfloor_excluded_product_packaging_ids"
widget="many2many_tags"
options="{'no_create': True}"
/>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 9b5d826

Please sign in to comment.