Skip to content

Commit 9e53b74

Browse files
[IMP] purchase_sale_stock_inter_company: make pickings link configurable
1 parent 64527ea commit 9e53b74

File tree

6 files changed

+129
-95
lines changed

6 files changed

+129
-95
lines changed
Lines changed: 33 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
# Translation of Odoo Server.
22
# This file contains the translation of the following modules:
3-
# * purchase_sale_stock_inter_company
3+
# * purchase_sale_stock_inter_company
44
#
5-
# Translators:
6-
# OCA Transbot <[email protected]>, 2017
75
msgid ""
86
msgstr ""
9-
"Project-Id-Version: Odoo Server 8.0\n"
7+
"Project-Id-Version: Odoo Server 16.0\n"
108
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2022-08-05 13:15+0000\n"
12-
"PO-Revision-Date: 2023-12-21 23:45+0000\n"
13-
"Last-Translator: Ivorra78 <[email protected]>\n"
14-
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
15-
"Language: es\n"
9+
"POT-Creation-Date: 2025-02-17 10:00+0000\n"
10+
"PO-Revision-Date: 2025-02-17 10:00+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
1613
"MIME-Version: 1.0\n"
1714
"Content-Type: text/plain; charset=UTF-8\n"
18-
"Content-Transfer-Encoding: 8bit\n"
19-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
20-
"X-Generator: Weblate 4.17\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
2117

2218
#. module: purchase_sale_stock_inter_company
2319
#: model:ir.model,name:purchase_sale_stock_inter_company.model_res_company
@@ -47,17 +43,42 @@ msgstr ""
4743
"Valor por defecto a establecer en pedidos de venta que serán creados en base "
4844
"a pedidos de compra realizados a esta compañía."
4945

46+
#. module: purchase_sale_stock_inter_company
47+
#: model:ir.model.fields,help:purchase_sale_stock_inter_company.field_res_company__link_purchase_sale_picking_ids
48+
#: model:ir.model.fields,help:purchase_sale_stock_inter_company.field_res_config_settings__link_purchase_sale_picking_ids
49+
msgid ""
50+
"If checked, the pickings of the purchase and sale orders will be linked "
51+
"together. This will validate the purchase pickings when the sale pickings "
52+
"are validated."
53+
msgstr "Si está marcado, los albaranes de compra y venta se vincularán."
54+
"Eso validará los albaranes de compra cuando los albaranes de venta se validen."
55+
5056
#. module: purchase_sale_stock_inter_company
5157
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_stock_picking__intercompany_picking_id
5258
msgid "Intercompany Picking"
5359
msgstr "Albarán intercompañía"
5460

61+
#. module: purchase_sale_stock_inter_company
62+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_res_company__link_purchase_sale_picking_ids
63+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_res_config_settings__link_purchase_sale_picking_ids
64+
msgid "Link Purchase and Sale Pickings"
65+
msgstr "Vincular albaranes de compra y venta"
66+
5567
#. module: purchase_sale_stock_inter_company
5668
#: model:ir.model,name:purchase_sale_stock_inter_company.model_purchase_order
5769
msgid "Purchase Order"
5870
msgstr "Pedido de compra"
5971

