Skip to content

Commit

Permalink
[14.0][IMP] purchase_order_type: picking_type_id
Browse files Browse the repository at this point in the history
Add a new functionality to add picking types in pruchase orders when changing the picking order type
  • Loading branch information
Reyes4711-S73 committed Jan 2, 2023
1 parent 1ab6f68 commit 24c7688
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 50 deletions.
3 changes: 2 additions & 1 deletion purchase_order_type/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Purchase Order Type
:target: https://runbot.odoo-community.org/runbot/142/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|

Adds a configurable *type* on the purchase orders.
This type can be used in filters and groupbys.
Expand Down Expand Up @@ -76,6 +76,7 @@ Contributors

* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Carlos Reyes <carlos@studio73.es>

Maintainers
~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions purchase_order_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

{
"name": "Purchase Order Type",
"version": "14.0.1.0.2",
"version": "14.0.1.1.0",
"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",
Expand Down
73 changes: 27 additions & 46 deletions purchase_order_type/i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_order_type
# * purchase_order_type
#
# Translators:
# Ahmet Altinisik <aaltinisik@altinkaya.com.tr>, 2016
# Ahmet Altinisik <aaltinisik@altinkaya.com.tr>, 2016
# Antonio Trueba, 2016
# Armando Vulcano Junior <vulcano@uol.com.br>, 2015
# Carles Antoli <carlesantoli@hotmail.com>, 2015
# Carles Antoli <carlesantoli@hotmail.com>, 2015
# danimaribeiro <danimaribeiro@gmail.com>, 2016
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012
# Kostas Goutoudis <goutoudis@gmail.com>, 2015
# Kostas Goutoudis <goutoudis@gmail.com>, 2015
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015-2016
# Paolo Valier, 2016
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2015
# Rudolf Schnapka <rs@techno-flex.de>, 2016
# SaFi J. <safi2266@gmail.com>, 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: 2016-11-25 14:55+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-purchase-"
"workflow-8-0/language/es/)\n"
"Language: es\n"
"POT-Creation-Date: 2023-01-02 07:41+0000\n"
"PO-Revision-Date: 2023-01-02 07:41+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: nplurals=2; plural=(n != 1);\n"
"Plural-Forms: \n"

#. module: purchase_order_type
#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__active
Expand All @@ -46,18 +28,18 @@ msgstr ""
#. module: purchase_order_type
#: model_terms:ir.actions.act_window,help:purchase_order_type.action_purchase_order_type_view
msgid "Click to set a new type for purchase order."
msgstr ""
msgstr "Haz click para fijar un nuevo tipo para los pedidos de compra"

#. module: purchase_order_type
#: 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 ""
msgstr "Compañía"

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

#. module: purchase_order_type
#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__create_uid
Expand All @@ -72,7 +54,7 @@ msgstr "Creado en"
#. module: purchase_order_type
#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order_type__description
msgid "Description"
msgstr ""
msgstr "Descripción"

#. module: purchase_order_type
#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order__display_name
Expand All @@ -83,27 +65,28 @@ 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 ""
msgstr "Documentos de la compañía y tipos de compañía no coinciden"

#. module: purchase_order_type
#: 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 ""
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 ""
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
Expand Down Expand Up @@ -136,37 +119,42 @@ 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 ""
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 ""
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 ""
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
#: model_terms:ir.ui.view,arch_db:purchase_order_type.view_purchase_order_type_tree
msgid "Purchase Order Types"
msgstr ""
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
msgid "Sequence"
msgstr ""
msgstr "Secuencia"

#. module: purchase_order_type
#: model:ir.model.fields,field_description:purchase_order_type.field_purchase_order__order_type
Expand All @@ -177,12 +165,5 @@ msgstr "Tipo"

#. module: purchase_order_type
#: model:ir.model,name:purchase_order_type.model_purchase_order_type
#, fuzzy
msgid "Type of purchase order"
msgstr "Orden de Compra"

#~ msgid "Create Invoice"
#~ msgstr "Crear factura"

#~ msgid "Partner"
#~ msgstr "Empresa"
8 changes: 8 additions & 0 deletions purchase_order_type/i18n/purchase_order_type.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -143,6 +146,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"
Expand Down
11 changes: 10 additions & 1 deletion purchase_order_type/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -63,3 +70,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
3 changes: 3 additions & 0 deletions purchase_order_type/models/purchase_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
1 change: 1 addition & 0 deletions purchase_order_type/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Carlos Reyes <carlos@studio73.es>
5 changes: 5 additions & 0 deletions purchase_order_type/tests/test_purchase_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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())

Expand Down
1 change: 1 addition & 0 deletions purchase_order_type/views/view_purchase_order_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<group>
<group>
<field name="sequence_id" />
<field name="picking_type_id" />
<field
name="company_id"
groups="base.group_multi_company"
Expand Down

0 comments on commit 24c7688

Please sign in to comment.