Merge lp:~mukunde/unifield-server/US-9357 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6306
Proposed branch: lp:~mukunde/unifield-server/US-9357
Merge into: lp:unifield-server
Diff against target: 77 lines (+32/-3)
2 files modified
bin/addons/account_override/account_invoice_view.xml (+3/-3)
bin/addons/account_override/invoice.py (+29/-0)
To merge this branch: bzr merge lp:~mukunde/unifield-server/US-9357
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+426206@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/account_override/account_invoice_view.xml'
2--- bin/addons/account_override/account_invoice_view.xml 2022-03-18 10:34:15 +0000
3+++ bin/addons/account_override/account_invoice_view.xml 2022-07-04 14:56:21 +0000
4@@ -164,7 +164,7 @@
5 <field name="arch" type="xml">
6 <form string="In-kind Donation" noteditable="state=='cancel'">
7 <group colspan="4" col="8">
8- <field name="journal_id" domain="[('inv_doc_type', '=', True), ('is_active', '=', True)]"/>
9+ <field name="journal_id" domain="[('inv_doc_type', '=', True), ('is_active', '=', True), ('code', '=', 'IKD')]"/>
10 <field name="number"/>
11 <field name="type" invisible="1"/>
12 <field name="is_inkind_donation" invisible="1"/>
13@@ -618,7 +618,7 @@
14 </group>
15 <newline/>
16 <group col="8" colspan="4">
17- <field name="journal_id" select='1' context="{'search_default_filter_is_active': 1}"/>
18+ <field name="fiscalyear_id" select='1'/>
19 <field name="period_id" select='1' string="Period" domain="[('state', 'not in', ['done', 'created'])]"/>
20 <field name="name"/>
21 <field name="amount_total"/>
22@@ -646,7 +646,7 @@
23 <field name="view_mode">tree,form,calendar,graph</field>
24 <field eval="False" name="view_id"/>
25 <field name="domain">[('doc_type', '=', 'donation')]</field>
26- <field name="context">{'doc_type': 'donation', 'type': 'in_invoice', 'journal_type': 'inkind', 'is_inkind_donation': '1', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_open': 1}</field>
27+ <field name="context">{'doc_type': 'donation', 'type': 'in_invoice', 'journal_type': 'inkind', 'is_inkind_donation': '1', 'from_inv_form': True, 'search_default_draft': 1, 'search_default_open': 0}</field>
28 <field name="search_view_id" ref="view_account_invoice_filter_donation"/>
29 </record>
30
31
32=== modified file 'bin/addons/account_override/invoice.py'
33--- bin/addons/account_override/invoice.py 2022-06-01 07:23:33 +0000
34+++ bin/addons/account_override/invoice.py 2022-07-04 14:56:21 +0000
35@@ -395,6 +395,34 @@
36 dom = ['|', ('state', '=', 'draft'), '&', ('state', '=', 'cancel'), ('date_invoice', '=', False)]
37 return dom
38
39+ def _get_fiscalyear(self, cr, uid, ids, field_name=None, arg=None, context=None):
40+ if context is None:
41+ context = {}
42+ if isinstance(ids, (int, long)):
43+ ids = [ids]
44+ res = {}
45+ fy_obj = self.pool.get('account.fiscalyear')
46+ for inv in self.browse(cr, uid, ids, fields_to_fetch=['date_invoice'], context=context):
47+ fy_id = fy_obj.search(cr, uid, [('date_start', '<=', inv.date_invoice), ('date_stop', '>=', inv.date_invoice)], context=context)[0]
48+ if fy_id:
49+ res[inv.id] = fy_id
50+ return res
51+
52+ def _get_search_by_fiscalyear(self, cr, uid, obj=None, name=None, args=None, context=None):
53+ if not args:
54+ return []
55+ if not args[0] or len(args[0]) < 3 or args[0][1] != '=':
56+ raise osv.except_osv(_('Error'), _('Filter not implemented yet.'))
57+ if context is None:
58+ context = {}
59+ fy_obj = self.pool.get('account.fiscalyear')
60+ dom = []
61+ if args[0][1] == '=' and args[0][2]:
62+ fy_id = args[0][2]
63+ fy = fy_obj.browse(cr, uid, fy_id, fields_to_fetch=['date_start', 'date_stop'], context=context)
64+ dom = [('date_invoice', '>=', fy.date_start), ('date_invoice', '<=', fy.date_stop)]
65+ return dom
66+
67 _columns = {
68 'sequence_id': fields.many2one('ir.sequence', string='Lines Sequence', ondelete='cascade',
69 help="This field contains the information related to the numbering of the lines of this order."),
70@@ -436,6 +464,7 @@
71 string='Document Type', store=False, fnct_search=_search_doc_type),
72 'open_fy': fields.function(_get_fake, method=True, type='boolean', string='Open Fiscal Year', store=False,
73 fnct_search=_search_open_fy),
74+ 'fiscalyear_id': fields.function(_get_fiscalyear, fnct_search=_get_search_by_fiscalyear, type='many2one', obj='account.fiscalyear', method=True, store=False, string='Fiscal year', readonly=True),
75 }
76
77 _defaults = {

Subscribers

People subscribed via source and target branches