From d6e1ecf0cbdbe07122aed89a3c7284735e098e24 Mon Sep 17 00:00:00 2001 From: Reyes4711 Date: Mon, 2 Jan 2023 09:03:16 +0100 Subject: [PATCH] [14.0][IMP] purchase_order_type: picking_type_id Add a new functionality to add picking types in pruchase orders when changing the picking order type --- purchase_order_type/README.rst | 1 + purchase_order_type/__manifest__.py | 2 +- purchase_order_type/i18n/es.po | 44 +++++++------------ .../i18n/purchase_order_type.pot | 8 ++++ purchase_order_type/models/purchase_order.py | 11 ++++- .../models/purchase_order_type.py | 3 ++ purchase_order_type/readme/CONTRIBUTORS.rst | 1 + .../tests/test_purchase_order_type.py | 5 +++ .../views/view_purchase_order_type.xml | 1 + 9 files changed, 47 insertions(+), 29 deletions(-) diff --git a/purchase_order_type/README.rst b/purchase_order_type/README.rst index eaf8321afc0..19eb587810e 100644 --- a/purchase_order_type/README.rst +++ b/purchase_order_type/README.rst @@ -79,6 +79,7 @@ Contributors * Guewen Baconnier * Pimolnat Suntian +* Carlos Reyes Maintainers ~~~~~~~~~~~ diff --git a/purchase_order_type/__manifest__.py b/purchase_order_type/__manifest__.py index bb95bc241b1..9a2df1f76de 100644 --- a/purchase_order_type/__manifest__.py +++ b/purchase_order_type/__manifest__.py @@ -7,7 +7,7 @@ "author": "Camptocamp, Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Purchase Management", - "depends": ["purchase"], + "depends": ["purchase", "stock"], "website": "https://github.com/OCA/purchase-workflow", "data": [ "security/ir.model.access.csv", diff --git a/purchase_order_type/i18n/es.po b/purchase_order_type/i18n/es.po index 6df93eefaa3..ed8a1287830 100644 --- a/purchase_order_type/i18n/es.po +++ b/purchase_order_type/i18n/es.po @@ -1,26 +1,10 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * purchase_order_type +# * purchase_order_type # -# Translators: -# Ahmet Altinisik , 2016 -# Ahmet Altinisik , 2016 -# Antonio Trueba, 2016 -# Armando Vulcano Junior , 2015 -# Carles Antoli , 2015 -# Carles Antoli , 2015 -# danimaribeiro , 2016 -# FIRST AUTHOR , 2012 -# Kostas Goutoudis , 2015 -# Kostas Goutoudis , 2015 -# Matjaž Mozetič , 2015-2016 -# Paolo Valier, 2016 -# Pedro M. Baeza , 2015 -# Rudolf Schnapka , 2016 -# SaFi J. , 2015 msgid "" msgstr "" -"Project-Id-Version: purchase-workflow (8.0)\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-11-16 12:06+0000\n" "PO-Revision-Date: 2024-04-16 19:34+0000\n" @@ -53,7 +37,7 @@ msgstr "Haga clic para establecer un nuevo tipo de orden de compra." #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__company_id #: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_search msgid "Company" -msgstr "Companía" +msgstr "Compañía" #. module: purchase_order_type #: model:ir.model,name:purchase_order_type.model_res_partner @@ -84,6 +68,7 @@ msgstr "Nombre mostrado" #. module: purchase_order_type #: code:addons/purchase_order_type/models/purchase_order.py:0 +#: code:addons/purchase_order_type/models/purchase_order.py:0 #, python-format msgid "Document's company and type's company mismatch" msgstr "" @@ -94,19 +79,19 @@ msgstr "" #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__sequence_id #: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_search msgid "Entry Sequence" -msgstr "Secuencia de Entrada" +msgstr "Secuencia de entrada" #. module: purchase_order_type #: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_search msgid "Group By" -msgstr "Agrupado Por" +msgstr "Agrupar por" #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order__id #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__id #: model:ir.model.fields,field_description:purchase_order_type.field_res_partner__id msgid "ID" -msgstr "ID" +msgstr "" #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__incoterm_id @@ -139,31 +124,36 @@ msgstr "Nombre" #. module: purchase_order_type #: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_search msgid "Payment Term" -msgstr "Término de Pago" +msgstr "Plazo de pago" #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__payment_term_id msgid "Payment Terms" -msgstr "Términos del Pago" +msgstr "Plazos de pago" #. module: purchase_order_type #: model:ir.model,name:purchase_order_type.model_purchase_order msgid "Purchase Order" -msgstr "Orden de Compra" +msgstr "Pedido de compra" #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_res_partner__purchase_type #: model:ir.model.fields,field_description:purchase_order_type.field_res_users__purchase_type #: model_terms:ir.ui.view,arch_db:purchase_order_type.res_partner_purchase_type_form_view msgid "Purchase Order Type" -msgstr "Tipo de Orden de Compra" +msgstr "Tipo de pedido de compra" #. module: purchase_order_type #: model:ir.actions.act_window,name:purchase_order_type.action_purchase_order_type_view #: model:ir.ui.menu,name:purchase_order_type.menu_purchase_order_type #: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_search msgid "Purchase Order Types" -msgstr "Tipos de Orden de Compra" +msgstr "Tipos de pedido de compra" + +#. module: purchase_order_type +#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__picking_type_id +msgid "Send to" +msgstr "Entregar a" #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__sequence diff --git a/purchase_order_type/i18n/purchase_order_type.pot b/purchase_order_type/i18n/purchase_order_type.pot index 873ea995178..a1029310e2a 100644 --- a/purchase_order_type/i18n/purchase_order_type.pot +++ b/purchase_order_type/i18n/purchase_order_type.pot @@ -6,6 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-01-02 07:40+0000\n" +"PO-Revision-Date: 2023-01-02 07:40+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -63,6 +65,7 @@ msgstr "" #. module: purchase_order_type #: code:addons/purchase_order_type/models/purchase_order.py:0 +#: code:addons/purchase_order_type/models/purchase_order.py:0 #, python-format msgid "Document's company and type's company mismatch" msgstr "" @@ -142,6 +145,11 @@ msgstr "" msgid "Purchase Order Types" msgstr "" +#. module: purchase_order_type +#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__picking_type_id +msgid "Send to" +msgstr "" + #. module: purchase_order_type #: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__sequence msgid "Sequence" diff --git a/purchase_order_type/models/purchase_order.py b/purchase_order_type/models/purchase_order.py index 19e7d075106..b259ad65c40 100644 --- a/purchase_order_type/models/purchase_order.py +++ b/purchase_order_type/models/purchase_order.py @@ -27,7 +27,12 @@ def onchange_partner_id(self): or self.partner_id.commercial_partner_id.purchase_type ) if purchase_type: - self.order_type = purchase_type + self.write( + { + "order_type": purchase_type.id, + "picking_type_id": purchase_type.picking_type_id.id, + } + ) @api.onchange("order_type") def onchange_order_type(self): @@ -36,6 +41,8 @@ def onchange_order_type(self): order.payment_term_id = order.order_type.payment_term_id.id if order.order_type.incoterm_id: order.incoterm_id = order.order_type.incoterm_id.id + if order.order_type.picking_type_id: + order.picking_type_id = order.order_type.picking_type_id.id @api.model def create(self, vals): @@ -65,3 +72,5 @@ def _default_order_type(self): @api.onchange("company_id") def _onchange_company(self): self.order_type = self._default_order_type() + if self.order_type: + self.picking_type_id = self.order_type.picking_type_id.id diff --git a/purchase_order_type/models/purchase_order_type.py b/purchase_order_type/models/purchase_order_type.py index c97f000ef04..cd178f45a88 100644 --- a/purchase_order_type/models/purchase_order_type.py +++ b/purchase_order_type/models/purchase_order_type.py @@ -43,3 +43,6 @@ def _default_sequence_id(self): string="Company", default=lambda self: self.env.company, ) + picking_type_id = fields.Many2one( + comodel_name="stock.picking.type", string="Send to" + ) diff --git a/purchase_order_type/readme/CONTRIBUTORS.rst b/purchase_order_type/readme/CONTRIBUTORS.rst index 3b6c71a0f70..cd2d0ce495f 100644 --- a/purchase_order_type/readme/CONTRIBUTORS.rst +++ b/purchase_order_type/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Guewen Baconnier * Pimolnat Suntian +* Carlos Reyes diff --git a/purchase_order_type/tests/test_purchase_order_type.py b/purchase_order_type/tests/test_purchase_order_type.py index eb576f80c4d..3e1efa4e431 100644 --- a/purchase_order_type/tests/test_purchase_order_type.py +++ b/purchase_order_type/tests/test_purchase_order_type.py @@ -21,9 +21,12 @@ def setUpClass(cls): cls.product1 = cls.env.ref("product.product_product_7") cls.product2 = cls.env.ref("product.product_product_9") cls.product3 = cls.env.ref("product.product_product_11") + # Picking Type + cls.picking_type1 = cls.env.ref("stock.picking_type_in") # Purchase Type cls.type1 = cls.env.ref("purchase_order_type.po_type_regular") cls.type2 = cls.env.ref("purchase_order_type.po_type_planned") + cls.type2.write({"picking_type_id": cls.picking_type1.id}) # Payment Term cls.payterm = cls.env.ref("account.account_payment_term_immediate") # Incoterm @@ -42,6 +45,7 @@ def test_purchase_order_type(self): self.assertFalse(purchase.payment_term_id) purchase.onchange_partner_id() self.assertEqual(purchase.order_type, self.type2) + self.assertEqual(purchase.picking_type_id, self.picking_type1) purchase.onchange_order_type() self.assertEqual(purchase.incoterm_id, self.incoterm) self.assertEqual(purchase.payment_term_id, self.payterm) @@ -74,6 +78,7 @@ def test_purchase_order_change_company(self): order = self.po_obj.new({"partner_id": self.partner1.id}) order.onchange_partner_id() self.assertEqual(order.order_type, self.type2) + self.assertEqual(order.picking_type_id, self.picking_type1) order._onchange_company() self.assertEqual(order.order_type, order._default_order_type()) diff --git a/purchase_order_type/views/view_purchase_order_type.xml b/purchase_order_type/views/view_purchase_order_type.xml index c28bfd046f9..bd2545e8bf1 100644 --- a/purchase_order_type/views/view_purchase_order_type.xml +++ b/purchase_order_type/views/view_purchase_order_type.xml @@ -37,6 +37,7 @@ +