From d57b726d97dc174d86aeb64cd70de95df66bb185 Mon Sep 17 00:00:00 2001 From: cubells Date: Fri, 5 Oct 2018 10:09:42 +0200 Subject: [PATCH] [MIG] account_payment_purchase: Migration to 11.0 --- account_payment_purchase/README.rst | 85 ++-- account_payment_purchase/__init__.py | 1 - account_payment_purchase/__manifest__.py | 5 +- account_payment_purchase/models/__init__.py | 5 +- .../models/account_invoice.py | 3 +- ...ocurement_order.py => procurement_rule.py} | 14 +- .../models/purchase_order.py | 1 - .../readme/CONTRIBUTORS.rst | 9 + .../readme/DESCRIPTION.rst | 8 + account_payment_purchase/readme/INSTALL.rst | 6 + account_payment_purchase/readme/USAGE.rst | 10 + .../static/description/index.html | 457 ++++++++++++++++++ account_payment_purchase/tests/__init__.py | 1 - .../tests/test_account_payment_purchase.py | 49 +- 14 files changed, 582 insertions(+), 72 deletions(-) rename account_payment_purchase/models/{procurement_order.py => procurement_rule.py} (57%) create mode 100644 account_payment_purchase/readme/CONTRIBUTORS.rst create mode 100644 account_payment_purchase/readme/DESCRIPTION.rst create mode 100644 account_payment_purchase/readme/INSTALL.rst create mode 100644 account_payment_purchase/readme/USAGE.rst create mode 100644 account_payment_purchase/static/description/index.html diff --git a/account_payment_purchase/README.rst b/account_payment_purchase/README.rst index f5d7031e2..140059f7a 100644 --- a/account_payment_purchase/README.rst +++ b/account_payment_purchase/README.rst @@ -1,11 +1,30 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ======================== Account Payment Purchase ======================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/11.0/account_payment_purchase + :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-11-0/bank-payment-11-0-account_payment_purchase + :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/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module adds 2 fields on purchase orders: *Bank Account* and *Payment Mode*. These fields are copied from partner to purchase order and then from purchase order to supplier invoice. @@ -15,20 +34,21 @@ is that it doesn't depend on the *account_payment_extension* module (it's not the only module to conflict with *account_payment_extension*; all the SEPA modules in the banking addons conflict with *account_payment_extension*). +**Table of contents** + +.. contents:: + :local: + Installation ============ This module depends on : + - purchase - account_payment_partner This module is part of the OCA/bank-payment suite. -Configuration -============= - -There is nothing to configure. - Usage ===== @@ -43,48 +63,51 @@ Invoices without any payment mode are displayed too. This module doesn't add any feature, but it is used by several other modules. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/173/9.0 - -Known issues / Roadmap -====================== - - * No known issues. - Bug Tracker =========== -Bugs are tracked on `GitHub 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. +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Contributors ------------- +Authors +~~~~~~~ + +* Akretion +* Tecnativa + +Contributors +~~~~~~~~~~~~ -* Pedro M. Baeza * Alexis de Lattre * Alexandre Fayolle * Danimar Ribeiro * Raphaël Valyi -* Vicent Cubells * Abraham Anes +* `Tecnativa `_: -Maintainer ----------- + * Pedro M. Baeza + * Vicent Cubells + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/bank-payment `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_purchase/__init__.py b/account_payment_purchase/__init__.py index 59f15b0fb..af735bf88 100644 --- a/account_payment_purchase/__init__.py +++ b/account_payment_purchase/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Akretion (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/account_payment_purchase/__manifest__.py b/account_payment_purchase/__manifest__.py index bd5c1ce5b..0cb237613 100644 --- a/account_payment_purchase/__manifest__.py +++ b/account_payment_purchase/__manifest__.py @@ -1,18 +1,17 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Akretion (). # Copyright 2017 Tecnativa - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Account Payment Purchase', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': "Adds Bank Account and Payment Mode on Purchase Orders", 'author': "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)", - 'website': 'http://www.akretion.com', + 'website': 'https://github.com/OCA/bank-payment', 'depends': [ 'purchase', 'account_payment_partner' diff --git a/account_payment_purchase/models/__init__.py b/account_payment_purchase/models/__init__.py index 29a6c4cc8..8c3bb2f57 100644 --- a/account_payment_purchase/models/__init__.py +++ b/account_payment_purchase/models/__init__.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Akretion (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import procurement_order -from . import purchase_order from . import account_invoice +from . import purchase_order +from . import procurement_rule diff --git a/account_payment_purchase/models/account_invoice.py b/account_payment_purchase/models/account_invoice.py index 98ebafee8..03a793159 100644 --- a/account_payment_purchase/models/account_invoice.py +++ b/account_payment_purchase/models/account_invoice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Akretion (). # Copyright 2017 Tecnativa - Vicent Cubells. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -21,6 +20,7 @@ class AccountInvoice(models.Model): 'payment mode.'), } return res + self.payment_mode_id = new_mode if self.partner_bank_id and self.partner_bank_id.id != new_bank: res['warning'] = { 'title': _('Warning'), @@ -28,5 +28,4 @@ class AccountInvoice(models.Model): 'supplier bank.'), } return res - self.payment_mode_id = new_mode self.partner_bank_id = new_bank diff --git a/account_payment_purchase/models/procurement_order.py b/account_payment_purchase/models/procurement_rule.py similarity index 57% rename from account_payment_purchase/models/procurement_order.py rename to account_payment_purchase/models/procurement_rule.py index 6d1aa687d..a94adf3d4 100644 --- a/account_payment_purchase/models/procurement_order.py +++ b/account_payment_purchase/models/procurement_rule.py @@ -1,17 +1,17 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import api, models +from odoo import models -class ProcurementOrder(models.Model): - _inherit = "procurement.order" +class ProcurementRule(models.Model): + _inherit = "procurement.rule" - @api.multi - def _prepare_purchase_order(self, partner): + def _prepare_purchase_order(self, product_id, product_qty, product_uom, + origin, values, partner): """Propagate payment mode on MTO/drop shipping.""" - values = super(ProcurementOrder, self)._prepare_purchase_order(partner) + values = super(ProcurementRule, self)._prepare_purchase_order( + product_id, product_qty, product_uom, origin, values, partner) if partner: values['payment_mode_id'] = partner.with_context( force_company=self.company_id.id).supplier_payment_mode_id.id diff --git a/account_payment_purchase/models/purchase_order.py b/account_payment_purchase/models/purchase_order.py index 07cbed0af..b61e2ac85 100644 --- a/account_payment_purchase/models/purchase_order.py +++ b/account_payment_purchase/models/purchase_order.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Akretion (). # Copyright 2017 Tecnativa - Vicent Cubells. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/account_payment_purchase/readme/CONTRIBUTORS.rst b/account_payment_purchase/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a4a055436 --- /dev/null +++ b/account_payment_purchase/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* Alexis de Lattre +* Alexandre Fayolle +* Danimar Ribeiro +* Raphaël Valyi +* Abraham Anes +* `Tecnativa `_: + + * Pedro M. Baeza + * Vicent Cubells diff --git a/account_payment_purchase/readme/DESCRIPTION.rst b/account_payment_purchase/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8af2e48df --- /dev/null +++ b/account_payment_purchase/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This module adds 2 fields on purchase orders: *Bank Account* and *Payment +Mode*. These fields are copied from partner to purchase order and then from +purchase order to supplier invoice. + +This module is similar to the *purchase_payment* module; the main difference +is that it doesn't depend on the *account_payment_extension* module (it's not +the only module to conflict with *account_payment_extension*; all the SEPA +modules in the banking addons conflict with *account_payment_extension*). diff --git a/account_payment_purchase/readme/INSTALL.rst b/account_payment_purchase/readme/INSTALL.rst new file mode 100644 index 000000000..09b853841 --- /dev/null +++ b/account_payment_purchase/readme/INSTALL.rst @@ -0,0 +1,6 @@ +This module depends on : + +- purchase +- account_payment_partner + +This module is part of the OCA/bank-payment suite. diff --git a/account_payment_purchase/readme/USAGE.rst b/account_payment_purchase/readme/USAGE.rst new file mode 100644 index 000000000..82c03448a --- /dev/null +++ b/account_payment_purchase/readme/USAGE.rst @@ -0,0 +1,10 @@ +You are able to add a payment mode directly on a partner. +This payment mode is automatically associated to the purchase order, then on +related invoice. +This default value could be change in a draft purchase or draft invoice. +When you create a payment order, only invoices related to chosen payment mode +are displayed. +Invoices without any payment mode are displayed too. + + +This module doesn't add any feature, but it is used by several other modules. diff --git a/account_payment_purchase/static/description/index.html b/account_payment_purchase/static/description/index.html new file mode 100644 index 000000000..fd900a30f --- /dev/null +++ b/account_payment_purchase/static/description/index.html @@ -0,0 +1,457 @@ + + + + + + +Account Payment Purchase + + + +
+

