mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_sale: Migration to v9
This commit is contained in:
committed by
Atchuthan Ubendran
parent
c2f1a1377a
commit
bb45ede128
@@ -1,19 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import sale_order
|
||||
|
||||
@@ -1,24 +1,6 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Sale module for OpenERP
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields, api
|
||||
|
||||
@@ -27,24 +9,25 @@ class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
payment_mode_id = fields.Many2one(
|
||||
'payment.mode', string='Payment Mode',
|
||||
domain="[('sale_ok', '=', True)]")
|
||||
'account.payment.mode', string='Payment Mode',
|
||||
domain=[('payment_type', '=', 'inbound')])
|
||||
|
||||
@api.multi
|
||||
def onchange_partner_id(self, partner_id):
|
||||
res = super(SaleOrder, self).onchange_partner_id(partner_id)
|
||||
if partner_id:
|
||||
partner = self.env['res.partner'].browse(partner_id)
|
||||
res['value']['payment_mode_id'] = partner.customer_payment_mode.id
|
||||
@api.onchange('partner_id')
|
||||
def onchange_partner_id(self):
|
||||
res = super(SaleOrder, self).onchange_partner_id()
|
||||
if self.partner_id:
|
||||
self.payment_mode_id = self.partner_id.customer_payment_mode_id
|
||||
else:
|
||||
res['value']['payment_mode_id'] = False
|
||||
self.payment_mode_id = False
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_invoice(self, order, lines):
|
||||
@api.multi
|
||||
def _prepare_invoice(self):
|
||||
"""Copy bank partner from sale order to invoice"""
|
||||
vals = super(SaleOrder, self)._prepare_invoice(order, lines)
|
||||
if order.payment_mode_id:
|
||||
vals['payment_mode_id'] = order.payment_mode_id.id
|
||||
vals['partner_bank_id'] = order.payment_mode_id.bank_id.id
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user