Upport the "mark invoice as sent" wizard from v8 to v10
PEP8 on account_usability
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
|
||||
from . import account
|
||||
from . import partner
|
||||
from . import wizard
|
||||
|
||||
@@ -33,6 +33,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'data': [
|
||||
'account_view.xml',
|
||||
'partner_view.xml',
|
||||
'wizard/account_invoice_mark_sent_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.tools import float_compare, float_is_zero
|
||||
from odoo.exceptions import UserError
|
||||
from itertools import groupby
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
@@ -79,8 +78,8 @@ class AccountInvoice(models.Model):
|
||||
# generated from customer invoices linked to the partners' account because:
|
||||
# 1) the label of an account move line is an important field, we can't
|
||||
# write a rubbish '/' in it !
|
||||
# 2) the 'name' field of the account.move.line is used in the overdue letter,
|
||||
# and '/' is not meaningful for our customer !
|
||||
# 2) the 'name' field of the account.move.line is used in the overdue
|
||||
# letter, and '/' is not meaningful for our customer !
|
||||
@api.multi
|
||||
def action_move_create(self):
|
||||
res = super(AccountInvoice, self).action_move_create()
|
||||
@@ -134,8 +133,10 @@ class AccountJournal(models.Model):
|
||||
return res
|
||||
else:
|
||||
for journal in self:
|
||||
currency = journal.currency_id or journal.company_id.currency_id
|
||||
name = "[%s] %s (%s)" % (journal.code, journal.name, currency.name)
|
||||
currency = journal.currency_id or\
|
||||
journal.company_id.currency_id
|
||||
name = "[%s] %s (%s)" % (
|
||||
journal.code, journal.name, currency.name)
|
||||
res.append((journal.id, name))
|
||||
return res
|
||||
|
||||
@@ -193,8 +194,8 @@ class AccountAnalyticAccount(models.Model):
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
default_move_line_name = fields.Char(string='Default Label',
|
||||
states={'posted': [('readonly', True)]})
|
||||
default_move_line_name = fields.Char(
|
||||
string='Default Label', states={'posted': [('readonly', True)]})
|
||||
# By default, we can still modify "ref" when account move is posted
|
||||
# which seems a bit lazy for me...
|
||||
ref = fields.Char(states={'posted': [('readonly', True)]})
|
||||
@@ -303,7 +304,7 @@ class AccountBankStatementLine(models.Model):
|
||||
# is caused by this.
|
||||
# Set search_reconciliation_proposition to False by default
|
||||
# TODO: re-write in v10
|
||||
#def get_data_for_reconciliations(
|
||||
# def get_data_for_reconciliations(
|
||||
# self, cr, uid, ids, excluded_ids=None,
|
||||
# search_reconciliation_proposition=False, context=None):
|
||||
# # Make variable name shorted for PEP8 !
|
||||
@@ -323,8 +324,8 @@ class AccountBankStatementLine(models.Model):
|
||||
# 2) The name of the statement line is already written in the name of
|
||||
# the move line -> not useful to have the info 2 times
|
||||
# In the end, I think it's better to just put nothing (we could write
|
||||
# the name of the statement which has the account number, but it doesn't
|
||||
# bring any useful info to the accountant)
|
||||
# the name of the statement which has the account number, but it
|
||||
# doesn't bring any useful info to the accountant)
|
||||
# The only "good" thing to do would be to have a sequence per
|
||||
# statement line and write it in this 'ref' field
|
||||
# But that would required an additionnal field on statement lines
|
||||
|
||||
3
account_usability/wizard/__init__.py
Normal file
3
account_usability/wizard/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import account_invoice_mark_sent
|
||||
23
account_usability/wizard/account_invoice_mark_sent.py
Normal file
23
account_usability/wizard/account_invoice_mark_sent.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountInvoiceMarkSent(models.TransientModel):
|
||||
_name = 'account.invoice.mark.sent'
|
||||
_description = 'Mark invoices as sent'
|
||||
|
||||
def run(self):
|
||||
assert self.env.context.get('active_model') == 'account.invoice',\
|
||||
'Source model must be invoices'
|
||||
assert self.env.context.get('active_ids'), 'No invoices selected'
|
||||
invoices = self.env['account.invoice'].search([
|
||||
('id', 'in', self.env.context.get('active_ids')),
|
||||
('state', 'in', ('open', 'paid'))])
|
||||
invoices.write({'sent': True})
|
||||
logger.info('Marking invoices with ID %s as sent', invoices.ids)
|
||||
return
|
||||
35
account_usability/wizard/account_invoice_mark_sent_view.xml
Normal file
35
account_usability/wizard/account_invoice_mark_sent_view.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="account_invoice_mark_sent_form" model="ir.ui.view">
|
||||
<field name="name">account.invoice.mark.sent.form</field>
|
||||
<field name="model">account.invoice.mark.sent</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Mark invoices as sent">
|
||||
<p>
|
||||
This wizard will mark as <i>sent</i> all the selected invoices in open or paid state.
|
||||
</p>
|
||||
<footer>
|
||||
<button type="object" name="run" string="Mark as Sent" class="btn-primary"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="account_invoice_mark_sent_action"
|
||||
multi="True"
|
||||
key2="client_action_multi"
|
||||
name="Mark as Sent"
|
||||
res_model="account.invoice.mark.sent"
|
||||
src_model="account.invoice"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
groups="account.group_account_invoice" />
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user