From f01ae7b937f6e1d878cb15b7ff476ef885697f7f Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Wed, 1 Feb 2023 12:39:31 -0300 Subject: [PATCH] [FIX] contract_payment_mode: set default payment mode by contract type --- contract_payment_mode/README.rst | 15 ++++--- contract_payment_mode/__manifest__.py | 2 +- contract_payment_mode/models/contract.py | 6 ++- .../static/description/index.html | 42 ++++++++++--------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/contract_payment_mode/README.rst b/contract_payment_mode/README.rst index 190926f23..6eb9f346b 100644 --- a/contract_payment_mode/README.rst +++ b/contract_payment_mode/README.rst @@ -2,10 +2,13 @@ Contract Payment Mode ===================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b0c3f63c4d845960be5d0e10a987897276ccdd53fe4a54d417bd64884c7377f6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,11 +22,11 @@ Contract Payment Mode .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/contract-15-0/contract-15-0-contract_payment_mode :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/110/15.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to set a payment mode on contract for creating the invoices with this payment mode. @@ -56,7 +59,7 @@ 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 +If you spotted it first, help us to smash it by providing a detailed and welcomed `feedback `_. Do not contact contributors directly about support or help with technical issues. diff --git a/contract_payment_mode/__manifest__.py b/contract_payment_mode/__manifest__.py index cae8f0b2c..d7e8ee136 100644 --- a/contract_payment_mode/__manifest__.py +++ b/contract_payment_mode/__manifest__.py @@ -9,7 +9,7 @@ { "name": "Contract Payment Mode", "summary": "Payment mode in contracts and their invoices", - "version": "15.0.1.1.0", + "version": "15.0.1.1.1", "author": "Domatix, " "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/contract", "depends": ["contract", "account_payment_partner"], diff --git a/contract_payment_mode/models/contract.py b/contract_payment_mode/models/contract.py index 8041d6b4d..d5c6f6ef9 100644 --- a/contract_payment_mode/models/contract.py +++ b/contract_payment_mode/models/contract.py @@ -13,7 +13,11 @@ class ContractContract(models.Model): @api.onchange("partner_id") def on_change_partner_id(self): - self.payment_mode_id = self.partner_id.customer_payment_mode_id.id + partner = self.with_company(self.company_id).partner_id + if self.contract_type == "purchase": + self.payment_mode_id = partner.supplier_payment_mode_id.id + else: + self.payment_mode_id = partner.customer_payment_mode_id.id def _prepare_invoice(self, date_invoice, journal=None): invoice_vals, move_form = super()._prepare_invoice( diff --git a/contract_payment_mode/static/description/index.html b/contract_payment_mode/static/description/index.html index 25e4e1e7b..99081d53e 100644 --- a/contract_payment_mode/static/description/index.html +++ b/contract_payment_mode/static/description/index.html @@ -1,20 +1,20 @@ - + - + Contract Payment Mode