Skip to content

Commit

Permalink
[IMP] delivery_package_number: Allow force set package number at part…
Browse files Browse the repository at this point in the history
…ner level and picking operation

TT51855
  • Loading branch information
sergio-teruel committed Dec 20, 2024
1 parent 8fa3c06 commit c9a2dfa
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 14 deletions.
1 change: 1 addition & 0 deletions delivery_package_number/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"security/ir.model.access.csv",
"data/paperformat_data.xml",
"reports/report_package_number.xml",
"views/res_partner_view.xml",
"views/stock_picking_type_views.xml",
"views/stock_picking_views.xml",
"wizard/stock_number_package_validate_wiz_view.xml",
Expand Down
21 changes: 20 additions & 1 deletion delivery_package_number/i18n/delivery_package_number.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-20 08:52+0000\n"
"PO-Revision-Date: 2024-12-20 08:52+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: delivery_package_number
#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__always
msgid "Always"
msgstr ""

#. module: delivery_package_number
#: model_terms:ir.ui.view,arch_db:delivery_package_number.view_number_package_validate
msgid "Apply"
Expand All @@ -33,6 +40,11 @@ msgstr ""
msgid "Cancel"
msgstr ""

#. module: delivery_package_number
#: model:ir.model,name:delivery_package_number.model_res_partner
msgid "Contact"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__create_uid
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__create_uid
Expand All @@ -57,6 +69,8 @@ msgid "Display Name"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_res_partner__force_set_number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_res_users__force_set_number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking_type__force_set_number_of_packages
msgid "Force Set Number Of Packages"
msgstr ""
Expand Down Expand Up @@ -91,12 +105,12 @@ msgid "Last Updated on"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__number_of_packages
msgid "Number Of Packages"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking__number_of_packages
msgid "Number of Packages"
msgstr ""
Expand All @@ -111,6 +125,11 @@ msgstr ""
msgid "Number of packages:"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__partner
msgid "Partner condition"
msgstr ""

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__pick_ids
msgid "Pick"
Expand Down
33 changes: 25 additions & 8 deletions delivery_package_number/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-16 08:40+0000\n"
"PO-Revision-Date: 2024-02-25 19:36+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"POT-Creation-Date: 2024-12-20 08:52+0000\n"
"PO-Revision-Date: 2024-12-20 09:53+0100\n"
"Last-Translator: Sergio Teruel <[email protected]>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
"X-Generator: Poedit 3.0.1\n"

#. module: delivery_package_number
#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__always
msgid "Always"
msgstr "Siempre"

#. module: delivery_package_number
#: model_terms:ir.ui.view,arch_db:delivery_package_number.view_number_package_validate
Expand All @@ -37,6 +42,11 @@ msgstr "Confirmación de pedido pendiente"
msgid "Cancel"
msgstr "Cancelar"

#. module: delivery_package_number
#: model:ir.model,name:delivery_package_number.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__create_uid
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__create_uid
Expand All @@ -61,6 +71,8 @@ msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_res_partner__force_set_number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_res_users__force_set_number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking_type__force_set_number_of_packages
msgid "Force Set Number Of Packages"
msgstr "Forzar Establecer Número De Paquetes"
Expand Down Expand Up @@ -95,12 +107,12 @@ msgid "Last Updated on"
msgstr "Última Actualización el"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__number_of_packages
msgid "Number Of Packages"
msgstr "Número de Bultos"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__number_of_packages
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_picking__number_of_packages
msgid "Number of Packages"
msgstr "Número de Bultos"
Expand All @@ -115,20 +127,25 @@ msgstr "Número de paquetes"
msgid "Number of packages:"
msgstr "Número de paquetes:"

#. module: delivery_package_number
#: model:ir.model.fields.selection,name:delivery_package_number.selection__stock_picking_type__force_set_number_of_packages__partner
msgid "Partner condition"
msgstr "Condición en el contacto"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__pick_ids
msgid "Pick"
msgstr "Escoja"
msgstr "Recogida"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_line_wizard__picking_id
msgid "Picking"
msgstr "Recogiendo"
msgstr "Albarán"

#. module: delivery_package_number
#: model:ir.model,name:delivery_package_number.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo de Recogida"
msgstr "Tipo de operación"

#. module: delivery_package_number
#: model:ir.model.fields,field_description:delivery_package_number.field_stock_number_package_validate_wizard__print_package_label
Expand Down
1 change: 1 addition & 0 deletions delivery_package_number/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import res_partner
from . import stock_picking_type
from . import stock_picking
9 changes: 9 additions & 0 deletions delivery_package_number/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

force_set_number_of_packages = fields.Boolean()
6 changes: 5 additions & 1 deletion delivery_package_number/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def _compute_ask_number_of_packages(self):
picking.ask_number_of_packages = bool(
picking.carrier_id
and not picking.package_ids
or picking.picking_type_id.force_set_number_of_packages
or picking.picking_type_id.force_set_number_of_packages == "always"
or (
picking.picking_type_id.force_set_number_of_packages == "partner"
and picking.partner_id.force_set_number_of_packages
)
)

def _get_pickings_to_set_number_of_packages(self):
Expand Down
7 changes: 6 additions & 1 deletion delivery_package_number/models/stock_picking_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
class StockPickingType(models.Model):
_inherit = "stock.picking.type"

force_set_number_of_packages = fields.Boolean()
force_set_number_of_packages = fields.Selection(
[
("always", "Always"),
("partner", "Partner condition"),
]
)
report_number_of_packages = fields.Many2one(
"ir.actions.report",
default=lambda self: self.env.ref(
Expand Down
12 changes: 12 additions & 0 deletions delivery_package_number/views/res_partner_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_partner_stock_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="stock.view_partner_stock_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='property_stock_supplier']" position="after">
<field name="force_set_number_of_packages" />
</xpath>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ 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
self.pick_ids.with_context(
set_default_package=False, bypass_set_number_of_packages=True
).button_validate()
if not self.env.context.get("skip_picking_validate", False):
self.pick_ids.with_context(

Check warning on line 46 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#L46

Added line #L46 was not covered by tests
set_default_package=False, bypass_set_number_of_packages=True
).button_validate()
if self.print_package_label:
return self._print_package_label()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
name="stock_number_package_validation_line_ids"
attrs="{'invisible': [('stock_number_package_validation_line_ids', '=', [])]}"
nolabel="1"
force_save="1"
>
<tree create="0" delete="0" editable="1">
<field
Expand Down

0 comments on commit c9a2dfa

Please sign in to comment.