Merge lp:~julie-w/unifield-server/US-777 into lp:unifield-server
- US-777
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 3645 |
Proposed branch: | lp:~julie-w/unifield-server/US-777 |
Merge into: | lp:unifield-server |
Diff against target: |
292 lines (+96/-39) 6 files modified
bin/addons/account/invoice.py (+3/-0) bin/addons/account_override/invoice.py (+14/-1) bin/addons/msf_profile/i18n/fr_MF.po (+1/-0) bin/addons/register_accounting/wizard/invoice_date.py (+14/-0) bin/addons/register_accounting/wizard/wizard_cash_return.py (+59/-35) bin/addons/register_accounting/wizard/wizard_cash_return.xml (+5/-3) |
To merge this branch: | bzr merge lp:~julie-w/unifield-server/US-777 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+289253@code.launchpad.net |
Commit message
Description of the change
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/invoice.py' |
2 | --- bin/addons/account/invoice.py 2016-02-17 08:55:37 +0000 |
3 | +++ bin/addons/account/invoice.py 2016-03-16 16:52:34 +0000 |
4 | @@ -348,6 +348,9 @@ |
5 | if view_type == 'tree': |
6 | doc = etree.XML(res['arch']) |
7 | nodes = doc.xpath("//field[@name='partner_id']") |
8 | + # (US-777) Remove the possibility to create new invoices through the "Advance Return" Wizard |
9 | + if context.get('from_wizard') and context.get('from_wizard')['model'] == 'wizard.cash.return': |
10 | + doc.set('hide_new_button', 'True') |
11 | partner_string = _('Customer') |
12 | if context.get('type', 'out_invoice') in ('in_invoice', 'in_refund'): |
13 | partner_string = _('Supplier') |
14 | |
15 | === modified file 'bin/addons/account_override/invoice.py' |
16 | --- bin/addons/account_override/invoice.py 2016-01-25 11:23:45 +0000 |
17 | +++ bin/addons/account_override/invoice.py 2016-03-16 16:52:34 +0000 |
18 | @@ -668,7 +668,7 @@ |
19 | No longer fills the date automatically, but requires it to be set |
20 | """ |
21 | # Some verifications |
22 | - if not context: |
23 | + if context is None: |
24 | context = {} |
25 | self._check_invoice_merged_lines(cr, uid, ids, context=context) |
26 | |
27 | @@ -700,6 +700,19 @@ |
28 | } |
29 | |
30 | wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_open', cr) |
31 | + |
32 | + fw = context.get('from_wizard', False) |
33 | + if fw: |
34 | + # since US-777: go back to wizard in progress |
35 | + return { |
36 | + 'type': 'ir.actions.act_window', |
37 | + 'res_model': fw['model'], |
38 | + 'view_type': 'form', |
39 | + 'view_mode': 'form', |
40 | + 'res_id': fw['res_id'], |
41 | + 'context': context, |
42 | + 'target': 'new', |
43 | + } |
44 | return True |
45 | |
46 | def action_reconcile_imported_invoice(self, cr, uid, ids, context=None): |
47 | |
48 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' |
49 | --- bin/addons/msf_profile/i18n/fr_MF.po 2016-03-11 16:18:26 +0000 |
50 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2016-03-16 16:52:34 +0000 |
51 | @@ -55426,6 +55426,7 @@ |
52 | |
53 | #. module: register_accounting |
54 | #: code:addons/register_accounting/wizard/import_invoice_on_registers.py:125 |
55 | +#: code:addons/register_accounting/wizard/wizard_cash_return.py:669 |
56 | #, python-format |
57 | msgid "This invoice: %s %s has already been added. Please choose another invoice." |
58 | msgstr "Cette facture: %s %s a déjà été ajoutée. Veuillez choisir une autre facture." |
59 | |
60 | === modified file 'bin/addons/register_accounting/wizard/invoice_date.py' |
61 | --- bin/addons/register_accounting/wizard/invoice_date.py 2014-03-07 11:05:37 +0000 |
62 | +++ bin/addons/register_accounting/wizard/invoice_date.py 2016-03-16 16:52:34 +0000 |
63 | @@ -51,6 +51,20 @@ |
64 | |
65 | inv_obj.write(cr, uid, [wiz.invoice_id.id], values) |
66 | wf_service.trg_validate(uid, 'account.invoice', wiz.invoice_id.id, 'invoice_open', cr) |
67 | + |
68 | + fw = context and context.get('from_wizard', False) or False |
69 | + if fw: |
70 | + # since US-777: go back to wizard in progress |
71 | + return { |
72 | + 'type': 'ir.actions.act_window', |
73 | + 'res_model': fw['model'], |
74 | + 'view_type': 'form', |
75 | + 'view_mode': 'form', |
76 | + 'res_id': fw['res_id'], |
77 | + 'context': context, |
78 | + 'target': 'new', |
79 | + } |
80 | + |
81 | return { 'type': 'ir.actions.act_window_close', } |
82 | |
83 | wizard_invoice_date() |
84 | |
85 | === modified file 'bin/addons/register_accounting/wizard/wizard_cash_return.py' |
86 | --- bin/addons/register_accounting/wizard/wizard_cash_return.py 2015-05-29 11:50:18 +0000 |
87 | +++ bin/addons/register_accounting/wizard/wizard_cash_return.py 2016-03-16 16:52:34 +0000 |
88 | @@ -28,6 +28,7 @@ |
89 | import time |
90 | from lxml import etree |
91 | |
92 | + |
93 | class account_bank_statement_line(osv.osv): |
94 | _name = "account.bank.statement.line" |
95 | _inherit = "account.bank.statement.line" |
96 | @@ -45,6 +46,7 @@ |
97 | A register line simulation containing some invoices. |
98 | """ |
99 | _name = "wizard.invoice.line" |
100 | + |
101 | _columns = { |
102 | 'document_date': fields.date(string='Document Date'), |
103 | 'reference': fields.char(string='Reference', size=64, required=False), # invoice.internal_number |
104 | @@ -58,6 +60,7 @@ |
105 | |
106 | wizard_invoice_line() |
107 | |
108 | + |
109 | class wizard_advance_line(osv.osv_memory): |
110 | """ |
111 | A register line simulation. |
112 | @@ -278,9 +281,9 @@ |
113 | 'context': context, |
114 | } |
115 | |
116 | - |
117 | wizard_advance_line() |
118 | |
119 | + |
120 | class wizard_cash_return(osv.osv_memory): |
121 | """ |
122 | A wizard to link some advance lines to some account_move_line according to some parameters : |
123 | @@ -323,7 +326,7 @@ |
124 | help="Add the invoices you want to link to the Cash Advance Return", required=False, readonly=True), |
125 | 'advance_line_ids': fields.one2many('wizard.advance.line', 'wizard_id', string="Advance Lines"), |
126 | 'total_amount': fields.float(string="Justified Amount", digits=(16,2), readonly=True), |
127 | - 'invoice_id': fields.many2one('account.invoice', string='Invoice', required=False), |
128 | + 'invoice_ids': fields.many2many('account.invoice', 'wizard_cash_return_invoice_rel', 'wizard_id', 'invoice_id', "Invoices"), |
129 | 'display_invoice': fields.boolean(string="Display Invoice"), |
130 | 'advance_st_line_id': fields.many2one('account.bank.statement.line', string='Advance Statement Line', required=True), |
131 | 'currency_id': fields.many2one('res.currency', string='Currency'), |
132 | @@ -364,7 +367,10 @@ |
133 | |
134 | def create(self, cr, uid, values, context=None): |
135 | w_id = super(wizard_cash_return, self).create(cr, uid, values, context=context) |
136 | - if context and 'statement_line_id' in context: |
137 | + if context is None: |
138 | + context = {} |
139 | + |
140 | + if 'statement_line_id' in context: |
141 | """" |
142 | UTP-482 if statment line of Operational Advance, |
143 | is linked to a PO, automatically adding PO invoices |
144 | @@ -393,6 +399,11 @@ |
145 | " Entering a 100% cash return (advance return amount = initial advance amount) you will be able to close this advance without linking it to an invoice." |
146 | values['comment'] = msg |
147 | self.write(cr, uid, [w_id], values, context=context) |
148 | + |
149 | + context['from_wizard'] = { |
150 | + 'model': 'wizard.cash.return', |
151 | + 'res_id': w_id, |
152 | + } |
153 | return w_id |
154 | |
155 | def onchange_addl_amount(self, cr, uid, returned_amount, context=None): |
156 | @@ -601,20 +612,26 @@ |
157 | is linked to a PO, automatically adding PO invoices |
158 | (force user to use invoices for this cash return) |
159 | """ |
160 | - auto_add = True |
161 | invoice_obj = self.pool.get('account.invoice') |
162 | - invoice = invoice_obj.browse(cr, uid, context['po_op_advance_auto_add_invoice_id'], context) |
163 | + invoice_rec = invoice_obj.browse(cr, uid, |
164 | + context['po_op_advance_auto_add_invoice_id'], context) |
165 | del context['po_op_advance_auto_add_invoice_id'] |
166 | - if not invoice: |
167 | + if not invoice_rec: |
168 | return |
169 | + auto_add = True |
170 | + invoices = [ invoice_rec, ] |
171 | else: |
172 | # default behaviour |
173 | + if not wizard.invoice_ids: |
174 | + return False |
175 | auto_add = False |
176 | - invoice = wizard.invoice_id |
177 | - to_write = {} |
178 | + invoices = wizard.invoice_ids |
179 | + |
180 | new_lines = [] |
181 | - total = 0.0 |
182 | - if invoice: |
183 | + total = wizard.returned_amount or 0. # reuse current amount when adding new line |
184 | + added_invoice_ids = [ |
185 | + wil.invoice_id.id for wil in wizard.invoice_line_ids ] |
186 | + for invoice in invoices: |
187 | # Verify that the invoice is in the same currency as those of the register |
188 | inv_currency = invoice.currency_id.id |
189 | if wizard.advance_st_line_id and wizard.advance_st_line_id.statement_id \ |
190 | @@ -624,18 +641,10 @@ |
191 | st_currency = False |
192 | if st_currency and st_currency != inv_currency: |
193 | raise osv.except_osv(_('Error'), _('The choosen invoice is not in the same currency as those of the register.')) |
194 | - # Make a list of invoices that have already been added in this wizard |
195 | - if wizard.invoice_line_ids: |
196 | - added_invoices = [x['invoice_id']['id'] for x in wizard.invoice_line_ids] |
197 | - else: |
198 | - added_invoices = [] |
199 | + |
200 | # Do operations only if our invoice is not in our list |
201 | - if invoice.id not in added_invoices: |
202 | - # Retrieve some variables |
203 | - move_line_obj = self.pool.get('account.move.line') |
204 | - account_id = invoice.account_id.id |
205 | + if invoice.id not in added_invoice_ids: |
206 | # recompute the total_amount |
207 | - total = wizard.returned_amount or 0 |
208 | if wizard.invoice_line_ids: |
209 | for line in wizard.invoice_line_ids: |
210 | total += line.amount |
211 | @@ -644,21 +653,30 @@ |
212 | partner_id = invoice.partner_id.id or False |
213 | account_id = invoice.account_id.id or False |
214 | date = invoice.document_date or False |
215 | - new_lines.append((0, 0, {'document_date': date, 'reference': reference, 'communication': communication, 'partner_id': partner_id, \ |
216 | - 'account_id': account_id, 'amount': invoice.residual, 'invoice_id': invoice.id})) |
217 | + line_vals = { |
218 | + 'document_date': date, |
219 | + 'reference': reference, |
220 | + 'communication': communication, |
221 | + 'partner_id': partner_id, |
222 | + 'account_id': account_id, |
223 | + 'amount': invoice.residual, |
224 | + 'invoice_id': invoice.id, |
225 | + } |
226 | + new_lines.append((0, 0, line_vals)) |
227 | # Add amount to total_amount |
228 | total += invoice.residual |
229 | - # Change display_invoice to True in order to show invoice lines |
230 | - if new_lines: |
231 | - to_write['display_invoice'] = True |
232 | - # Add lines to elements to be written |
233 | - to_write['invoice_line_ids'] = new_lines |
234 | - # Add total_amount to elements to be written |
235 | - to_write['total_amount'] = total |
236 | - # Delete content of invoice_id field |
237 | - to_write['invoice_id'] = False |
238 | - # write changes in the wizard |
239 | - self.write(cr, uid, ids, to_write, context=context) |
240 | + else: |
241 | + raise osv.except_osv(_('Warning'), _('This invoice: %s %s has already been added. Please choose another invoice.')%(invoice.internal_number or '', invoice.residual)) |
242 | + |
243 | + if new_lines: |
244 | + vals = { |
245 | + # Change display_invoice to True in order to show invoice lines |
246 | + 'display_invoice': True, |
247 | + 'invoice_line_ids': new_lines, |
248 | + 'total_amount': total, |
249 | + 'invoice_ids': [ (6, 0, []), ] , # reset invoices picker |
250 | + } |
251 | + self.write(cr, uid, ids, vals, context=context) |
252 | |
253 | if not auto_add: |
254 | return { |
255 | @@ -693,10 +711,16 @@ |
256 | display_invoice = False |
257 | """ |
258 | |
259 | - # Delete links to invoice_line_ids and inform wizard of that |
260 | - self.write(cr, uid, ids, {'display_invoice': display_invoice, 'invoice_line_ids': [(5,)]}, context=context) |
261 | + vals = { |
262 | + 'display_invoice': display_invoice, |
263 | + 'invoice_ids': [ (6, 0, []), ] , # reset invoices picker |
264 | + 'invoice_line_ids': [ (5, ), ], # reset to import invoices |
265 | + } |
266 | + self.write(cr, uid, ids, vals, context=context) |
267 | + |
268 | # Update total amount |
269 | self.compute_total_amount(cr, uid, ids, context=context) |
270 | + |
271 | return { |
272 | 'type': 'ir.actions.act_window', |
273 | 'res_model': 'wizard.cash.return', |
274 | |
275 | === modified file 'bin/addons/register_accounting/wizard/wizard_cash_return.xml' |
276 | --- bin/addons/register_accounting/wizard/wizard_cash_return.xml 2014-10-07 07:50:37 +0000 |
277 | +++ bin/addons/register_accounting/wizard/wizard_cash_return.xml 2016-03-16 16:52:34 +0000 |
278 | @@ -29,9 +29,11 @@ |
279 | <field name="analytic_distribution_id" invisible="1"/> |
280 | </group> |
281 | <group colspan="4"> |
282 | - <field name='invoice_id' nolabel="1" domain="[('type', '=', 'in_invoice'), ('state', '=', 'open'), |
283 | - ('currency_id', '=', currency_id)]"/> |
284 | - <button string='Add invoice' name='action_add_invoice' type='object' icon='gtk-add' /> |
285 | + <field name='invoice_ids' nolabel="1" |
286 | + domain="[('type', '=', 'in_invoice'), ('state', '=', 'open'), ('currency_id', '=', currency_id)]" |
287 | + context="{ 'type': 'in_invoice', 'journal_type': 'purchase' }" |
288 | + /> |
289 | + <button string='Add invoice(s)' name='action_add_invoice' type='object' icon='gtk-add' /> |
290 | </group> |
291 | <newline /> |
292 | <field name='invoice_line_ids' attrs="{'invisible':[('display_invoice', '!=', True)]}" nolabel="1" colspan="4" /> |