Merge lp:~unifield-team/unifield-addons/jfb-utp-766 into lp:unifield-addons

Proposed by jftempo
Status: Merged
Merged at revision: 4593
Proposed branch: lp:~unifield-team/unifield-addons/jfb-utp-766
Merge into: lp:unifield-addons
Diff against target: 61 lines (+22/-3)
2 files modified
account/account.py (+12/-0)
account/account_move_line.py (+10/-3)
To merge this branch: bzr merge lp:~unifield-team/unifield-addons/jfb-utp-766
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+191127@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2013-07-12 14:29:50 +0000
3+++ account/account.py 2013-10-15 09:04:06 +0000
4@@ -1398,6 +1398,16 @@
5
6 return True
7
8+ def _hook_check_move_line(self, cr, uid, move_line, context=None):
9+ """
10+ Some checks on move line
11+ """
12+ if not context:
13+ context = {}
14+ if not move_line:
15+ return False
16+ return True
17+
18 #
19 # Validate a balanced move. If it is a centralised journal, create a move.
20 #
21@@ -1429,6 +1439,8 @@
22 line_draft_ids = []
23 company_id = None
24 for line in move.line_id:
25+ # Hook to check line
26+ self._hook_check_move_line(cr, uid, line, context=context)
27 amount += line.debit - line.credit
28 line_ids.append(line.id)
29 if line.state=='draft':
30
31=== modified file 'account/account_move_line.py'
32--- account/account_move_line.py 2013-05-24 15:37:40 +0000
33+++ account/account_move_line.py 2013-10-15 09:04:06 +0000
34@@ -1245,10 +1245,15 @@
35 journal_obj = self.pool.get('account.journal')
36 if context is None:
37 context = {}
38+ move_date = False
39 if vals.get('move_id', False):
40- company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False)
41- if company_id:
42- vals['company_id'] = company_id[0]
43+ move_data = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id', 'date'])
44+ if move_data.get('company_id'):
45+ vals['company_id'] = move_data['company_id'][0]
46+ move_date = move_data.get('date')
47+ if not vals.get('date') and move_date:
48+ vals['date'] = move_date
49+
50 self._check_date(cr, uid, vals, context, check)
51 if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
52 raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
53@@ -1391,6 +1396,8 @@
54
55 if check and ((not context.get('no_store_function')) or journal.entry_posted):
56 tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
57+ if vals.get('date') and vals.get('date') != move_date:
58+ move_obj.write(cr, uid, [vals['move_id']], {'date': vals.get('date')}, context)
59 if journal.entry_posted and tmp:
60 move_obj.button_validate(cr,uid, [vals['move_id']], context)
61 return result

Subscribers

People subscribed via source and target branches

to all changes: