Move fields mandate_required and export_ascii from payment mode to payment method

Display chatter on payment orders
Several small usability improvements
This commit is contained in:
Alexis de Lattre
2016-05-10 23:16:31 +02:00
parent b0c10a708d
commit 4e6261a9b1
21 changed files with 69 additions and 42 deletions

View File

@@ -20,7 +20,7 @@
],
'data': [
'views/account_banking_mandate_view.xml',
'views/account_payment_mode.xml',
'views/account_payment_method.xml',
'views/account_invoice_view.xml',
'views/account_payment_line.xml',
'views/res_partner_bank_view.xml',

View File

@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2015 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_banking_mandate
from . import account_payment_mode
from . import account_payment_method
from . import account_payment_order
from . import account_invoice
from . import res_partner_bank

View File

@@ -47,7 +47,7 @@ class AccountInvoice(models.Model):
if (
self.type in ('out_invoice', 'out_refund') and
self.payment_mode_id.payment_type == 'inbound' and
self.payment_mode_id.mandate_required and
self.payment_mode_id.payment_method_id.mandate_required and
self.partner_id):
mandates = self.env['account.banking.mandate'].search([
('state', '=', 'valid'),

View File

@@ -5,10 +5,10 @@
from openerp import models, fields
class AccountPaymentMode(models.Model):
_inherit = "account.payment.mode"
class AccountPaymentMethod(models.Model):
_inherit = "account.payment.method"
mandate_required = fields.Boolean(
string='Mandate Required',
help="Activate this option is this payment mode requires your "
help="Activate this option is this payment method requires your "
"customer to sign a direct debit mandate with your company.")

View File

@@ -12,7 +12,7 @@ class AccountPaymentOrder(models.Model):
@api.multi
def draft2open(self):
for order in self:
if order.payment_mode_id.mandate_required:
if order.payment_mode_id.payment_method_id.mandate_required:
for line in order.payment_line_ids:
if not line.mandate_id:
raise UserError(_(

View File

@@ -3,15 +3,15 @@
<data>
<record id="account_payment_mode_form" model="ir.ui.view">
<field name="name">account_banking_mandate.account.payment.mode.form</field>
<field name="model">account.payment.mode</field>
<field name="inherit_id" ref="account_payment_order.account_payment_mode_form"/>
<record id="account_payment_method_form" model="ir.ui.view">
<field name="name">account_banking_mandate.account.payment.method.form</field>
<field name="model">account.payment.method</field>
<field name="inherit_id" ref="account_payment_mode.account_payment_method_form"/>
<field name="arch" type="xml">
<group name="payment_order_options" position="inside">
<field name="payment_type" position="after">
<field name="mandate_required"
attrs="{'invisible': [('payment_type', '!=', 'inbound')]}"/>
</group>
</field>
</field>
</record>

View File

@@ -28,7 +28,9 @@ class SaleOrder(models.Model):
@api.onchange('payment_mode_id')
def payment_mode_change(self):
"""Select by default the first valid mandate of the partner"""
if self.payment_mode_id.mandate_required and self.partner_id:
if (
self.payment_mode_id.payment_method_id.mandate_required and
self.partner_id):
mandates = self.env['account.banking.mandate'].search([
('state', '=', 'valid'),
('partner_id', '=', self.commercial_partner_id.id),

View File

@@ -10,6 +10,11 @@ class AccountPaymentMethod(models.Model):
_inherit = 'account.payment.method'
pain_version = fields.Selection([], string='PAIN Version')
convert_to_ascii = fields.Boolean(
string='Convert to ASCII', default=True,
help="If active, Odoo will convert each accented caracter to "
"the corresponding unaccented caracter, so that only ASCII "
"caracters are used in the generated PAIN file.")
@api.multi
def get_xsd_file_path(self):

View File

@@ -10,11 +10,6 @@ from openerp import models, fields
class AccountPaymentMode(models.Model):
_inherit = 'account.payment.mode'
convert_to_ascii = fields.Boolean(
string='Convert to ASCII', default=True,
help="If active, Odoo will convert each accented caracter to "
"the corresponding unaccented caracter, so that only ASCII "
"caracters are used in the generated PAIN file.")
initiating_party_issuer = fields.Char(
string='Initiating Party Issuer', size=35,
help="This will be used as the 'Initiating Party Issuer' in the "

View File

@@ -10,14 +10,15 @@ class AccountPaymentOrder(models.Model):
_inherit = 'account.payment.order'
sepa = fields.Boolean(
compute='compute_sepa', readonly=True,
string="SEPA Payment")
compute='compute_sepa', readonly=True, string="SEPA Payment")
charge_bearer = fields.Selection([
('SLEV', 'Following Service Level'),
('SHAR', 'Shared'),
('CRED', 'Borne by Creditor'),
('DEBT', 'Borne by Debtor')], string='Charge Bearer',
default='SLEV',
default='SLEV', readonly=True,
states={'draft': [('readonly', False)], 'open': [('readonly', False)]},
track_visibility='onchange',
help="Following service level : transaction charges are to be "
"applied following the rules agreed in the service level "
"and/or scheme (SEPA Core messages must use this). Shared : "
@@ -28,7 +29,9 @@ class AccountPaymentOrder(models.Model):
"by debtor : all transaction charges are to be borne by the "
"debtor.")
batch_booking = fields.Boolean(
string='Batch Booking',
string='Batch Booking', readonly=True,
states={'draft': [('readonly', False)], 'open': [('readonly', False)]},
track_visibility='onchange',
help="If true, the bank statement will display only one debit "
"line for all the wire transfers of the SEPA XML file ; if "
"false, the bank statement will display one debit line per wire "

View File

@@ -10,6 +10,8 @@
<field name="arch" type="xml">
<field name="payment_type" position="after">
<field name="pain_version"/>
<field name="convert_to_ascii"
attrs="{'invisible': [('pain_version', '=', False)]}"/>
</field>
</field>
</record>

View File

@@ -16,7 +16,6 @@
<field name="arch" type="xml">
<group name="payment_order_options" position="after">
<group name="pain_options" string="Options for PAIN">
<field name="convert_to_ascii"/>
<!-- To be set visible in the localisation modules that need it -->
<field name="initiating_party_identifier" invisible="1"/>
<field name="initiating_party_issuer" invisible="1"/>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<record id="sepa_credit_transfer" model="account.payment.method">

View File

@@ -57,11 +57,12 @@ class AccountPaymentOrder(models.Model):
else:
raise UserError(
_("PAIN version '%s' is not supported.") % pain_flavor)
xsd_file = self.payment_mode_id.payment_method_id.get_xsd_file_path()
pay_method = self.payment_mode_id.payment_method_id
xsd_file = pay_method.get_xsd_file_path()
gen_args = {
'bic_xml_tag': bic_xml_tag,
'name_maxsize': name_maxsize,
'convert_to_ascii': self.payment_mode_id.convert_to_ascii,
'convert_to_ascii': pay_method.convert_to_ascii,
'payment_method': 'TRF',
'file_prefix': 'sct_',
'pain_flavor': pain_flavor,

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<record id="sepa_direct_debit" model="account.payment.method">
<field name="name">SEPA Direct Debit for customers</field>
<field name="code">sepa_direct_debit</field>
<field name="payment_type">inbound</field>
<field name="mandate_required" eval="True"/>
<field name="pain_version">pain.008.001.02</field>
</record>

View File

@@ -9,7 +9,6 @@
<field name="bank_account_link">variable</field>
<field name="payment_method_id" ref="sepa_direct_debit"/>
<field name="default_journal_ids" search="[('type', 'in', ('sale', 'sale_refund'))]"/>
<field name="mandate_required" eval="True"/>
</record>
<record id="base.main_company" model="res.company">

View File

@@ -16,6 +16,7 @@ logger = logging.getLogger(__name__)
class AccountBankingMandate(models.Model):
"""SEPA Direct Debit Mandate"""
_inherit = 'account.banking.mandate'
_rec_name = 'display_name'
format = fields.Selection(
selection_add=[('sepa', 'Sepa Mandate')], default='sepa')
@@ -35,6 +36,7 @@ class AccountBankingMandate(models.Model):
('B2B', 'Enterprise (B2B)')],
string='Scheme', default="CORE", track_visibility='onchange')
unique_mandate_reference = fields.Char(size=35) # cf ISO 20022
display_name = fields.Char(compute='compute_display_name', store=True)
@api.multi
@api.constrains('type', 'recurrent_sequence_type')
@@ -46,6 +48,18 @@ class AccountBankingMandate(models.Model):
_("The recurrent mandate '%s' must have a sequence type.")
% mandate.unique_mandate_reference)
@api.multi
@api.depends('unique_mandate_reference', 'recurrent_sequence_type')
def compute_display_name(self):
for mandate in self:
if mandate.format == 'sepa':
name = '%s (%s)' % (
mandate.unique_mandate_reference,
mandate.recurrent_sequence_type)
else:
name = mandate.unique_mandate_reference
mandate.display_name = name
@api.multi
@api.onchange('partner_bank_id')
def mandate_partner_bank_change(self):

View File

@@ -62,11 +62,12 @@ class AccountPaymentOrder(models.Model):
"Payment Type Code supported for SEPA Direct Debit are "
"'pain.008.001.02', 'pain.008.001.03' and "
"'pain.008.001.04'.") % pain_flavor)
xsd_file = self.payment_mode_id.payment_method_id.get_xsd_file_path()
pay_method = self.payment_mode_id.payment_method_id
xsd_file = pay_method.get_xsd_file_path()
gen_args = {
'bic_xml_tag': bic_xml_tag,
'name_maxsize': name_maxsize,
'convert_to_ascii': self.payment_mode_id.convert_to_ascii,
'convert_to_ascii': pay_method.convert_to_ascii,
'payment_method': 'DD',
'file_prefix': 'sdd_',
'pain_flavor': pain_flavor,

View File

@@ -17,13 +17,13 @@
<field name="inherit_id" ref="account_banking_mandate.view_mandate_form"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="scheme" attrs="{'invisible': [('format', '!=', 'sepa')],
'required': [('format', '=', 'sepa')]}"/>
<field name="type" attrs="{'invisible': [('format', '!=', 'sepa')],
'required': [('format', '=', 'sepa')]}"/>
<field name="recurrent_sequence_type"
attrs="{'invisible': ['|', ('type', '=', 'oneoff'), ('format', '!=', 'sepa')],
'required': [('type', '=', 'recurrent')]}"/>
<field name="scheme" attrs="{'invisible': [('format', '!=', 'sepa')],
'required': [('format', '=', 'sepa')]}"/>
</field>
</field>
</record>
@@ -34,8 +34,8 @@
<field name="inherit_id" ref="account_banking_mandate.view_mandate_tree"/>
<field name="arch" type="xml">
<field name="unique_mandate_reference" position="after">
<field name="type" string="Type"/>
<field name="scheme"/>
<field name="type" string="Type"/>
<field name="recurrent_sequence_type" string="Sequence Type"/>
</field>
</field>

View File

@@ -16,8 +16,7 @@ class AccountPaymentOrder(models.Model):
_order = 'id desc'
name = fields.Char(
string='Number', readonly=True, copy=False,
track_visibility='onchange') # v8 field : name
string='Number', readonly=True, copy=False) # v8 field : name
payment_mode_id = fields.Many2one(
'account.payment.mode', 'Payment Method', required=True,
ondelete='restrict', track_visibility='onchange',
@@ -35,7 +34,8 @@ class AccountPaymentOrder(models.Model):
related='payment_mode_id.bank_account_link', readonly=True)
journal_id = fields.Many2one(
'account.journal', string='Bank Journal', ondelete='restrict',
readonly=True, states={'draft': [('readonly', False)]})
readonly=True, states={'draft': [('readonly', False)]},
track_visibility='onchange')
allowed_journal_ids = fields.Many2many(
'account.journal', compute='_compute_allowed_journals', readonly=True,
string='Selectable Bank Journals')
@@ -200,7 +200,11 @@ class AccountPaymentOrder(models.Model):
for order in self:
if not order.journal_id:
raise UserError(_(
'Missing Bank Journal on payment order %s') % order.name)
'Missing Bank Journal on payment order %s.') % order.name)
if not order.payment_line_ids:
raise UserError(_(
'There are no transactions on payment order %s.')
% order.name)
# Delete existing bank payment lines
order.bank_line_ids.unlink()
# Create the bank payment lines from the payment lines

View File

@@ -46,7 +46,7 @@
<group name="head-right">
<field name="date_prefered"/>
<field name="date_scheduled"
attrs="{'readonly': [('date_prefered', '!=', 'fixed')]}"/>
attrs="{'invisible': [('date_prefered', '!=', 'fixed')], 'required': [('date_prefered', '=', 'fixed')]}"/>
<field name="date_generated"/>
<field name="generated_user_id"/>
<field name="date_uploaded"/>
@@ -66,6 +66,10 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>