Split account_payment_purchase (add account_payment_purchase_stock)

This commit is contained in:
Andrea
2019-05-21 09:32:24 +02:00
committed by mreficent
parent fbdfb3db4b
commit 8b5f61beb7
20 changed files with 283 additions and 66 deletions

View File

@@ -44,7 +44,7 @@ Installation
This module depends on :
- purchase_stock
- purchase
- account_payment_partner
This module is part of the OCA/bank-payment suite.
@@ -97,6 +97,7 @@ Contributors
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Andrea Stirpe <a.stirpe@onestein.nl>
Maintainers
~~~~~~~~~~~

View File

@@ -1,4 +1,3 @@
# Copyright 2016 Akretion (<http://www.akretion.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@@ -10,7 +10,7 @@
"summary": "Adds Bank Account and Payment Mode on Purchase Orders",
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-payment",
"depends": ["account_payment_partner", "purchase_stock"],
"depends": ["account_payment_partner", "purchase"],
"data": ["views/purchase_order_view.xml"],
"installable": True,
"auto_install": True,

View File

@@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice, purchase_order, stock_rule
from . import account_invoice, purchase_order

View File

@@ -10,3 +10,4 @@
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Andrea Stirpe <a.stirpe@onestein.nl>

View File

@@ -1,6 +1,6 @@
This module depends on :
- purchase_stock
- purchase
- account_payment_partner
This module is part of the OCA/bank-payment suite.

View File

@@ -393,7 +393,7 @@ modules in the banking addons conflict with <em>account_payment_extension</em>).
<h1><a class="toc-backref" href="#id1">Installation</a></h1>
<p>This module depends on :</p>
<ul class="simple">
<li>purchase_stock</li>
<li>purchase</li>
<li>account_payment_partner</li>
</ul>
<p>This module is part of the OCA/bank-payment suite.</p>
@@ -441,6 +441,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</li>
<li>Nikul Chaudhary &lt;<a class="reference external" href="mailto:nikulchaudhary2112&#64;gmail.com">nikulchaudhary2112&#64;gmail.com</a>&gt;</li>
<li>Miquel Raïch &lt;<a class="reference external" href="mailto:miquel.raich&#64;forgeflow.com">miquel.raich&#64;forgeflow.com</a>&gt;</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">

View File

@@ -44,7 +44,6 @@ class TestAccountPaymentPurchase(SavepointCase):
cls.mto_product = cls.env["product.product"].create(
{
"name": "Test buy product",
"type": "product",
"uom_id": cls.uom_id,
"uom_po_id": cls.uom_id,
"seller_ids": [(0, 0, {"name": cls.partner.id})],
@@ -77,10 +76,6 @@ class TestAccountPaymentPurchase(SavepointCase):
def test_purchase_order_invoicing(self):
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
@@ -91,17 +86,11 @@ class TestAccountPaymentPurchase(SavepointCase):
self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode
)
def test_picking_from_purchase_order_invoicing(self):
def test_from_purchase_order_invoicing(self):
# Test payment mode
stockable_product = self.env["product.product"].create(
{"name": "Test stockable product", "type": "product"}
)
self.purchase.order_line[0].product_id = stockable_product
product = self.env["product.product"].create({"name": "Test product"})
self.purchase.order_line[0].product_id = product
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
@@ -113,29 +102,20 @@ class TestAccountPaymentPurchase(SavepointCase):
payment_mode2 = self.payment_mode.copy()
purchase2.payment_mode_id = payment_mode2
purchase2.button_confirm()
picking = purchase2.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice.purchase_id = purchase2
result = invoice._onchange_purchase_auto_complete()
self.assertEqual(
result and result.get("warning", {}).get("title", False), "Warning"
)
def test_picking_from_purchase_order_invoicing_bank(self):
def test_from_purchase_order_invoicing_bank(self):
# Test partner_bank
stockable_product = self.env["product.product"].create(
{"name": "Test stockable product", "type": "product"}
)
self.purchase.order_line[0].product_id = stockable_product
product = self.env["product.product"].create({"name": "Test product"})
self.purchase.order_line[0].product_id = product
self.purchase.payment_mode_id = False
self.purchase.supplier_partner_bank_id = self.bank
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
@@ -146,38 +126,9 @@ class TestAccountPaymentPurchase(SavepointCase):
purchase2 = self.purchase.copy()
purchase2.supplier_partner_bank_id = self.bank2
purchase2.button_confirm()
picking = purchase2.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice.purchase_id = purchase2
result = invoice._onchange_purchase_auto_complete()
self.assertEqual(
result and result.get("warning", {}).get("title", False), "Warning"
)
def test_procurement_buy_payment_mode(self):
route = self.env.ref("purchase_stock.route_warehouse0_buy")
rule = self.env["stock.rule"].search([("route_id", "=", route.id)], limit=1)
rule._run_buy(
procurements=[
(
self.env["procurement.group"].Procurement(
self.mto_product,
1,
self.mto_product.uom_id,
self.env["stock.location"].search([], limit=1),
"Procurement order test",
"Test",
rule.company_id,
{
"company_id": rule.company_id,
"date_planned": fields.Datetime.now(),
},
),
rule,
)
]
)
purchase = self.env["purchase.order"].search([("origin", "=", "Test")])
self.assertEqual(purchase.payment_mode_id, self.payment_mode)

View File

@@ -0,0 +1,101 @@
==============================
Account Payment Purchase Stock
==============================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
:target: https://github.com/OCA/bank-payment/tree/13.0/account_payment_purchase_stock
:alt: OCA/bank-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-payment-13-/bank-payment-13--account_payment_purchase_stock
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/97/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module combines the *account_payment_purchase* module with *purchase_stock*.
**Table of contents**
.. contents::
:local:
Installation
============
This module depends on :
- purchase_stock
- account_payment_purchase
This module is part of the OCA/bank-payment suite.
Usage
=====
This module doesn't add any feature, but it is used by several other modules.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_purchase_stock%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Akretion
* Tecnativa
Contributors
~~~~~~~~~~~~
* Alexis de Lattre
* Alexandre Fayolle
* Danimar Ribeiro
* Raphaël Valyi
* Abraham Anes <abraham@studio73.es>
* `Tecnativa <https://www.tecnativa.com>`_:
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Andrea Stirpe <a.stirpe@onestein.nl>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/13.0/account_payment_purchase_stock>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@@ -0,0 +1,16 @@
# Copyright 2016 Akretion (<http://www.akretion.com>).
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Payment Purchase Stock",
"version": "13.0.1.0.0",
"category": "Banking addons",
"license": "AGPL-3",
"summary": "Integrate Account Payment Purchase with Stock",
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-payment",
"depends": ["account_payment_purchase", "purchase_stock"],
"installable": True,
"auto_install": True,
}

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import stock_rule

