[MIG] account_payment_sale: Migration to v9

This commit is contained in:
Alexis de Lattre
2016-05-02 11:43:11 +02:00
committed by Atchuthan Ubendran
parent c2f1a1377a
commit bb45ede128
8 changed files with 70 additions and 114 deletions

View File

@@ -1,13 +1,12 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
====================
Account Payment Sale
====================
This module should be used when the invoice is based on the sale order.
This modules adds one field on sale orders: *Payment Mode*.
This field is copied from partner to sale order and then from sale order to
This field is copied from customer to sale order and then from sale order to
customer invoice.
This module is similar to the *sale_payment* module; the main difference is
@@ -19,7 +18,8 @@ Installation
============
This module depends on :
* purchase
* sale
* account_payment_partner
This module is part of the OCA/bank-payment suite.
@@ -35,25 +35,23 @@ 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.
When you create an direct debit order, only invoices related to chosen payment mode are displayed.
Invoices without any payment mode are displayed to.
For further information, please visit:
* https://www.odoo.com/forum/help-1
.. 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 <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
`here <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_sale%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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.
Credits
=======
@@ -62,7 +60,7 @@ Contributors
------------
* Pedro M. Baeza
* Alexis de Lattre
* Alexis de Lattre <alexis.delattre@akretion.com>
* Alexandre Fayolle
* Danimar Ribeiro
* Raphaël Valyi

View File

@@ -1,23 +1,4 @@
# -*- 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 -*-
from . import models
from . import wizard

View File

@@ -1,28 +1,11 @@
# -*- 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 (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': '8.0.1.0.0',
'version': '9.0.1.0.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Adds payment mode on sale orders",

View File

@@ -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

View File

@@ -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

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
Copyright (C) 2014-2016 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
@@ -14,9 +14,9 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="payment_term" position="after">
<field name="payment_term_id" position="after">
<field name="payment_mode_id"
domain="[('sale_ok', '=', True)]"
domain="[('payment_type', '=', 'inbound')]"
widget="selection"/>
</field>
</field>

View File

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

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 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, api
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = 'sale.advance.payment.inv'
@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
if vals:
inv.write(vals)
return inv