Skip to content

Commit

Permalink
[IMP] delivery_package_number: add field for auto printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ferran-S73 committed Oct 16, 2024
1 parent 16474e9 commit 9a9f536
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion delivery_package_number/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Stock Picking Package Number",
"summary": "Set or compute number of packages for a picking",
"version": "16.0.2.1.0",
"version": "16.0.3.0.0",
"category": "Delivery",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
11 changes: 11 additions & 0 deletions delivery_package_number/migrations/16.0.3.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2023 Studio73 - Ferran Mora
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
ptypes = env["stock.picking.type"].search([("print_label", "=", True)])
if ptypes:
ptypes.write({"print_label_on_validate": True})
4 changes: 4 additions & 0 deletions delivery_package_number/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
class StockPickingType(models.Model):
_inherit = "stock.picking.type"

print_label_on_validate = fields.Boolean(
string="Print label on validate",
help="Print the number of packages label when validating a picking of this type",
)
force_set_number_of_packages = fields.Boolean()
report_number_of_packages = fields.Many2one(
"ir.actions.report",
Expand Down
1 change: 1 addition & 0 deletions delivery_package_number/views/stock_picking_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='default_location_src_id']/.." position="after">
<group string="Number of packages">
<field name="print_label_on_validate" />
<field name="force_set_number_of_packages" />
<field name="report_number_of_packages" />
</group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class StockNumberPackageValidateWiz(models.TransientModel):
@api.depends("pick_ids")
def _compute_print_package_label(self):
for item in self:
item.print_package_label = item.pick_ids.picking_type_id.print_label
item.print_package_label = (

Check warning on line 28 in delivery_package_number/wizard/stock_number_package_validate_wiz.py

View check run for this annotation

Codecov / codecov/patch

delivery_package_number/wizard/stock_number_package_validate_wiz.py#L28

Added line #L28 was not covered by tests
item.pick_ids.picking_type_id.print_label_on_validate
)

@api.depends("pick_ids")
def _compute_stock_number_package_validation_line_ids(self):
Expand Down

0 comments on commit 9a9f536

Please sign in to comment.