-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] delivery_package_number: Add label to print package numbers
- Loading branch information
1 parent
1db5b74
commit ce519df
Showing
19 changed files
with
271 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
|
||
<record id="paperformat_number_of_packages_label" model="report.paperformat"> | ||
<field name="name">Number of package label</field> | ||
<field name="default" eval="True" /> | ||
<field name="format">custom</field> | ||
<field name="page_width">100</field> | ||
<field name="page_height">50</field> | ||
<field name="orientation">Portrait</field> | ||
<field name="margin_top">0</field> | ||
<field name="margin_bottom">0</field> | ||
<field name="margin_left">5</field> | ||
<field name="margin_right">5</field> | ||
<field name="header_line" eval="False" /> | ||
<field name="header_spacing">0</field> | ||
<field name="dpi">150</field> | ||
</record> | ||
|
||
</odoo> |
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 +1,2 @@ | ||
from . import stock_picking_type | ||
from . import stock_picking |
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,9 @@ | ||
# Copyright 2023 Tecnativa - Carlos Roca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class StockPickingType(models.Model): | ||
_inherit = "stock.picking.type" | ||
|
||
force_set_number_of_packages = fields.Boolean() |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* Pedro M. Baeza | ||
* David Vidal | ||
* Marçal Isern | ||
* Carlos Roca | ||
|
||
|
||
* `Sygel <https://www.sygel.es>`_: | ||
|
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,80 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template id="delivery_package_number_document"> | ||
<t t-call="web.basic_layout"> | ||
<t | ||
t-set="move_ids" | ||
t-value="doc.move_lines._rollup_move_dests({doc.move_lines[:1].id})" | ||
/> | ||
<t | ||
t-set="dest_picking" | ||
t-value="doc.move_lines.browse(move_ids).filtered('sale_line_id')[:1].picking_id" | ||
/> | ||
<t t-foreach="doc.number_of_packages" t-as="pack_num"> | ||
<div class="page"> | ||
<div class="row"> | ||
<div class="col-5" name="logo"> | ||
<img | ||
t-if="doc.company_id.logo" | ||
t-att-src="image_data_uri(doc.company_id.logo)" | ||
style="max-height: 80px;" | ||
class="float-left" | ||
/> | ||
</div> | ||
<div class="col-2" /> | ||
<div class="col-5 text-center pt-3" name="picking_ref"> | ||
<div | ||
t-field="dest_picking.name" | ||
t-options="{'widget': 'barcode', 'img_style': 'width:100%'}" | ||
/> | ||
<h4> | ||
<strong t-field="dest_picking.name" /> | ||
</h4> | ||
</div> | ||
</div> | ||
<div class="row mt-3"> | ||
<div | ||
class="col-5 border border-dark rounded text-center" | ||
style="padding: 60px 0;" | ||
name="client" | ||
> | ||
<span t-field="dest_picking.partner_id" /> | ||
</div> | ||
<div class="col-2" /> | ||
<div | ||
class="col-5 border border-dark rounded" | ||
name="package_number" | ||
> | ||
<h6>Number of packages:</h6> | ||
<div style="font-size: 4em" class="text-center"> | ||
<span t-out="pack_num + 1" />/<span | ||
t-field="doc.number_of_packages" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div style="page-break-before:always;" /> | ||
</t> | ||
</t> | ||
</template> | ||
<template id="delivery_package_number_report"> | ||
<t t-foreach="docs" t-as="doc"> | ||
<t t-call="delivery_package_number.delivery_package_number_document" /> | ||
</t> | ||
</template> | ||
<record id="action_delivery_package_number_report" model="ir.actions.report"> | ||
<field name="name">Delivery packages</field> | ||
<field name="model">stock.picking</field> | ||
<field name="binding_model_id" ref="stock.model_stock_picking" /> | ||
<field name="report_type">qweb-pdf</field> | ||
<field | ||
name="report_name" | ||
>delivery_package_number.delivery_package_number_report</field> | ||
<field | ||
name="report_file" | ||
>delivery_package_number.delivery_package_number_report</field> | ||
<field name="paperformat_id" ref="paperformat_number_of_packages_label" /> | ||
</record> | ||
</odoo> |
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 @@ | ||
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 |
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
14 changes: 14 additions & 0 deletions
14
delivery_package_number/views/stock_picking_type_views.xml
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record model="ir.ui.view" id="view_picking_type_form"> | ||
<field name="model">stock.picking.type</field> | ||
<field name="inherit_id" ref="stock.view_picking_type_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='default_location_src_id']/.." position="after"> | ||
<group string="Number of packages"> | ||
<field name="force_set_number_of_packages" /> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
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,2 +1,4 @@ | ||
from . import stock_number_package_mixin | ||
from . import stock_inmediate_transfer | ||
from . import stock_backorder_confirmation | ||
from . import stock_number_package_validate_wiz |
19 changes: 3 additions & 16 deletions
19
delivery_package_number/wizard/stock_backorder_confirmation.py
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,25 +1,12 @@ | ||
# Copyright 2023 Ángel García de la Chica Herrera <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo import models | ||
|
||
|
||
class StockBackorderConfirmation(models.TransientModel): | ||
_inherit = "stock.backorder.confirmation" | ||
|
||
number_of_packages = fields.Integer( | ||
help="Set the number of packages for picking to be validated", | ||
) | ||
ask_number_of_packages = fields.Boolean(compute="_compute_ask_number_of_packages") | ||
|
||
@api.depends("pick_ids") | ||
def _compute_ask_number_of_packages(self): | ||
for item in self: | ||
# we use ._origin because if not, a NewId is used for the checks and the returned | ||
# value of package_ids is wrong. | ||
item.ask_number_of_packages = bool( | ||
item.pick_ids.carrier_id and not item.pick_ids._origin.package_ids | ||
) | ||
_inherit = ["stock.backorder.confirmation", "stock.number.package.mixin"] | ||
_name = "stock.backorder.confirmation" | ||
|
||
def process(self): | ||
if self.number_of_packages: | ||
|
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
19 changes: 3 additions & 16 deletions
19
delivery_package_number/wizard/stock_inmediate_transfer.py
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
23 changes: 23 additions & 0 deletions
23
delivery_package_number/wizard/stock_number_package_mixin.py
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,23 @@ | ||
# Copyright 2023 Tecnativa - Carlos Roca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockNumberPackageMixin(models.AbstractModel): | ||
_name = "stock.number.package.mixin" | ||
_description = "Mixin to set number of packages" | ||
|
||
number_of_packages = fields.Integer( | ||
help="Set the number of packages for this picking(s)", | ||
) | ||
ask_number_of_packages = fields.Boolean(compute="_compute_ask_number_of_packages") | ||
print_package_label = fields.Boolean() | ||
|
||
@api.depends("pick_ids") | ||
def _compute_ask_number_of_packages(self): | ||
for item in self: | ||
# we use ._origin because if not, a NewId is used for the checks and the returned | ||
# value of package_ids is wrong. | ||
item.ask_number_of_packages = bool( | ||
item.pick_ids.carrier_id and not item.pick_ids._origin.package_ids | ||
) |
19 changes: 19 additions & 0 deletions
19
delivery_package_number/wizard/stock_number_package_validate_wiz.py
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 2023 Tecnativa - Carlos Roca | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class StockNumberPackageValidateWiz(models.TransientModel): | ||
_inherit = "stock.number.package.mixin" | ||
_name = "stock.number.package.validate.wizard" | ||
_description = "Wizard to force set number of pickings when validate" | ||
|
||
pick_ids = fields.Many2many("stock.picking", "stock_picking_number_package_rel") | ||
|
||
def process(self): | ||
if self.number_of_packages: | ||
self.pick_ids.write({"number_of_packages": self.number_of_packages}) | ||
# put context key for avoiding `base_delivery_carrier_label` auto-packaging feature | ||
return self.pick_ids.with_context( | ||
set_default_package=False, bypass_set_number_of_packages=True | ||
).button_validate() |
Oops, something went wrong.