6072
#. module: purchase_sale_stock_inter_company
73+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_purchase_order__smart_search
74+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_res_company__smart_search
75+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_res_config_settings__smart_search
76+
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_stock_picking__smart_search
77+
msgid "Smart Search"
78+
msgstr "Búsqueda inteligente"
79+
80+
#. module: purchase_sale_stock_inter_company
81+
#. odoo-python
6182
#: code:addons/purchase_sale_stock_inter_company/models/stock_picking.py:0
6283
#, python-format
6384
msgid ""
@@ -81,81 +102,3 @@ msgstr "Almacén para pedidos de venta"
81102
#: model:ir.model.fields,field_description:purchase_sale_stock_inter_company.field_res_config_settings__warehouse_id
82103
msgid "Warehouse for Sale Orders"
83104
msgstr "Almacén para pedidos de venta"
84-
85-
#~ msgid "Create Sale Orders when buying to this company"
86-
#~ msgstr "Crear pedido de venta al comprar a esta compañía"
87-
88-
#~ msgid ""
89-
#~ "Generate a Sale Order when a Purchase Order with this company as supplier "
90-
#~ "is created.\n"
91-
#~ " The intercompany user must at least be Sale User."
92-
#~ msgstr ""
93-
#~ "Generar un pedido de venta cuando se cree un pedido de compra con esta "
94-
#~ "compañía como proveedor.\n"
95-
#~ "El usuario intercompañía debe ser al menos Usuario de Ventas."
96-
97-
#~ msgid "Intercompany Sale User"
98-
#~ msgstr "Usuario de venta intercompañía"
99-
100-
#~ msgid "Journal Entries"
101-
#~ msgstr "Asientos contables"
102-
103-
#~ msgid "Purchase/Sale"
104-
#~ msgstr "Compra/Venta"
105-
106-
#~ msgid "Sale Orders Auto Validation"
107-
#~ msgstr "Auto confirmar pedidos de venta"
108-
109-
#~ msgid "Sale from purchase"
110-
#~ msgstr "Venta desde compra"
111-
112-
#~ msgid "Sales Order"
113-
#~ msgstr "Pedido de venta"
114-
115-
#~ msgid "Sales Order Line"
116-
#~ msgstr "Línea de pedido de venta"
117-
118-
#~ msgid "Source Purchase Order"
119-
#~ msgstr "Pedido de compra de origen"
120-
121-
#~ msgid "Source Purchase Order Line"
122-
#~ msgstr "Línea pedido de compra origen"
123-
124-
#~ msgid "This vendor bill is related with: {}"
125-
#~ msgstr "Esta factura de proveedor está relacionada con: {}"
126-
127-
#~ msgid ""
128-
#~ "User used to create the sales order arising from a purchase order in "
129-
#~ "another company."
130-
#~ msgstr ""
131-
#~ "El usuario solía crear los pedidos de venta que surgen de un pedido de "
132-
#~ "compra en otra compañía."
133-
134-
#~ msgid ""
135-
#~ "When a Sale Order is created by a multi company rule for this company, it "
136-
#~ "will automatically validate it."
137-
#~ msgstr ""
138-
#~ "Cuando un pedido de venta es creado por una regla intercompañía para esta "
139-
#~ "compañía, este sera confirmado automáticamente."
140-
141-
#~ msgid "You can't cancel an order that is %s"
142-
#~ msgstr "No puede cancelar un pedido que es %s"
143-
144-
#~ msgid ""
145-
#~ "You cannot create SO from PO because product '%s' is not intercompany"
146-
#~ msgstr ""
147-
#~ "No puede crear pedido de venta desde pedido de compra porque el producto "
148-
#~ "'%s' no es intercompañía"
149-
150-
#~ msgid ""
151-
#~ "You cannot create SO from PO because sale price list currency is "
152-
#~ "different than purchase price list currency."
153-
#~ msgstr ""
154-
#~ "No puede crear pedido de venta desde pedido de compra porque la moneda de "
155-
#~ "la tarifa de venta es distinta de la moneda de la tarifa de compra."
156-
157-
#~ msgid "Invoice"
158-
#~ msgstr "Factura"
159-
160-
#~ msgid "Quotation"
161-
#~ msgstr "Presupuesto"

purchase_sale_stock_inter_company/models/res_company.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ class ResCompany(models.Model):
1616
help="Default value to set on Sale Orders that "
1717
"will be created based on Purchase Orders made to this company",
1818
)
19+
link_purchase_sale_picking_ids = fields.Boolean(
20+
string="Link Purchase and Sale Pickings",
21+
help="If checked, the pickings of the purchase and sale "
22+
"orders will be linked together. This will validate "
23+
"the purchase pickings when the sale pickings are validated.",
24+
)

purchase_sale_stock_inter_company/models/res_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ class InterCompanyRulesConfig(models.TransientModel):
1818
"based on Purchase Orders made to this company.",
1919
readonly=False,
2020
)
21+
22+
link_purchase_sale_picking_ids = fields.Boolean(
23+
related="company_id.link_purchase_sale_picking_ids",
24+
string="Link Purchase and Sale Pickings",
25+
help="If checked, the pickings of the purchase and sale "
26+
"orders will be linked together. This will validate "
27+
"the purchase pickings when the sale pickings are validated.",
28+
readonly=False,
29+
)

purchase_sale_stock_inter_company/models/stock_picking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class StockPicking(models.Model):
1313

1414
def _action_done(self):
1515
# Only DropShip pickings
16+
if not self.env.company.link_purchase_sale_picking_ids:
17+
return super()._action_done()
1618
po_picks = self.browse()
1719
for pick in self.filtered(
1820
lambda x: x.location_dest_id.usage == "customer"

purchase_sale_stock_inter_company/tests/test_inter_company_purchase_sale_stock.py

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2018-2019 Tecnativa - Carlos Dauden
44
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
55
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
6-
6+
from odoo.tests.common import Form
77

88
from odoo.addons.purchase_sale_inter_company.tests.test_inter_company_purchase_sale import (
99
TestPurchaseSaleInterCompany,
@@ -23,9 +23,23 @@ def _create_warehouse(cls, code, company):
2323
}
2424
)
2525

