Merge lp:~julie-w/unifield-server/US-1864 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4841
Proposed branch: lp:~julie-w/unifield-server/US-1864
Merge into: lp:unifield-server
Diff against target: 41 lines (+28/-1)
1 file modified
bin/addons/base/res/partner/partner.py (+28/-1)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-1864
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+342563@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 'bin/addons/base/res/partner/partner.py'
2--- bin/addons/base/res/partner/partner.py 2018-03-09 09:31:12 +0000
3+++ bin/addons/base/res/partner/partner.py 2018-04-03 10:30:49 +0000
4@@ -145,9 +145,36 @@
5 return [context['category_id']]
6 return []
7
8+ def _default_customer(self, cr, uid, context=None):
9+ """
10+ If we come from a register by default the partner isn't a customer (returns False), else it is (returns True)
11+ """
12+ if context is None:
13+ context = {}
14+ journal_obj = self.pool.get('account.journal')
15+ if context.get('journal') and isinstance(context['journal'], int):
16+ journal_type = journal_obj.read(cr, uid, context['journal'], ['type'], context=context)['type']
17+ if journal_type in ('cash', 'bank', 'cheque'):
18+ return False
19+ return True
20+
21+ def _default_supplier(self, cr, uid, context=None):
22+ """
23+ If we come from a register by default the partner is a supplier (returns True), else it isn't (returns False)
24+ """
25+ if context is None:
26+ context = {}
27+ journal_obj = self.pool.get('account.journal')
28+ if context.get('journal') and isinstance(context['journal'], int):
29+ journal_type = journal_obj.read(cr, uid, context['journal'], ['type'], context=context)['type']
30+ if journal_type in ('cash', 'bank', 'cheque'):
31+ return True
32+ return False
33+
34 _defaults = {
35 'active': lambda *a: 1,
36- 'customer': lambda *a: 1,
37+ 'customer': _default_customer,
38+ 'supplier': _default_supplier,
39 'category_id': _default_category,
40 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner', context=c),
41 }

Subscribers

People subscribed via source and target branches