View File

@@ -9,9 +9,7 @@ class StockRule(models.Model):
def _prepare_purchase_order(self, company_id, origins, values):
"""Propagate payment mode on MTO/drop shipping."""
res = super(StockRule, self)._prepare_purchase_order(
company_id, origins, values
)
res = super()._prepare_purchase_order(company_id, origins, values)
values = values[0]
partner = values["supplier"].name
if partner:

View File

@@ -0,0 +1,13 @@
* Alexis de Lattre
* Alexandre Fayolle
* Danimar Ribeiro
* Raphaël Valyi
* Abraham Anes <abraham@studio73.es>
* `Tecnativa <https://www.tecnativa.com>`_:
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
* Miquel Raïch <miquel.raich@forgeflow.com>
* Andrea Stirpe <a.stirpe@onestein.nl>

View File

@@ -0,0 +1 @@
This module combines the *account_payment_purchase* module with *purchase_stock*.

View File

@@ -0,0 +1,6 @@
This module depends on :
- purchase_stock
- account_payment_purchase
This module is part of the OCA/bank-payment suite.

View File

@@ -0,0 +1 @@
This module doesn't add any feature, but it is used by several other modules.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_account_payment_purchase_stock

View File

@@ -0,0 +1,119 @@
# Copyright 2013-2015 Tecnativa - Pedro M. Baeza
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import fields
from odoo.tests import Form
from odoo.addons.account_payment_purchase.tests.test_account_payment_purchase import (
TestAccountPaymentPurchase,
)
class TestAccountPaymentPurchaseStock(TestAccountPaymentPurchase):
def test_purchase_stock_order_invoicing(self):
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
)
with Form(invoice) as inv:
inv.purchase_id = self.purchase
self.assertEqual(
self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode
)
def test_picking_from_purchase_order_invoicing(self):
# Test payment mode
stockable_product = self.env["product.product"].create(
{"name": "Test stockable product", "type": "product"}
)
self.purchase.order_line[0].product_id = stockable_product
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
)
invoice.purchase_id = self.purchase
invoice._onchange_purchase_auto_complete()
self.assertEqual(invoice.payment_mode_id, self.payment_mode)
purchase2 = self.purchase.copy()
payment_mode2 = self.payment_mode.copy()
purchase2.payment_mode_id = payment_mode2
purchase2.button_confirm()
picking = purchase2.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice.purchase_id = purchase2
result = invoice._onchange_purchase_auto_complete()
self.assertEqual(
result and result.get("warning", {}).get("title", False), "Warning"
)
def test_picking_from_purchase_order_invoicing_bank(self):
# Test partner_bank
stockable_product = self.env["product.product"].create(
{"name": "Test stockable product", "type": "product"}
)
self.purchase.order_line[0].product_id = stockable_product
self.purchase.payment_mode_id = False
self.purchase.supplier_partner_bank_id = self.bank
self.purchase.button_confirm()
picking = self.purchase.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice = self.env["account.move"].create(
{"partner_id": self.partner.id, "type": "in_invoice"}
)
invoice.purchase_id = self.purchase
invoice._onchange_purchase_auto_complete()
self.assertEqual(invoice.invoice_partner_bank_id, self.bank)
purchase2 = self.purchase.copy()
purchase2.supplier_partner_bank_id = self.bank2
purchase2.button_confirm()
picking = purchase2.picking_ids[0]
picking.action_confirm()
picking.move_lines.write({"quantity_done": 1.0})
picking.button_validate()
invoice.purchase_id = purchase2
result = invoice._onchange_purchase_auto_complete()
self.assertEqual(
result and result.get("warning", {}).get("title", False), "Warning"
)
def test_stock_rule_buy_payment_mode(self):
route = self.env.ref("purchase_stock.route_warehouse0_buy")
rule = self.env["stock.rule"].search([("route_id", "=", route.id)], limit=1)
rule._run_buy(
procurements=[
(
self.env["procurement.group"].Procurement(
self.mto_product,
1,
self.mto_product.uom_id,
self.env["stock.location"].search([], limit=1),
"Procurement order test",
"Test",
rule.company_id,
{
"company_id": rule.company_id,
"date_planned": fields.Datetime.now(),
},
),
rule,
)
]
)
purchase = self.env["purchase.order"].search([("origin", "=", "Test")])
self.assertEqual(purchase.payment_mode_id, self.payment_mode)