forked from OCA/wms
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
139 additions
and
56 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/shopfloor_vendor_packaging/odoo/addons/shopfloor_vendor_packaging
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 @@ | ||
../../../../shopfloor_vendor_packaging |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import actions |
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,19 @@ | ||
# Copyright 2024 Camptocamp SA (http://www.camptocamp.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Shopfloor Vendor Packaging", | ||
"summary": "Manage shopfloor behavior for vendor packaging", | ||
"version": "14.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Inventory", | ||
"website": "https://github.com/OCA/wms", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"data": [ | ||
"views/shopfloor_menu.xml", | ||
], | ||
"depends": ["shopfloor", "product_packaging_type_vendor"], | ||
"auto-install": True, | ||
} |
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,56 @@ | ||
# Copyright 2024 Camptocamp SA (http://www.camptocamp.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.shopfloor_base.utils import ensure_model | ||
|
||
|
||
class DataAction(Component): | ||
_inherit = "shopfloor.data.action" | ||
|
||
@ensure_model("stock.move.line") | ||
def move_line(self, record, with_picking=False, **kw): | ||
display_vendor_packagings = kw.get("display_vendor_packagings") | ||
record = record.with_context( | ||
display_vendor_packagings=display_vendor_packagings, | ||
) | ||
return super().move_line(record, with_picking, **kw) | ||
|
||
@ensure_model("stock.move") | ||
def move(self, record, **kw): | ||
display_vendor_packagings = kw.get("display_vendor_packagings") | ||
record = record.with_context( | ||
display_vendor_packagings=display_vendor_packagings, | ||
) | ||
return super().move(record, **kw) | ||
|
||
@ensure_model("stock.package_level") | ||
def package_level(self, record, **kw): | ||
display_vendor_packagings = kw.get("display_vendor_packagings") | ||
record = record.with_context( | ||
display_vendor_packagings=display_vendor_packagings | ||
) | ||
return super().package_level(record, **kw) | ||
|
||
@ensure_model("product.product") | ||
def product(self, record, **kw): | ||
display_vendor_packagings = kw.get("display_vendor_packagings") | ||
record = record.with_context( | ||
display_vendor_packagings=display_vendor_packagings | ||
) | ||
return super().product(record, **kw) | ||
|
||
def _product_packaging(self, rec, field): | ||
display_vendor_packagings = rec.env.context.get("display_vendor_packagings") | ||
packagings = rec.packaging_ids | ||
if display_vendor_packagings: | ||
packagings = packagings.filtered(lambda x: x.qty) | ||
else: | ||
packagings = packagings.filtered( | ||
lambda x: x.qty and not x.packaging_type_id.is_vendor_packaging | ||
) | ||
return self._jsonify( | ||
packagings, | ||
self._packaging_parser, | ||
multi=True, | ||
) |
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,29 @@ | ||
# Copyright 2024 Camptocamp SA (http://www.camptocamp.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
DISPLAY_VENDOR_PACKAGINGS_HELP = """ | ||
When enabled, the user will be able to see the vendor packagings | ||
in the frontend, e.g. in the qty picker. | ||
""" | ||
|
||
|
||
class ShopfloorMenu(models.Model): | ||
_inherit = "shopfloor.menu" | ||
|
||
display_vendor_packagings = fields.Boolean( | ||
string="Display vendor packagings", | ||
default=False, | ||
help=DISPLAY_VENDOR_PACKAGINGS_HELP, | ||
) | ||
display_vendor_packagings_is_possible = fields.Boolean( | ||
compute="_compute_display_vendor_packagings_is_possible", | ||
) | ||
|
||
@api.depends("scenario_id") | ||
def _compute_display_vendor_packagings_is_possible(self): | ||
for menu in self: | ||
menu.display_vendor_packagings_is_possible = menu.scenario_id.has_option( | ||
"display_vendor_packagings" | ||
) |
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 @@ | ||
* Juan Miguel Sánchez Arce <[email protected]> |
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,2 @@ | ||
When installed, this module adds a new option in shopfloor | ||
to prevent vendor packagings from being displayed in the frontend. |
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,18 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="shopfloor_menu_form_view" model="ir.ui.view"> | ||
<field name="model">shopfloor.menu</field> | ||
<field name="inherit_id" ref="shopfloor.shopfloor_menu_form_view" /> | ||
<field name="arch" type="xml"> | ||
<group name="options" position="inside"> | ||
<group | ||
name="display_vendor_packagings" | ||
attrs="{'invisible': [('display_vendor_packagings_is_possible', '=', False)]}" | ||
> | ||
<field name="display_vendor_packagings_is_possible" invisible="1" /> | ||
<field name="display_vendor_packagings" /> | ||
</group> | ||
</group> | ||
</field> | ||
</record> | ||
</odoo> |