[MIG] account_payment_sale: Migrate to 11.0

This commit is contained in:
Artem Kostyuk
2017-12-19 17:45:19 +02:00
parent 331ad9c954
commit 2f7a69c492
8 changed files with 21 additions and 40 deletions

View File

@@ -33,17 +33,12 @@ Usage
=====
You are able to add a payment mode directly on a partner.
This payment mode is automatically associated to the sale order, then on related invoice.
This default value could be change in a draft sale order or draft invoice.
This payment mode is automatically associated to the sale order, then on related invoice.
This default value can be changed in a draft sale order or draft invoice.
.. 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.
:target: https://runbot.odoo-community.org/runbot/173/11.0
Bug Tracker
===========

View File

@@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard

View File

@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (http://www.akretion.com)
# Copyright 2014-2016 Akretion (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
{
'name': 'Account Payment Sale',
'version': '10.0.1.1.0',
'version': '11.0.1.0.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Adds payment mode on sale orders",
@@ -17,11 +16,9 @@
'sale',
'account_payment_partner',
],
'conflicts': ['sale_payment'],
'data': [
'views/sale_order_view.xml',
'views/sale_report_templates.xml',
],
'installable': True,
'auto_install': True,
}

View File

@@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import sale_order

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2014-2016 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
@@ -12,9 +11,17 @@ class SaleOrder(models.Model):
'account.payment.mode', string='Payment Mode',
domain=[('payment_type', '=', 'inbound')])
def _get_payment_mode_vals(self, vals):
if self.payment_mode_id:
vals['payment_mode_id'] = self.payment_mode_id.id
if self.payment_mode_id.bank_account_link == 'fixed':
vals['partner_bank_id'] =\
self.payment_mode_id.fixed_journal_id.bank_account_id.id
return vals
@api.onchange('partner_id')
def onchange_partner_id(self):
res = super(SaleOrder, self).onchange_partner_id()
res = super().onchange_partner_id()
if self.partner_id:
self.payment_mode_id = self.partner_id.customer_payment_mode_id
else:
@@ -24,10 +31,5 @@ class SaleOrder(models.Model):
@api.multi
def _prepare_invoice(self):
"""Copy bank partner from sale order to invoice"""
vals = super(SaleOrder, self)._prepare_invoice()
if self.payment_mode_id:
vals['payment_mode_id'] = self.payment_mode_id.id
if self.payment_mode_id.bank_account_link == 'fixed':
vals['partner_bank_id'] =\
self.payment_mode_id.fixed_journal_id.bank_account_id.id
return vals
vals = super()._prepare_invoice()
return self._get_payment_mode_vals(vals)

View File

@@ -3,7 +3,7 @@
<template id="report_sale_payment_mode" inherit_id="sale.report_saleorder_document">
<xpath expr="//p[@t-if='doc.payment_term_id.note']" position="after">
<p t-if="doc.payment_mode_id.note">
<p t-if="doc.payment_mode_id.note" id="payment_mode_note">
<strong>Payment Mode:</strong>
<span t-field="doc.payment_mode_id.note" />
</p>

View File

@@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import sale_make_invoice_advance

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2016 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api
@@ -11,14 +10,8 @@ class SaleAdvancePaymentInv(models.TransientModel):
@api.multi
def _create_invoice(self, order, so_line, amount):
"""Copy payment mode from sale order to invoice"""
inv = super(SaleAdvancePaymentInv, self)._create_invoice(
order, so_line, amount)
vals = {}
if order.payment_mode_id:
vals['payment_mode_id'] = order.payment_mode_id.id
if order.payment_mode_id.bank_account_link == 'fixed':
vals['partner_bank_id'] =\
order.payment_mode_id.fixed_journal_id.bank_account_id.id
inv = super()._create_invoice(order, so_line, amount)
vals = order._get_payment_mode_vals({})
if vals:
inv.write(vals)
return inv