-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
account_move_base_import/wizard/account_autocomplete_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from openerp import models, api, _ | ||
from openerp.exceptions import UserError | ||
|
||
|
||
class AutocompleteAccountMove(models.TransientModel): | ||
_name = "autocomplete.account.move" | ||
_description = "Autocomplete Account Move" | ||
|
||
@api.multi | ||
def autocomplete_move(self): | ||
context = dict(self._context or {}) | ||
moves = self.env['account.move'].browse(context.get('active_ids')) | ||
draft_move_ids = [] | ||
journal_error_names = [] | ||
for move in moves: | ||
if move.state != 'draft': | ||
draft_move_ids.append(move.id) | ||
if not move.used_for_completion: | ||
if move.journal_id.name not in journal_error_names: | ||
journal_error_names.append(move.journal_id.name) | ||
if draft_move_ids: | ||
raise UserError( | ||
_('Some journal entries are not at draft state : %s' | ||
% (draft_move_ids,))) | ||
if journal_error_names: | ||
raise UserError( | ||
_('Autocompletion is not allowed on journals %s' | ||
% (journal_error_names,))) | ||
moves.button_auto_completion() | ||
return {'type': 'ir.actions.act_window_close'} |
42 changes: 42 additions & 0 deletions
42
account_move_base_import/wizard/autocomplete_move_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<!--Account Move lines--> | ||
<record id="autocomplete_account_move_view" model="ir.ui.view"> | ||
<field name="name">Autocomplete Journal Entries</field> | ||
<field name="model">autocomplete.account.move</field> | ||
<field name="arch" type="xml"> | ||
<form string="Post Journal Entries"> | ||
<label string="All selected journal entries will be autocompleted"/> | ||
<footer> | ||
<button string="Auto-complete" name="autocomplete_move" type="object" default_focus="1" class="btn-primary"/> | ||
<button string="Cancel" class="btn-default" special="cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_autocomplete_account_move" model="ir.actions.act_window"> | ||
<field name="name">Autocomplete Journal Entries</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">autocomplete.account.move</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">form</field> | ||
<field name="view_id" ref="autocomplete_account_move_view"/> | ||
<field name="context">{}</field> | ||
<field name="target">new</field> | ||
<field name="help">This wizard will autocomplete all journal entries selected.</field> | ||
</record> | ||
|
||
<record model="ir.values" id="autocomplete_account_move_values"> | ||
<field name="model_id" ref="account.model_account_move" /> | ||
<field name="name">Autocomplete Journal Entries</field> | ||
<field name="key2">client_action_multi</field> | ||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_autocomplete_account_move'))" /> | ||
<field name="key">action</field> | ||
<field name="model">account.move</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters