From e8da7881a133111ca84ab2021f50d592bddec228 Mon Sep 17 00:00:00 2001 From: Arthur Maniet <arthurmaniet@me.com> Date: Wed, 27 May 2015 08:52:52 +0200 Subject: [PATCH] [FIX] account.payment / check writing / batch deposit : - restored icon of modules account_check_writing and l10n_us_check_printing - removed payment_type from account.payment tree/view since those views are already used with a domain and the type can be inferred from the name given by a sequence - account.payment field company_id wasn't stored and, so, 'Group By' failed - fixed extensibility of register payment wizard through method get_payment_vals() - since register payment fully pays selected invoices, the amount should be readonly - if payment journal is called 'Payment Mode', payment_method should not be called 'Payment Mode' - improved batch deposit template - check memo length when registering a check - in check printing, sort invoices by due date - checks get a check number attributes when registered from the payment wizard as well - when a module extends a method from account.payment it should be careful to check the selected payment method --- addons/account/account_payment.py | 17 ++++++++----- addons/account/views/account_payment_view.xml | 13 +++------- .../account_check_writing/account_payment.py | 24 +++++++++++++----- .../static/description/icon.png | Bin 0 -> 3179 bytes 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/addons/account/account_payment.py b/addons/account/account_payment.py index 10b9faa182d9..e2e64b884e23 100644 --- a/addons/account/account_payment.py +++ b/addons/account/account_payment.py @@ -150,21 +150,24 @@ class account_register_payments(models.TransientModel): }) return rec - @api.multi - def create_payment(self): - invoices = self._get_invoices() - payment = self.env['account.payment'].create({ + def get_payment_vals(self): + """ Hook for extension """ + return { 'journal_id': self.journal_id.id, 'payment_method': self.payment_method.id, 'payment_date': self.payment_date, 'communication': self.communication, - 'invoice_ids': [(4, inv.id, None) for inv in invoices], + 'invoice_ids': [(4, inv.id, None) for inv in self._get_invoices()], 'payment_type': self.payment_type, 'amount': self._compute_total_invoices_amount(), 'currency_id': self.currency_id.id, 'partner_id': self.partner_id.id, 'partner_type': self.partner_type, - }) + } + + @api.multi + def create_payment(self): + payment = self.env['account.payment'].create(self.get_payment_vals()) payment.post() return {'type': 'ir.actions.act_window_close'} @@ -191,6 +194,8 @@ class account_payment(models.Model): else: self.payment_difference = self._compute_total_invoices_amount() - self.amount + company_id = fields.Many2one(store=True) + name = fields.Char(readonly=True, copy=False) state = fields.Selection([('draft', 'Draft'), ('posted', 'Posted'), ('sent', 'Sent'), ('reconciled', 'Reconciled')], readonly=True, default='draft', copy=False, string="Status") diff --git a/addons/account/views/account_payment_view.xml b/addons/account/views/account_payment_view.xml index bdb6cce16b94..1e290ca63d3f 100644 --- a/addons/account/views/account_payment_view.xml +++ b/addons/account/views/account_payment_view.xml @@ -10,7 +10,6 @@ <field name="payment_date"/> <field name="name"/> <field name="journal_id"/> - <field name="payment_type"/> <field name="payment_method"/> <field name="partner_id" string="Customer"/> <field name="amount"/> @@ -30,7 +29,6 @@ <field name="payment_date"/> <field name="name"/> <field name="journal_id"/> - <field name="payment_type"/> <field name="payment_method"/> <field name="partner_id" string="Supplier"/> <field name="amount"/> @@ -63,7 +61,7 @@ <separator/> <filter string="Partner" domain="[]" context="{'group_by': 'partner_id'}"/> <filter string="Journal" domain="[]" context="{'group_by': 'journal_id'}"/> - <filter string="Payment Type" domain="[]" context="{'group_by': 'payment_type'}"/> + <filter string="Payment Method" domain="[]" context="{'group_by': 'payment_method'}"/> <filter string="State" domain="[]" context="{'group_by': 'state'}"/> <filter string="Currency" domain="[]" context="{'group_by': 'currency_id'}" groups="base.group_multi_currency"/> <filter string="Company" domain="[]" context="{'group_by': 'company_id'}" groups="base.group_multi_company"/> @@ -103,7 +101,7 @@ <field name="journal_id" widget="selection" attrs="{'readonly': [('state', '!=', 'draft')]}"/> <field name="destination_journal_id" widget="selection" attrs="{'required': [('payment_type', '=', 'transfer')], 'invisible': [('payment_type', '!=', 'transfer')], 'readonly': [('state', '!=', 'draft')]}"/> <field name="hide_payment_method" invisible="1"/> - <field name="payment_method" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}" String="Payment Mode"/> + <field name="payment_method" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}"/> <field name="payment_method_code" invisible="1"/> <label for="amount"/> <div name="amount_div"> @@ -245,11 +243,8 @@ <field name="hide_payment_method" invisible="1"/> <field name="payment_method" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)]}"/> <field name="payment_method_code" invisible="1"/> - <label for="amount" /> - <div> - <field name="amount" class="oe_inline"/> - <field name="currency_id" groups="base.group_multi_currency" class="oe_inline"/> - </div> + <field name="amount" readonly="1"/> + <field name="currency_id" invisible="1"/> </group> <group> <field name="payment_date"/> diff --git a/addons/account_check_writing/account_payment.py b/addons/account_check_writing/account_payment.py index eb19755b6491..db54215d43ae 100644 --- a/addons/account_check_writing/account_payment.py +++ b/addons/account_check_writing/account_payment.py @@ -4,7 +4,7 @@ import math from openerp import models, fields, api, _ from openerp.tools import amount_to_text_en, float_round -from openerp.exceptions import UserError +from openerp.exceptions import UserError, ValidationError class account_register_payments(models.TransientModel): _inherit = "account.register.payments" @@ -31,13 +31,16 @@ class account_register_payments(models.TransientModel): check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh decimals = self.amount % 1 if decimals >= 10**-2: - check_amount_in_words += _(' and %s/100') % str(int(float_round(decimals, precision_rounding=0.01)*100)) + check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1)))) self.check_amount_in_words = check_amount_in_words - @api.multi def get_payment_vals(self): res = super(account_register_payments, self).get_payment_vals() - res.update({'check_amount_in_words': self.check_amount_in_words}) + if self.payment_method == self.env.ref('account_check_writing.account_payment_method_check_writing'): + res.update({ + 'check_amount_in_words': self.check_amount_in_words, + 'check_manual_sequencing': self.check_manual_sequencing, + }) return res @@ -65,12 +68,21 @@ class account_payment(models.Model): check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh decimals = self.amount % 1 if decimals >= 10**-2: - check_amount_in_words += _(' and %s/100') % str(int(float_round(decimals, precision_rounding=0.01)*100)) + check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1)))) self.check_amount_in_words = check_amount_in_words + def _check_communication(self, payment_method_id, communication): + super(account_payment, self)._check_communication(payment_method_id, communication) + if payment_method_id == self.env.ref('account_check_writing.account_payment_method_check_writing').id: + if not communication: + return + if len(communication) > 60: + raise ValidationError(_("A check memo cannot exceed 60 characters.")) + @api.model def create(self, vals): - if vals.get('check_manual_sequencing'): + if vals['payment_method'] == self.env.ref('account_check_writing.account_payment_method_check_writing').id\ + and vals.get('check_manual_sequencing'): sequence = self.env['account.journal'].browse(vals['journal_id']).check_sequence_id vals.update({'check_number': sequence.next_by_id()}) return super(account_payment, self.sudo()).create(vals) diff --git a/addons/account_check_writing/static/description/icon.png b/addons/account_check_writing/static/description/icon.png index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3c06aa8178220ef9dfdcf185864221076dbc895f 100644 GIT binary patch literal 3179 zcmb7{do&c<7st;SW|Y@>+(I51E+*tzgvMZmk!MQD^)`_hkC~JPBVs0%T!R^u*Bw&f z=2`NX`@1BWJW?WgM3^3!`3XaleskCF|KD1_v(`R)?ep1ZpR?B4Ykk+Dd3iX?>{i_k z0FZHY!TN|i<sXxTiRQo2Ap;^Op6KA}D=8Xe$#AMD-WBI^CJ_Lv&OZjhoa^xwEvgWm zP7_ZM@WiB$gb0w7lyopEHaamZBrf70A>mxfimfUDQe0Q8z3-*c<vS_2)tpqGl_kY) zq7`g0<v1yc#t)c~f!ih1SVyc}Uc)PDDD7X@ZiB0;E(m=uw}Dqa@(XU_e;}O@avxm; z`nwfgT;+L}x>jFV^$C=4xUPg%pi5>2%qCoUy0+c7k~Kd*Su(l2HO|~RIi+c7`D0^p z)7EBk^ysKNM;bg2H#=vtW(Mv6S;ynb6B7H~ux+OcTVR07)XID;%RaQTxM$w9yTB*V z&4Fsp*xJ?IMB{59tw;5L+XzESnj4#Y2?uj&x_4l6vO)AC9G*>vavDtr5g!W0mW~5? zy~CKE|2tHW9l8Q%Yscy;RNZL;YE~1j9x^-vYC(d;Qk+LQP>W{SfbaLe3io}&+zxAR zZ&z@1bg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