26+
@classmethod
27+
def _create_purchase_order_with_product(cls, partner):
28+
po = Form(cls.env["purchase.order"])
29+
po.company_id = cls.company_a
30+
po.partner_id = partner
31+
32+
cls.product_a.invoice_policy = "order"
33+
34+
with po.order_line.new() as line_form:
35+
line_form.product_id = cls.product_a
36+
line_form.product_qty = 280
37+
return po.save()
38+
2639
@classmethod
2740
def setUpClass(cls):
2841
super().setUpClass()
42+
cls.env = cls.env(context={"test_queue_job_no_delay": 1})
2943
# Configure 2 Warehouse per company
3044
cls.warehouse_a = cls.env["stock.warehouse"].search(
3145
[("company_id", "=", cls.company_a.id)]
@@ -37,6 +51,24 @@ def setUpClass(cls):
3751
)
3852
cls.warehouse_d = cls._create_warehouse("CB-WD", cls.company_b)
3953
cls.company_b.warehouse_id = cls.warehouse_c
54+
cls.product_a = cls.env["product.product"].create(
55+
{
56+
"name": "Product A",
57+
"type": "product",
58+
"categ_id": cls.env.ref("product.product_category_all").id,
59+
}
60+
)
61+
# Configure User
62+
cls.user_company_a.groups_id += cls.env.ref("stock.group_stock_user")
63+
cls._configure_user(cls.user_company_a)
64+
cls._configure_user(cls.user_company_b)
65+
66+
# Configure Company B (the supplier)
67+
cls.company_b.so_from_po = True
68+
cls.company_b.sale_auto_validation = 1
69+
70+
cls.intercompany_sale_user_id.company_ids |= cls.company_a
71+
cls.company_b.intercompany_sale_user_id = cls.intercompany_sale_user_id
4072

4173
def test_deliver_to_warehouse_a(self):
4274
self.purchase_company_a.picking_type_id = self.warehouse_a.in_type_id
@@ -58,11 +90,49 @@ def test_send_from_warehouse_d(self):
5890
sale = self._approve_po()
5991
self.assertEqual(sale.warehouse_id, self.warehouse_d)
6092

61-
def test_purchase_sale_stock_inter_company(self):
62-
self.purchase_company_a.notes = "Test note"
63-
sale = self._approve_po()
93+
def test_purchase_sale_stock_inter_company_without_linking_pickings(self):
94+
self.partner_company_b.company_id = self.company_a
95+
purchase = self._create_purchase_order_with_product(self.partner_company_b)
96+
purchase.with_user(self.user_company_a).sudo().button_approve()
97+
sale = (
98+
self.env["sale.order"]
99+
.with_user(self.user_company_b)
100+
.search([("auto_purchase_order_id", "=", purchase.id)])
101+
)
102+
sale.action_confirm()
103+
self.assertEqual(
104+
sale.partner_shipping_id,
105+
purchase.picking_type_id.warehouse_id.partner_id,
106+
)
107+
self.assertEqual(sale.warehouse_id, self.warehouse_c)
108+
purchase_picking_id = purchase.picking_ids
109+
sale_picking_id = sale.picking_ids
110+
for move_id in sale_picking_id.move_ids:
111+
move_id.quantity_done = move_id.product_uom_qty
112+
sale_picking_id._action_done()
113+
self.assertEqual(purchase_picking_id.state, "assigned")
114+
self.assertEqual(sale_picking_id.state, "done")
115+
116+
def test_purchase_sale_stock_inter_company_linking_pickings(self):
117+
self.partner_company_b.company_id = self.company_a
118+
self.company_b.link_purchase_sale_picking_ids = True
119+
purchase = self._create_purchase_order_with_product(self.partner_company_b)
120+
purchase.with_user(self.user_company_a).sudo().button_approve()
121+
sale = (
122+
self.env["sale.order"]
123+
.with_user(self.user_company_b)
124+
.search([("auto_purchase_order_id", "=", purchase.id)])
125+
)
126+
sale.action_confirm()
64127
self.assertEqual(
65128
sale.partner_shipping_id,
66-
self.purchase_company_a.picking_type_id.warehouse_id.partner_id,
129+
purchase.picking_type_id.warehouse_id.partner_id,
67130
)
68131
self.assertEqual(sale.warehouse_id, self.warehouse_c)
132+
purchase_picking_id = purchase.picking_ids
133+
sale_picking_id = sale.picking_ids
134+
for move_id in sale_picking_id.move_ids:
135+
move_id.quantity_done = move_id.product_uom_qty
136+
sale_picking_id._action_done()
137+
self.assertEqual(purchase_picking_id.state, "done")
138+
self.assertEqual(sale_picking_id.state, "done")

purchase_sale_stock_inter_company/views/res_config_view.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
class="oe_inline"
1616
domain="[('company_id', '=', company_id)]"
1717
/>
18+
<div attrs="{'invisible': [('warehouse_id', '=', False)]}">
19+
<field name="link_purchase_sale_picking_ids" class="oe_inline" />
20+
<label for="link_purchase_sale_picking_ids" class="o_light_label" />
21+
</div>
1822
</xpath>
1923
</field>
2024
</record>

0 commit comments

Comments
 (0)