Account Payment Purchase

+ + +

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

+

This module adds 2 fields on purchase orders: Bank Account and Payment +Mode. These fields are copied from partner to purchase order and then from +purchase order to supplier invoice.

+

This module is similar to the purchase_payment module; the main difference +is that it doesn’t depend on the account_payment_extension module (it’s not +the only module to conflict with account_payment_extension; all the SEPA +modules in the banking addons conflict with account_payment_extension).

+

Table of contents

+ +
+

Installation

+

This module depends on :

+
    +
  • purchase
  • +
  • account_payment_partner
  • +
+

This module is part of the OCA/bank-payment suite.

+
+
+

Usage

+

You are able to add a payment mode directly on a partner. +This payment mode is automatically associated to the purchase order, then on +related invoice. +This default value could be change in a draft purchase or draft invoice. +When you create a payment order, only invoices related to chosen payment mode +are displayed. +Invoices without any payment mode are displayed too.

+

This module doesn’t add any feature, but it is used by several other modules.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_payment_purchase/tests/__init__.py b/account_payment_purchase/tests/__init__.py index 5af37be3f..172df56fa 100644 --- a/account_payment_purchase/tests/__init__.py +++ b/account_payment_purchase/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2013-2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html diff --git a/account_payment_purchase/tests/test_account_payment_purchase.py b/account_payment_purchase/tests/test_account_payment_purchase.py index c610daf56..2f28e48c4 100644 --- a/account_payment_purchase/tests/test_account_payment_purchase.py +++ b/account_payment_purchase/tests/test_account_payment_purchase.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # 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 @@ -55,8 +54,8 @@ class TestAccountPaymentPurchase(common.SavepointCase): self.purchase.button_confirm() picking = self.purchase.picking_ids[0] picking.force_assign() - picking.pack_operation_product_ids.write({'qty_done': 1.0}) - picking.do_new_transfer() + picking.move_lines.write({'quantity_done': 1.0}) + picking.do_transfer() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, @@ -76,8 +75,8 @@ class TestAccountPaymentPurchase(common.SavepointCase): self.purchase.button_confirm() picking = self.purchase.picking_ids[0] picking.force_assign() - picking.pack_operation_product_ids.write({'qty_done': 1.0}) - picking.do_new_transfer() + picking.move_lines.write({'quantity_done': 1.0}) + picking.do_transfer() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, @@ -92,8 +91,8 @@ class TestAccountPaymentPurchase(common.SavepointCase): purchase2.button_confirm() picking = purchase2.picking_ids[0] picking.force_assign() - picking.pack_operation_product_ids.write({'qty_done': 1.0}) - picking.do_new_transfer() + picking.move_lines.write({'quantity_done': 1.0}) + picking.do_transfer() invoice.purchase_id = purchase2.id result = invoice.purchase_order_change() self.assertEqual(result['warning']['title'], 'Warning') @@ -109,14 +108,16 @@ class TestAccountPaymentPurchase(common.SavepointCase): self.purchase.button_confirm() picking = self.purchase.picking_ids[0] picking.force_assign() - picking.pack_operation_product_ids.write({'qty_done': 1.0}) - picking.do_new_transfer() + picking.move_lines.write({'quantity_done': 1.0}) + picking.do_transfer() invoice = self.env['account.invoice'].create({ 'partner_id': self.partner.id, 'purchase_id': self.purchase.id, 'account_id': self.partner.property_account_payable_id.id, }) + # Avoid bank company from default_get method + invoice.partner_bank_id = False invoice.purchase_order_change() self.assertEqual(invoice.partner_bank_id, self.bank) purchase2 = self.purchase.copy() @@ -124,8 +125,8 @@ class TestAccountPaymentPurchase(common.SavepointCase): purchase2.button_confirm() picking = purchase2.picking_ids[0] picking.force_assign() - picking.pack_operation_product_ids.write({'qty_done': 1.0}) - picking.do_new_transfer() + picking.move_lines.write({'quantity_done': 1.0}) + picking.do_transfer() invoice.purchase_id = purchase2.id result = invoice.purchase_order_change() self.assertEqual(result['warning']['title'], 'Warning') @@ -134,15 +135,17 @@ class TestAccountPaymentPurchase(common.SavepointCase): route = self.env.ref('purchase.route_warehouse0_buy') rule = self.env['procurement.rule'].search( [('route_id', '=', route.id)], limit=1) - procurement_order = self.env['procurement.order'].create({ - 'product_id': self.mto_product.id, - 'rule_id': rule.id, - 'location_id': self.env['stock.location'].search([], limit=1).id, - 'warehouse_id': self.env['stock.warehouse'].search([], limit=1).id, - 'product_qty': 1, - 'product_uom': self.mto_product.uom_id.id, - 'name': 'Procurement order test', - }) - procurement_order.run() - self.assertEqual( - procurement_order.purchase_id.payment_mode_id, self.payment_mode) + rule._run_buy( + product_id=self.mto_product, + product_qty=1, + product_uom=self.mto_product.uom_id, + location_id=self.env['stock.location'].search([], limit=1), + name='Procurement order test', + origin='Test', + values={ + 'company_id': self.env.user.company_id, + 'date_planned': fields.Datetime.now(), + }, + ) + purchase = self.env['purchase.order'].search([('origin', '=', 'Test')]) + self.assertEqual(purchase.payment_mode_id, self.payment_mode)