mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX+IMP] account_payment_partner: Several things:
* Forgot to remove a usecase of debit_denied * Add ACL * Better filters on payment.order.create wizard * Add default values for those filters on payment.mode * FIX remove coma at end of line * Add translatable 'label' field on payment.mode, designed to be used in invoice report
This commit is contained in:
committed by
Thomas Binsfeld
parent
f5cd5f0a33
commit
d77f563860
@@ -36,7 +36,9 @@
|
||||
'views/res_partner_view.xml',
|
||||
'views/account_invoice_view.xml',
|
||||
'views/report_invoice.xml',
|
||||
'views/payment_mode.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/payment_order_create_view.xml',
|
||||
],
|
||||
'demo': ['demo/partner_demo.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -1,24 +1,5 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Partner 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 res_partner
|
||||
from . import account_invoice
|
||||
from . import payment_mode
|
||||
|
||||
35
account_payment_partner/models/payment_mode.py
Normal file
35
account_payment_partner/models/payment_mode.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2015 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
class PaymentMode(models.Model):
|
||||
_inherit = "payment.mode"
|
||||
|
||||
label = fields.Char(
|
||||
string='Label', translate=True,
|
||||
help="This field is designed to be used in the invoice report")
|
||||
default_payment_mode = fields.Selection([
|
||||
('same', 'Same'),
|
||||
('same_or_null', 'Same or empty'),
|
||||
('any', 'Any'),
|
||||
], string='Payment Mode on Invoice', default='same')
|
||||
@@ -1,2 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_payment_mode_read,Read access on payment.mode to Employees,account_payment.model_payment_mode,base.group_user,1,0,0,0
|
||||
access_payment_mode_type_read,Read access on payment.mode.type to Employees,account_banking_payment_export.model_payment_mode_type,base.group_user,1,0,0,0
|
||||
|
||||
|
23
account_payment_partner/views/payment_mode.xml
Normal file
23
account_payment_partner/views/payment_mode.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_payment_mode_form" model="ir.ui.view">
|
||||
<field name="name">account_payment_partner.payment.mode.form</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_banking_payment_export.view_payment_mode_form_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="payment_order_create_defaults" position="inside">
|
||||
<field name="default_payment_mode"
|
||||
attrs="{'invisible': [('default_invoice', '=', False)]}"/>
|
||||
</group>
|
||||
<field name="name" position="after">
|
||||
<field name="label"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Account Payment Partner module for OpenERP
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# Account Payment Partner module for Odoo
|
||||
# Copyright (C) 2014-2015 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
|
||||
@@ -20,39 +20,41 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, api
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class PaymentOrderCreate(models.TransientModel):
|
||||
_inherit = 'payment.order.create'
|
||||
|
||||
payment_mode = fields.Selection([
|
||||
('same', 'Same'),
|
||||
('same_or_null', 'Same or empty'),
|
||||
('any', 'Any'),
|
||||
], string='Payment Mode on Invoice')
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
res = super(PaymentOrderCreate, self).default_get(field_list)
|
||||
context = self.env.context
|
||||
assert context.get('active_model') == 'payment.order',\
|
||||
'active_model should be payment.order'
|
||||
assert context.get('active_id'), 'Missing active_id in context !'
|
||||
pay_order = self.env['payment.order'].browse(context['active_id'])
|
||||
res['payment_mode'] = pay_order.mode.default_payment_mode
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def extend_payment_order_domain(self, payment_order, domain):
|
||||
res = super(PaymentOrderCreate, self).extend_payment_order_domain(
|
||||
payment_order, domain)
|
||||
# Monkey patch for fixing problem with the core search function
|
||||
# when args has ('invoice', '=', False), referred in the issue #4857
|
||||
# (https://github.com/odoo/odoo/issues/4857)
|
||||
#
|
||||
# Original domain:
|
||||
# domain += ['|', '|',
|
||||
# ('invoice', '=', False),
|
||||
# ('invoice.payment_mode_id', '=', False),
|
||||
# ('invoice.payment_mode_id', '=', payment_order.mode.id)]
|
||||
self.env.cr.execute(
|
||||
"SELECT l.id "
|
||||
"FROM account_move_line l "
|
||||
"LEFT OUTER JOIN account_invoice i "
|
||||
"ON l.move_id = i.move_id "
|
||||
"INNER JOIN account_account a "
|
||||
"ON a.id = l.account_id "
|
||||
"WHERE i.id IS NULL"
|
||||
" AND l.reconcile_id IS NULL"
|
||||
" AND a.type in ('receivable', 'payable')")
|
||||
ids = [x[0] for x in self.env.cr.fetchall()]
|
||||
domain += ['|',
|
||||
('id', 'in', ids),
|
||||
'|',
|
||||
('invoice.payment_mode_id', '=', False),
|
||||
('invoice.payment_mode_id', '=', payment_order.mode.id)]
|
||||
if self.invoice and self.payment_mode:
|
||||
if self.payment_mode == 'same':
|
||||
domain.append(
|
||||
('invoice.payment_mode_id', '=', payment_order.mode.id))
|
||||
elif self.payment_mode == 'same_or_null':
|
||||
domain += [
|
||||
'|',
|
||||
('invoice.payment_mode_id', '=', False),
|
||||
('invoice.payment_mode_id', '=', payment_order.mode.id)]
|
||||
# if payment_mode == 'any', don't modify domain
|
||||
return res
|
||||
|
||||
25
account_payment_partner/wizard/payment_order_create_view.xml
Normal file
25
account_payment_partner/wizard/payment_order_create_view.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_create_payment_order" model="ir.ui.view">
|
||||
<field name="name">account_payment_partner.payment.order.create.form</field>
|
||||
<field name="model">payment.order.create</field>
|
||||
<field name="inherit_id" ref="account_banking_payment_export.view_create_payment_order"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice" position="after">
|
||||
<field name="payment_mode"
|
||||
attrs="{'invisible': [('invoice', '=', False)], 'required': [('invoice', '=', True)]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user