-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Remove button install the Main Menu barcode [IMP] Add barcode demo files and barcode operations files [ADD] Tests [IMP] Tests [FIX] Tests [FIX] Tests [ADD] Tests [ADD] Tests [ADD] Tests [ADD] Tests [ADD] Tests [ADD] Tests [IMP] Improving success, error and info notifications [IMP] View inventory adjustment [IMP] Validate where to direct the return from the Barcode main [IMP] Validate where to direct the return from the Barcode main [IMP] View operations adjustment [IMP] Custom inventory and forms scan views [IMP] Add barcode main view, improve inventory and forms scan views [IMP] View inventory adjustment barcode and Operations Barcode [IMP] View inventory adjustment barcode and Operations Barcode [IMP] View inventory adjustment barcode and Operations Barcode [IMP] Show or hide the edit form based on manual option value, scan screen. [IMP] Display the number of elements according to the context and barcode action [IMP] Do not allow trailing and leading spaces in the context field in barcode actions [IMP] Enable validate inventory date [IMP] Delete label list products scaned
- Loading branch information
1 parent
9db3fee
commit ddcf9f7
Showing
35 changed files
with
1,551 additions
and
535 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
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,11 @@ | ||
# Copyright 2019 Sergio Teruel <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class BarcodesEventsMixin(models.AbstractModel): | ||
_inherit = "barcodes.barcode_events_mixin" | ||
|
||
def send_bus_done(self, channel, type_channel, data=None): | ||
self.env["bus.bus"]._sendone(channel, type_channel, data or {}) |
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,8 +1,14 @@ | ||
# Copyright 2019 Sergio Teruel <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
import re | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
regex = r"^[^\s].*[^\s]$|^$" | ||
FIELDS_NAME = {"barcode_options": "barcode_option_group_id"} | ||
|
||
|
||
class StockBarcodesAction(models.Model): | ||
_name = "stock.barcodes.action" | ||
|
@@ -15,11 +21,76 @@ class StockBarcodesAction(models.Model): | |
action_window_id = fields.Many2one( | ||
comodel_name="ir.actions.act_window", string="Action window" | ||
) | ||
xml_external_id = fields.Char(related="action_window_id.xml_id") | ||
context = fields.Char() | ||
key_shortcut = fields.Integer() | ||
key_char_shortcut = fields.Char() | ||
icon_class = fields.Char() | ||
|
||
count_elements = fields.Integer(default=0, compute="_compute_count_elements") | ||
|
||
@api.constrains("context") | ||
def _constrains_context(self): | ||
if self.context and not bool(re.match(regex, self.context)): | ||
raise ValidationError(_("There can be no spaces at the beginning or end.")) | ||
|
||
def _count_elements(self): | ||
domain = [] | ||
if self.context: | ||
context_values = self.context.strip("{}").split(",") | ||
|
||
def _map_context_values(x): | ||
field_values = x.split(":") | ||
field_name = field_values[0].split("search_default_") | ||
if len(field_name) > 1: | ||
field_name = field_name[1].strip("'") | ||
field_value_format = field_values[1].replace("'", "").strip() | ||
field_value = ( | ||
int(field_value_format) | ||
if field_value_format.isdigit() | ||
else field_value_format | ||
) | ||
if hasattr( | ||
self.action_window_id.res_model, | ||
FIELDS_NAME.get(field_name, field_name), | ||
): | ||
return ( | ||
f"{FIELDS_NAME.get(field_name, field_name)}", | ||
"=", | ||
field_value, | ||
) | ||
else: | ||
return False | ||
else: | ||
return () | ||
|
||
domain = [ | ||
val_domain | ||
for val_domain in list( | ||
map(lambda x: _map_context_values(x), context_values) | ||
) | ||
] | ||
search_count = ( | ||
list(filter(lambda x: x, domain)) | ||
if all(val_d is True for val_d in domain) | ||
else [] | ||
) | ||
return ( | ||
self.env[self.action_window_id.res_model].search_count(search_count) | ||
if self.action_window_id.res_model | ||
else 0 | ||
) | ||
return 0 | ||
|
||
@api.depends("context") | ||
def _compute_count_elements(self): | ||
for barcode_action in self: | ||
barcode_action.count_elements = ( | ||
barcode_action._count_elements() | ||
if "search_default_" in barcode_action.context | ||
else 0 | ||
) | ||
|
||
def open_action(self): | ||
action = self.action_window_id.sudo().read()[0] | ||
action_context = safe_eval(action["context"]) | ||
|
@@ -29,8 +100,10 @@ def open_action(self): | |
if self.context: | ||
ctx.update(safe_eval(self.context)) | ||
if action_context.get("inventory_mode", False): | ||
return self.open_inventory_action(ctx) | ||
action["context"] = ctx | ||
action = self.open_inventory_action(ctx) | ||
else: | ||
action["context"] = ctx | ||
|
||
return action | ||
|
||
def open_inventory_action(self, ctx): | ||
|
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
Binary file not shown.
Binary file not shown.
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
Oops, something went wrong.