diff --git a/custom_sale_order_type_route/i18n/custom_sale_order_type_route.pot b/custom_sale_order_type_route/i18n/custom_sale_order_type_route.pot index 100fd5ea..519eb582 100644 --- a/custom_sale_order_type_route/i18n/custom_sale_order_type_route.pot +++ b/custom_sale_order_type_route/i18n/custom_sale_order_type_route.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-30 10:42+0000\n" -"PO-Revision-Date: 2024-07-30 10:42+0000\n" +"POT-Creation-Date: 2024-10-03 07:42+0000\n" +"PO-Revision-Date: 2024-10-03 07:42+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -53,6 +53,13 @@ msgstr "" msgid "Contact" msgstr "" +#. module: custom_sale_order_type_route +#: code:addons/custom_sale_order_type_route/models/sale_order_type.py:0 +#: model_terms:ir.ui.view,arch_db:custom_sale_order_type_route.sot_sale_order_type_form_view +#, python-format +msgid "Contacts" +msgstr "" + #. module: custom_sale_order_type_route #: model_terms:ir.actions.act_window,help:custom_sale_order_type_route.action_my_route_type_sales #: model_terms:ir.actions.act_window,help:custom_sale_order_type_route.action_route_type_sales @@ -96,6 +103,12 @@ msgstr "" msgid "Display Name" msgstr "" +#. module: custom_sale_order_type_route +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_partner__distribution_sequence +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_users__distribution_sequence +msgid "Distribution Sequence" +msgstr "" + #. module: custom_sale_order_type_route #: model:ir.model.fields,field_description:custom_sale_order_type_route.field_account_payment__id #: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_partner__id @@ -152,6 +165,11 @@ msgstr "" msgid "Not Route Type" msgstr "" +#. module: custom_sale_order_type_route +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_sale_order__partner_distribution_sequence +msgid "Partner Distribution Sequence" +msgstr "" + #. module: custom_sale_order_type_route #: model:ir.model,name:custom_sale_order_type_route.model_account_payment msgid "Payments" diff --git a/custom_sale_order_type_route/i18n/es.po b/custom_sale_order_type_route/i18n/es.po index fe9a1e99..ae01e346 100644 --- a/custom_sale_order_type_route/i18n/es.po +++ b/custom_sale_order_type_route/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-30 10:42+0000\n" -"PO-Revision-Date: 2024-07-30 10:42+0000\n" +"POT-Creation-Date: 2024-10-03 07:42+0000\n" +"PO-Revision-Date: 2024-10-03 07:42+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -53,6 +53,13 @@ msgstr "Tipo carga" msgid "Contact" msgstr "Contacto" +#. module: custom_sale_order_type_route +#: code:addons/custom_sale_order_type_route/models/sale_order_type.py:0 +#: model_terms:ir.ui.view,arch_db:custom_sale_order_type_route.sot_sale_order_type_form_view +#, python-format +msgid "Contacts" +msgstr "Contactos" + #. module: custom_sale_order_type_route #: model_terms:ir.actions.act_window,help:custom_sale_order_type_route.action_my_route_type_sales #: model_terms:ir.actions.act_window,help:custom_sale_order_type_route.action_route_type_sales @@ -96,6 +103,12 @@ msgstr "Repartidor" msgid "Display Name" msgstr "Nombre mostrado" +#. module: custom_sale_order_type_route +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_partner__distribution_sequence +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_users__distribution_sequence +msgid "Distribution Sequence" +msgstr "Órden de reparto" + #. module: custom_sale_order_type_route #: model:ir.model.fields,field_description:custom_sale_order_type_route.field_account_payment__id #: model:ir.model.fields,field_description:custom_sale_order_type_route.field_res_partner__id @@ -152,6 +165,11 @@ msgstr "Mis ventas" msgid "Not Route Type" msgstr "No es tipo ruta" +#. module: custom_sale_order_type_route +#: model:ir.model.fields,field_description:custom_sale_order_type_route.field_sale_order__partner_distribution_sequence +msgid "Partner Distribution Sequence" +msgstr "Órden de reparto" + #. module: custom_sale_order_type_route #: model:ir.model,name:custom_sale_order_type_route.model_account_payment msgid "Payments" diff --git a/custom_sale_order_type_route/models/res_partner.py b/custom_sale_order_type_route/models/res_partner.py index 2095bab2..097e7eab 100644 --- a/custom_sale_order_type_route/models/res_partner.py +++ b/custom_sale_order_type_route/models/res_partner.py @@ -11,3 +11,6 @@ class ResPartner(models.Model): string="Special Burden", default=False, ) + distribution_sequence = fields.Integer( + string="Distribution Sequence", + ) diff --git a/custom_sale_order_type_route/models/sale_order.py b/custom_sale_order_type_route/models/sale_order.py index 70b6e8fd..7ee656e7 100644 --- a/custom_sale_order_type_route/models/sale_order.py +++ b/custom_sale_order_type_route/models/sale_order.py @@ -19,6 +19,11 @@ class SaleOrder(models.Model): string="Special Burden", default=False, ) + partner_distribution_sequence = fields.Integer( + string="Partner Distribution Sequence", + related="partner_shipping_id.distribution_sequence", + store=True, + ) def _compute_deliverement_menu(self): for sale in self: diff --git a/custom_sale_order_type_route/models/sale_order_line.py b/custom_sale_order_type_route/models/sale_order_line.py index af696d4a..8667cc4e 100644 --- a/custom_sale_order_type_route/models/sale_order_line.py +++ b/custom_sale_order_type_route/models/sale_order_line.py @@ -52,16 +52,22 @@ def action_create_burden_picking(self): if line.order_id.type_id.burden_picking_type not in burden_type: burden_picking_type = line.order_id.type_id.burden_picking_type burden_type.append(burden_picking_type) - picking = self.env["stock.picking"].create( - { - "picking_type_id": burden_picking_type.id, - "location_id": burden_picking_type.default_location_src_id.id, - "location_dest_id": burden_picking_type.default_location_dest_id.id, - "custom_date_done": fields.datetime.now(), - "user_id": self.env.user.id, - "company_id": line.company_id.id, - } - ) + picking_obj = self.env["stock.picking"] + vals = { + "picking_type_id": burden_picking_type.id, + "location_id": burden_picking_type.default_location_src_id.id, + "location_dest_id": burden_picking_type.default_location_dest_id.id, + "custom_date_done": fields.datetime.now(), + "user_id": self.env.user.id, + "company_id": line.company_id.id, + } + picking = picking_obj.new(vals) + for comp_onchange in picking._onchange_methods[ + "picking_type_id", + ]: + comp_onchange(picking) + picking = picking._convert_to_write(picking._cache) + picking = picking_obj.create(picking) lines = [] same_type_lines = self.filtered( lambda c: c.order_id.type_id.burden_picking_type @@ -69,24 +75,32 @@ def action_create_burden_picking(self): ) for same_type_line in same_type_lines: if same_type_line.order_id.special_burden: - self.env["stock.move.line"].create( - { - "picking_id": picking.id, - "product_id": same_type_line.product_id.id, - "burden_partner_id": ( - same_type_line.special_partner_id.id - ), - "product_uom_id": (same_type_line.product_id.uom_id.id), - "location_id": picking.location_id.id, - "location_dest_id": picking.location_dest_id.id, - "product_packaging_id": ( - same_type_line.product_packaging.id - ), - "product_packaging_qty": ( - same_type_line.product_packaging_qty - ), - } - ) + move_line_obj = self.env["stock.move.line"] + vals = { + "picking_id": picking.id, + "product_id": same_type_line.product_id.id, + "burden_partner_id": (same_type_line.special_partner_id.id), + "product_uom_id": (same_type_line.product_id.uom_id.id), + "location_id": picking.location_id.id, + "location_dest_id": picking.location_dest_id.id, + "product_packaging_id": ( + same_type_line.product_packaging.id + ), + "product_packaging_qty": ( + same_type_line.product_packaging_qty + ), + } + move_line = move_line_obj.new(vals) + for comp_onchange in move_line._onchange_methods[ + "picking_id", + "product_id", + "product_uom_id", + "product_packaging_id", + "product_packaging_qty", + ]: + comp_onchange(move_line) + move_line = move_line._convert_to_write(move_line._cache) + move_line = move_line_obj.create(move_line) if not same_type_line.order_id.special_burden and ( same_type_line not in lines ): @@ -96,23 +110,31 @@ def action_create_burden_picking(self): == (same_type_line.product_packaging) and not c.order_id.special_burden ) - self.env["stock.move.line"].create( - { - "picking_id": picking.id, - "product_id": same_type_line.product_id.id, - "burden_partner_id": ( - same_type_line.special_partner_id.id - ), - "product_uom_id": (same_type_line.product_id.uom_id.id), - "location_id": picking.location_id.id, - "location_dest_id": picking.location_dest_id.id, - "product_packaging_id": ( - same_type_line.product_packaging.id - ), - "product_packaging_qty": sum( - same_product_package.mapped("product_packaging_qty") - ), - } - ) + move_line_obj = self.env["stock.move.line"] + vals = { + "picking_id": picking.id, + "product_id": same_type_line.product_id.id, + "burden_partner_id": (same_type_line.special_partner_id.id), + "product_uom_id": (same_type_line.product_id.uom_id.id), + "location_id": picking.location_id.id, + "location_dest_id": picking.location_dest_id.id, + "product_packaging_id": ( + same_type_line.product_packaging.id + ), + "product_packaging_qty": sum( + same_product_package.mapped("product_packaging_qty") + ), + } + move_line = move_line_obj.new(vals) + for comp_onchange in move_line._onchange_methods[ + "picking_id", + "product_id", + "product_uom_id", + "product_packaging_id", + "product_packaging_qty", + ]: + comp_onchange(move_line) + move_line = move_line._convert_to_write(move_line._cache) + move_line = move_line_obj.create(move_line) for sale_line in same_product_package: lines.append(sale_line) diff --git a/custom_sale_order_type_route/models/sale_order_type.py b/custom_sale_order_type_route/models/sale_order_type.py index 457d9887..144cae95 100644 --- a/custom_sale_order_type_route/models/sale_order_type.py +++ b/custom_sale_order_type_route/models/sale_order_type.py @@ -1,7 +1,7 @@ # Copyright 2024 Berezi Amubieta - AvanzOSC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import _, fields, models class SaleOrderType(models.Model): @@ -14,3 +14,22 @@ class SaleOrderType(models.Model): burden_picking_type = fields.Many2one( string="Burden Picking Type", comodel_name="stock.picking.type" ) + + def action_view_contact(self): + context = self.env.context.copy() + context.update( + { + "default_sale_type": self.id, + } + ) + return { + "name": _("Contacts"), + "view_mode": "tree", + "view_id": self.env.ref( + "custom_sale_order_type_route.view_partner_tree_editable" + ).id, + "res_model": "res.partner", + "domain": [("sale_type", "=", self.id)], + "type": "ir.actions.act_window", + "context": context, + } diff --git a/custom_sale_order_type_route/views/res_partner_view.xml b/custom_sale_order_type_route/views/res_partner_view.xml index fcdc4f9c..472812fb 100644 --- a/custom_sale_order_type_route/views/res_partner_view.xml +++ b/custom_sale_order_type_route/views/res_partner_view.xml @@ -8,6 +8,26 @@ + + + + + + + + res.partner + + primary + 50 + + + 0 + bottom + distribution_sequence, name + + + + diff --git a/custom_sale_order_type_route/views/sale_order_type_view.xml b/custom_sale_order_type_route/views/sale_order_type_view.xml index 9bf5bf46..1e9d7713 100644 --- a/custom_sale_order_type_route/views/sale_order_type_view.xml +++ b/custom_sale_order_type_route/views/sale_order_type_view.xml @@ -4,6 +4,15 @@ sale.order.type +
+
+ + sale.order + + + + partner_distribution_sequence, name + + + + + + + sale.order