Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0][MIG] account_reversal #405

Merged
merged 4 commits into from
Nov 22, 2016
Merged

Conversation

antespi
Copy link
Contributor

@antespi antespi commented Sep 30, 2016

Migration of addon account_reversal

@pedrobaeza
Copy link
Member

Please squash all the commits from "OCA Transbot" together

@antespi
Copy link
Contributor Author

antespi commented Sep 30, 2016

Squash done, please mark this PR as needsreview

@pedrobaeza
Copy link
Member

You can still join more the translations commits although they are not together. You can also join the one with the en.po removal

@antespi
Copy link
Contributor Author

antespi commented Sep 30, 2016

There is something weird in coveralls because only 10 files are evaluated and all come from currency_rate_update addon

@antespi
Copy link
Contributor Author

antespi commented Oct 17, 2016

Codecov says, that account_reversal addon files ar not tracked:
image

Where can I change this, in order to include them?

* a checkbox and filter "to be reversed"
* a link between an entry and its reversal entry
* a checkbox and filter "to be reversed"
* a link between an entry and its reversal entry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain the limitations of standard reversal system as the reason for this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Usage
=====

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include usage instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



Credits
=======

Module originally developped by Alexis de Lattre <alexis.delattre@akretion.com>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this text, as it's not the template. He is already in the contributors part and the git history.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


def _move_lines_reverse_prepare(self, lines, date=False, journal=False,
line_prefix=False):
for line in lines:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With new API, lines should be a recordset instead of a dictionary to ease developments. Remember methods _convert_to_write and _convert_to_read and the possibility to have a in-memory recordset with env['model'].new({})

Copy link
Contributor Author

@antespi antespi Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dict because _move_reverse_prepare (copy_data method use inside) also return a dict with (0,0,{}) tuples as move lines.
So, I don't convert it again to other data structure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there are several problems in this prepare design, like the fact that you don't know here the source account.move.line, so in practice, there's no use for this method. Remove it or refactor it discarding copy_data dictionary and iterating over source account.move.line for getting the sub-records.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What source account.move.line do you want to know?
Why do you say that "in practice, there's no use for this method"?, if you want to include/modify another field in other addon you can do it easily inheriting this method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source account.move.line. You have the copied move lines, but not from each journal item they come. How do you use this method then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now _move_lines_reverse_prepare receive move, instead of lines, in order to have journal item info.

data.get('line_ids', []), date=date, journal=journal,
line_prefix=line_prefix)
moves |= self.create(data)
if moves and post:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post option shouldn't be taken for journal flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option comes from the reversal wizard, we can default it to journal configuration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let you decide to do what you consider more consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Journal has not this flag

if moves and post:
moves.post()
if reconcile:
for move in moves:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is @api.multi, so use it: moves.move_reverse_reconcile()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done

@pedrobaeza
Copy link
Member

No clue about codecov.

@@ -12,9 +12,30 @@ Also add on account entries:
* a checkbox and filter "to be reversed"
* a link between an entry and its reversal entry

Odoo v9c include an action similar (overwritten by this addon), but with less
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an action similar/a similar action

features, for instance:

* Allowing inheritance
* Options like prefix (for entry and entry line), post and reconcile.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry: journal entry
entry line: journal item


* If no Reversal Journal is selected, then the same journal is used
* If Post is True, then reversal entry will be posted else it will be leaved
as a draft entry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad indentation (it misses 2 spaces).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following you. What spaces are missed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 spaces at the beginning to align with the list.

Copy link

@elicoidal elicoidal Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* If Post is True, then the reversal entry will be posted else it will be left
  as a draft entry

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done

* If Post and Reconcile are True, then all entry lines with reconciled accounts
of the entry will be reconciled with the reserval entry ones.

Also, there is new menu Accounting > Adviser > Journal Entries to be Reversed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a new menu Accounting > Adviser > Journal Entries to be Reversed
in order to allow tracking entries that must be reserved for any reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there,

I just did a quick test of runbot. Runs fine mostly. Two remarks:

  • the to_be_reversed flag is not set to False after reversing
  • the default prefix for items is blank, IMO it should be REV: as for the move reference (in v8 it was the contrary and I think the prefix must be set on both)

'date': date,
'ref': ref,
'to_be_reversed': False,
'reversal_id': self.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is here: to_be_reversed and reversal_id must be set on the original move, not the reversal move.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set in both, thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antespi I would remove 'reversal_id': self.id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buth this field is needed to known the move who was reversed. It is the same concept like origin in refund invoices

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's debatable The field is named "Reversal move" so the relation is in the other direction. So it's important that you add it on the other side. It might be ok to leave it here although it's slightly confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just understand it, viewing original addon in v8. Sorry, you're right

@antespi
Copy link
Contributor Author

antespi commented Nov 3, 2016

@sbidoul Thanks for your suggestions. I've done all of them

data, date=date, journal=journal, line_prefix=line_prefix)
moves |= self.create(data)
if orig.to_be_reversed:
orig.to_be_reversed = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antespi orig.reversal_id must be set to the reversal move here.

'date': date,
'ref': ref,
'to_be_reversed': False,
'reversal_id': self.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antespi I would remove 'reversal_id': self.id

@antespi
Copy link
Contributor Author

antespi commented Nov 4, 2016

@sbidoul Changes done, thanks

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please @sbidoul @pedrobaeza could you review again? Comments are attended @Tecnativa

@sbidoul
Copy link
Member

sbidoul commented Nov 22, 2016

Looks good. I did a test on runbot, works fine. Thanks!

@alexis-via @adrienpeiffer it would be good to depend on this module in OCA/account-closing 9.0+ to generate cutoff and accrual moves with the to be reversed flag set.

pedrobaeza and others added 4 commits November 22, 2016 15:28
…#387)

[IMP] account_reversal: Several improvements

* Default date for reverse move is not start_date of the period following the period of the original move (and not the period following today's period)
* Return form view of account.move if only 1 move is reversed
* Add option to reconcile with the reversal entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants