Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] delivery_package_number: add field for auto printing #762

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
@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
Loading