Skip to content

Commit

Permalink
Merge PR #736 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 17, 2024
2 parents 8059e2d + 9e52f09 commit 166d6ae
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions delivery_package_number/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stock_number_package_validate_wizard,access.stock.number.package.validate.wizard,model_stock_number_package_validate_wizard,stock.group_stock_user,1,1,1,0
access_stock_number_package_validate_line_wizard,access.stock.number.package.validate.line.wizard,model_stock_number_package_validate_line_wizard,stock.group_stock_user,1,1,1,0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 Tecnativa - Carlos Roca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo import api, fields, models


class StockNumberPackageValidateWiz(models.TransientModel):
Expand All @@ -9,6 +9,24 @@ class StockNumberPackageValidateWiz(models.TransientModel):
_description = "Wizard to force set number of pickings when validate"

pick_ids = fields.Many2many("stock.picking", "stock_picking_number_package_rel")
stock_number_package_validation_line_ids = fields.One2many(
comodel_name="stock.number.package.validate.line.wizard",
inverse_name="wiz_id",
compute="_compute_stock_number_package_validation_line_ids",
readonly=False,
store=True,
)

@api.depends("pick_ids")
def _compute_stock_number_package_validation_line_ids(self):
for wiz in self:
if len(wiz.pick_ids) <= 1:
wiz.stock_number_package_validation_line_ids = False
else:
wiz.stock_number_package_validation_line_ids = [
fields.Command.create({"picking_id": picking.id})
for picking in wiz.pick_ids
]

def process(self):
if self.number_of_packages:
Expand Down Expand Up @@ -36,3 +54,16 @@ def _print_package_label(self):
report_action = report.report_action(self.pick_ids)
report_action.update({"close_on_report_download": True})
return report_action


class StockNumberPackageValidateLineWizLine(models.TransientModel):
_name = "stock.number.package.validate.line.wizard"
_description = "Stock Number Package Lines Wizard"

wiz_id = fields.Many2one(
comodel_name="stock.number.package.validate.wizard", readonly=True
)
picking_id = fields.Many2one(comodel_name="stock.picking")
number_of_packages = fields.Integer(
related="picking_id.number_of_packages", readonly=False
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@
<field name="model">stock.number.package.validate.wizard</field>
<field name="arch" type="xml">
<form string="Set number of packages">
<field name="pick_ids" invisible="1" />
<group>
<field name="number_of_packages" />
<field
name="number_of_packages"
attrs="{'invisible': [('stock_number_package_validation_line_ids', '!=', [])]}"
/>
</group>
<group>
<field
name="stock_number_package_validation_line_ids"
attrs="{'invisible': [('stock_number_package_validation_line_ids', '=', [])]}"
nolabel="1"
>
<tree create="0" delete="0" editable="1">
<field
name="picking_id"
options="{'no_open': True}"
readonly="1"
force_save="1"
/>
<field name="number_of_packages" />
</tree>
</field>
</group>
<footer>
<button
Expand Down

0 comments on commit 166d6ae

Please sign in to comment.