Merge lp:~julie-w/unifield-server/US-3593 into lp:unifield-server
- US-3593
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 4744 |
Proposed branch: | lp:~julie-w/unifield-server/US-3593 |
Merge into: | lp:unifield-server |
Diff against target: |
480 lines (+142/-169) 4 files modified
bin/addons/msf_profile/i18n/es_MF.po (+0/-5) bin/addons/msf_profile/i18n/fr_MF.po (+2/-7) bin/addons/register_accounting/wizard/wizard_cash_return.py (+136/-152) bin/addons/register_accounting/wizard/wizard_cash_return.xml (+4/-5) |
To merge this branch: | bzr merge lp:~julie-w/unifield-server/US-3593 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+337638@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/msf_profile/i18n/es_MF.po' |
2 | --- bin/addons/msf_profile/i18n/es_MF.po 2017-09-28 14:05:02 +0000 |
3 | +++ bin/addons/msf_profile/i18n/es_MF.po 2018-02-13 14:39:37 +0000 |
4 | @@ -20461,11 +20461,6 @@ |
5 | msgid "If you have more than one shop reselling your company products, you can create and manage that from here. Whenever you will record a new quotation or sales order, it has to be linked to a shop. The shop also defines the warehouse from which the products will be delivered for each particular sales." |
6 | msgstr "Si hay más de una tienda que vende los productos de su empresa, puede crearlas y administrarlas desde aquí. Cada vez que registre un nuevo presupuesto o pedido de venta, deberá vincularlo a la tienda correspondiente. La tienda también define el almacén desde el que se enviarán los productos para cada venta concreta." |
7 | |
8 | -#. module: register_accounting |
9 | -#: field:wizard.cash.return,display_invoice:0 |
10 | -msgid "Display Invoice" |
11 | -msgstr "Mostrar factura" |
12 | - |
13 | #. modules: account, register_accounting |
14 | #: view:account.bank.statement:0 |
15 | #: field:account.bank.statement.line,statement_id:0 |
16 | |
17 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' |
18 | --- bin/addons/msf_profile/i18n/fr_MF.po 2018-02-13 08:37:02 +0000 |
19 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2018-02-13 14:39:37 +0000 |
20 | @@ -36871,8 +36871,8 @@ |
21 | #. module: register_accounting |
22 | #: code:addons/register_accounting/wizard/wizard_cash_return.py:826 |
23 | #, python-format |
24 | -msgid "Initial advance amount (%s) does not match the amount you justified (%s). First correct. Then press Compute button" |
25 | -msgstr "Initial advance amount (%s) does not match the amount you justified (%s). First correct. Then press Compute button" |
26 | +msgid "Advance amount (%s) does not match the amount you justified (%s). First correct. Then press Compute button." |
27 | +msgstr "Le montant de l'avance (%s) ne correspond pas avec le montant que vous avez justifié (%s). Veuillez d'abord corriger. Puis cliquez sur le bouton Calculer." |
28 | |
29 | #. modules: account, stock_override, supplier_catalogue, consumption_calculation, purchase_override, base, register_accounting, stock, analytic_distribution |
30 | #: field:account.analytic.chart,from_date:0 |
31 | @@ -64260,11 +64260,6 @@ |
32 | msgid "Fiscal Year to close" |
33 | msgstr "Exercice comptable à Clôturer" |
34 | |
35 | -#. module: register_accounting |
36 | -#: field:wizard.cash.return,display_invoice:0 |
37 | -msgid "Display Invoice" |
38 | -msgstr "Afficher Facture" |
39 | - |
40 | #. module: product |
41 | #: field:product.template,type:0 |
42 | msgid "Product Type" |
43 | |
44 | === modified file 'bin/addons/register_accounting/wizard/wizard_cash_return.py' |
45 | --- bin/addons/register_accounting/wizard/wizard_cash_return.py 2017-08-18 10:15:40 +0000 |
46 | +++ bin/addons/register_accounting/wizard/wizard_cash_return.py 2018-02-13 14:39:37 +0000 |
47 | @@ -295,8 +295,12 @@ |
48 | _name = "wizard.cash.return" |
49 | _description = "A wizard that link some advance lines to some account move lines" |
50 | |
51 | - def changeline(self, cr, uid, ids, lines, returned_amount, date, reference, additional_amount, context=None): |
52 | + def changeline(self, cr, uid, ids, lines, returned_amount, invoices, date, reference, additional_amount, context=None): |
53 | total_amount = returned_amount or 0.0 |
54 | + # add the amount of invoice lines |
55 | + for invoice in invoices: |
56 | + if len(invoice) > 2: |
57 | + total_amount += invoice[2].get('amount', 0.0) |
58 | for line in lines: |
59 | if line[0] == 1: |
60 | total_amount += line[2].get('amount',0) |
61 | @@ -308,7 +312,7 @@ |
62 | |
63 | def _get_ok_with_confirm(self, cr, uid, ids, fieldname, args, context=None): |
64 | """UFTP-24 display confirm message at wizard validation when linked |
65 | - to a PO and no invoices selected (or advance lines added)""" |
66 | + to a PO and no invoices selected""" |
67 | res = {} |
68 | if not ids: |
69 | return res |
70 | @@ -316,8 +320,7 @@ |
71 | ids = [ids] |
72 | fields = ['advance_linked_po_auto_invoice', 'invoice_line_ids', 'advance_line_ids'] |
73 | for r in self.read(cr, uid, ids, fields, context=context): |
74 | - res[r['id']] = r['advance_linked_po_auto_invoice'] and \ |
75 | - (not r['invoice_line_ids'] or r['advance_line_ids']) |
76 | + res[r['id']] = r['advance_linked_po_auto_invoice'] and not r['invoice_line_ids'] |
77 | return res |
78 | |
79 | _columns = { |
80 | @@ -329,7 +332,6 @@ |
81 | 'advance_line_ids': fields.one2many('wizard.advance.line', 'wizard_id', string="Advance Lines"), |
82 | 'total_amount': fields.float(string="Justified Amount", digits=(16,2), readonly=True), |
83 | 'invoice_ids': fields.many2many('account.invoice', 'wizard_cash_return_invoice_rel', 'wizard_id', 'invoice_id', "Invoices"), |
84 | - 'display_invoice': fields.boolean(string="Display Invoice"), |
85 | 'advance_st_line_id': fields.many2one('account.bank.statement.line', string='Advance Statement Line', required=True), |
86 | 'currency_id': fields.many2one('res.currency', string='Currency'), |
87 | 'date': fields.date(string='Date for advance return', required=True), |
88 | @@ -343,7 +345,6 @@ |
89 | |
90 | _defaults = { |
91 | 'initial_amount': lambda self, cr, uid, c=None: c.get('amount', False), |
92 | - 'display_invoice': False, # this permits to show only advance lines tree. Then add an invoice make the invoice tree to be displayed |
93 | 'date': lambda *a: time.strftime('%Y-%m-%d'), |
94 | 'advance_linked_po_auto_invoice': False, |
95 | } |
96 | @@ -413,7 +414,7 @@ |
97 | return {'value': {'returned_amount': 0}} |
98 | return {} |
99 | |
100 | - def onchange_returned_amount(self, cr, uid, ids, amount=0.0, invoices=None, advances=None, display_invoice=None, initial_amount=0.0, advance_linked_po_auto_invoice=False, additional_amount=0.0, context=None): |
101 | + def onchange_returned_amount(self, cr, uid, ids, amount=0.0, invoices=None, advances=None, initial_amount=0.0, advance_linked_po_auto_invoice=False, additional_amount=0.0, context=None): |
102 | """ |
103 | When the returned amount change, it update the "Justified amount" (total_amount) |
104 | """ |
105 | @@ -432,14 +433,10 @@ |
106 | return {'value': values} |
107 | if amount: |
108 | total_amount = amount + 0.0 |
109 | - if display_invoice: |
110 | - if invoices: |
111 | - for invoice in invoices: |
112 | - total_amount += invoice[2].get('amount', 0.0) |
113 | - else: |
114 | - if advances: |
115 | - for advance in advances: |
116 | - total_amount += advance[2].get('amount', 0.0) |
117 | + for invoice in invoices: |
118 | + total_amount += invoice[2].get('amount', 0.0) |
119 | + for advance in advances: |
120 | + total_amount += advance[2].get('amount', 0.0) |
121 | values.update({'total_amount': total_amount}) |
122 | # clear the additional amount if returned amount is updated |
123 | if additional_amount <> 0: |
124 | @@ -631,6 +628,9 @@ |
125 | |
126 | new_lines = [] |
127 | total = wizard.returned_amount or 0. # reuse current amount when adding new line |
128 | + # add the amount of advance lines |
129 | + for adv_line in wizard.advance_line_ids: |
130 | + total += adv_line.amount or 0.0 |
131 | added_invoice_ids = [ |
132 | wil.invoice_id.id for wil in wizard.invoice_line_ids ] |
133 | for invoice in invoices: |
134 | @@ -672,8 +672,6 @@ |
135 | |
136 | if new_lines: |
137 | vals = { |
138 | - # Change display_invoice to True in order to show invoice lines |
139 | - 'display_invoice': True, |
140 | 'invoice_line_ids': new_lines, |
141 | 'total_amount': total, |
142 | 'invoice_ids': [(6, 0, [])], # reset invoices picker |
143 | @@ -701,18 +699,7 @@ |
144 | but we show a confirm message at wizard validation |
145 | """ |
146 | |
147 | - display_invoice = False |
148 | - |
149 | - """ |
150 | - UTP-482: operation advance linked to a PO, force display_invoice |
151 | - if wizard.advance_linked_po_auto_invoice: |
152 | - display_invoice = True |
153 | - else: |
154 | - display_invoice = False |
155 | - """ |
156 | - |
157 | vals = { |
158 | - 'display_invoice': display_invoice, |
159 | 'invoice_ids': [(6, 0, [])] , # reset invoices picker |
160 | 'invoice_line_ids': [(5, )], # reset to import invoices |
161 | } |
162 | @@ -748,7 +735,6 @@ |
163 | wizard = self.browse(cr, uid, ids[0], context=context) |
164 | total = 0.0 |
165 | total += wizard.returned_amount |
166 | - # Do computation for invoice lines only if display_invoice is True |
167 | advance_settled_100_cash_return = self._is_advance_settled_100_cash_return(wizard) |
168 | if not advance_settled_100_cash_return: |
169 | """ |
170 | @@ -759,13 +745,12 @@ |
171 | '1 exception: if advance is settled through 100% cash return, |
172 | no need to link the advance return with an invoice' |
173 | """ |
174 | - if wizard.display_invoice: |
175 | - for move_line in wizard.invoice_line_ids: |
176 | - total += move_line.amount |
177 | - # else do computation for advance lines only |
178 | - else: |
179 | - for st_line in wizard.advance_line_ids: |
180 | - total+= st_line.amount |
181 | + # add the amount of invoice lines to the total |
182 | + for move_line in wizard.invoice_line_ids: |
183 | + total += move_line.amount |
184 | + # add the amount of advance lines to the total |
185 | + for st_line in wizard.advance_line_ids: |
186 | + total += st_line.amount |
187 | res.update({'total_amount': total}) |
188 | self.write(cr, uid, ids, res, context=context) |
189 | return { |
190 | @@ -821,7 +806,8 @@ |
191 | self.verify_date(cr, uid, ids, context=context) |
192 | # retrieve some values |
193 | if abs(wizard.initial_amount + wizard.additional_amount - wizard.total_amount) > 10**-3: |
194 | - raise osv.except_osv(_('Warning'), _('Initial advance amount (%s) does not match the amount you justified (%s). First correct. Then press Compute button') % (wizard.initial_amount, wizard.total_amount)) |
195 | + adv_amount = (wizard.initial_amount or 0.0) + (wizard.additional_amount or 0.0) |
196 | + raise osv.except_osv(_('Warning'), _('Advance amount (%s) does not match the amount you justified (%s). First correct. Then press Compute button.') % (adv_amount, wizard.total_amount or 0.0)) |
197 | |
198 | # determine the advance return reference (for the advance closing entry and advance expense lines/SI lines) |
199 | if wizard.reference: |
200 | @@ -875,55 +861,53 @@ |
201 | self.create_move_line(cr, uid, ids, wizard.date, wizard.date, adv_closing_name, journal, register, False, wizard.advance_st_line_id.employee_id.id, return_acc_id, \ |
202 | wizard.returned_amount, 0.0, adv_return_ref, move_id, False, context=context) |
203 | |
204 | - if wizard.display_invoice: |
205 | - # make treatment for invoice lines |
206 | - # create invoice lines |
207 | - inv_move_line_ids = [] |
208 | - for invoice in wizard.invoice_line_ids: |
209 | - inv_name = "Invoice" + " " + invoice.invoice_id.internal_number |
210 | - inv_doc_date = invoice.invoice_id.document_date |
211 | - partner_id = invoice.partner_id.id |
212 | - debit = invoice.amount |
213 | - credit = 0.0 |
214 | - account_id = invoice.account_id.id |
215 | - inv_id = self.create_move_line(cr, uid, ids, wizard.date, inv_doc_date, inv_name, journal, register, partner_id, False, account_id, \ |
216 | - debit, credit, adv_return_ref, move_id, False, context=context) |
217 | - inv_move_line_ids.append((inv_id, invoice.invoice_id.id)) |
218 | - else: |
219 | - # make treatment for advance lines |
220 | - # Prepare a list of advances that have a supplier and then demand generating some moves |
221 | - advances_with_supplier = {} |
222 | - # create move line from advance line |
223 | - adv_move_line_ids = [] |
224 | - for advance in wizard.advance_line_ids: |
225 | - # Case where line equals 0 |
226 | - if advance.amount == 0.0: |
227 | - continue |
228 | - adv_date = advance.document_date |
229 | - adv_name = advance.description |
230 | - partner_id = False |
231 | - line_employee_id = False |
232 | - partner = advance.partner_type |
233 | - if partner: |
234 | - if partner._name == 'res.partner': |
235 | - partner_id = partner.id |
236 | - if partner_id in advances_with_supplier: |
237 | - advances_with_supplier[partner_id].append(advance.id) |
238 | - else: |
239 | - advances_with_supplier[partner_id] = [advance.id] |
240 | - elif partner._name == 'hr.employee': |
241 | - line_employee_id = partner.id |
242 | - debit = abs(advance.amount) |
243 | - credit = 0.0 |
244 | - account_id = advance.account_id.id |
245 | - # Analytic distribution for this line |
246 | - distrib_id = (advance.analytic_distribution_id and advance.analytic_distribution_id.id) or \ |
247 | - (advance.wizard_id.analytic_distribution_id and advance.wizard_id.analytic_distribution_id.id) or False |
248 | - # other infos |
249 | - line_ref = advance.reference or adv_return_ref |
250 | - adv_id = self.create_move_line(cr, uid, ids, wizard.date, adv_date, adv_name, journal, register, partner_id, line_employee_id, account_id, \ |
251 | - debit, credit, line_ref, move_id, distrib_id, context=context) |
252 | - adv_move_line_ids.append(adv_id) |
253 | + # make treatment for invoice lines |
254 | + # create invoice lines |
255 | + inv_move_line_ids = [] |
256 | + for invoice in wizard.invoice_line_ids: |
257 | + inv_name = "Invoice" + " " + invoice.invoice_id.internal_number |
258 | + inv_doc_date = invoice.invoice_id.document_date |
259 | + partner_id = invoice.partner_id.id |
260 | + debit = invoice.amount |
261 | + credit = 0.0 |
262 | + account_id = invoice.account_id.id |
263 | + inv_id = self.create_move_line(cr, uid, ids, wizard.date, inv_doc_date, inv_name, journal, register, partner_id, False, account_id, \ |
264 | + debit, credit, adv_return_ref, move_id, False, context=context) |
265 | + inv_move_line_ids.append((inv_id, invoice.invoice_id.id)) |
266 | + # make treatment for advance lines |
267 | + # Prepare a list of advances that have a supplier and then demand generating some moves |
268 | + advances_with_supplier = {} |
269 | + # create move line from advance line |
270 | + adv_move_line_ids = [] |
271 | + for advance in wizard.advance_line_ids: |
272 | + # Case where line equals 0 |
273 | + if advance.amount == 0.0: |
274 | + continue |
275 | + adv_date = advance.document_date |
276 | + adv_name = advance.description |
277 | + partner_id = False |
278 | + line_employee_id = False |
279 | + partner = advance.partner_type |
280 | + if partner: |
281 | + if partner._name == 'res.partner': |
282 | + partner_id = partner.id |
283 | + if partner_id in advances_with_supplier: |
284 | + advances_with_supplier[partner_id].append(advance.id) |
285 | + else: |
286 | + advances_with_supplier[partner_id] = [advance.id] |
287 | + elif partner._name == 'hr.employee': |
288 | + line_employee_id = partner.id |
289 | + debit = abs(advance.amount) |
290 | + credit = 0.0 |
291 | + account_id = advance.account_id.id |
292 | + # Analytic distribution for this line |
293 | + distrib_id = (advance.analytic_distribution_id and advance.analytic_distribution_id.id) or \ |
294 | + (advance.wizard_id.analytic_distribution_id and advance.wizard_id.analytic_distribution_id.id) or False |
295 | + # other infos |
296 | + line_ref = advance.reference or adv_return_ref |
297 | + adv_id = self.create_move_line(cr, uid, ids, wizard.date, adv_date, adv_name, journal, register, partner_id, line_employee_id, account_id, \ |
298 | + debit, credit, line_ref, move_id, distrib_id, context=context) |
299 | + adv_move_line_ids.append(adv_id) |
300 | |
301 | # create the advance closing line |
302 | adv_closing_acc_id = wizard.advance_st_line_id.account_id.id |
303 | @@ -946,72 +930,72 @@ |
304 | # create the statement line for the invoices |
305 | absl_obj = self.pool.get('account.bank.statement.line') |
306 | curr_date = wizard.date |
307 | - if wizard.display_invoice: |
308 | - for inv_move_line_data in inv_move_line_ids: |
309 | - self.create_st_line_from_move_line(cr, uid, ids, register.id, move_id, inv_move_line_data[0], invoice_id=inv_move_line_data[1], context=context) |
310 | - # search the invoice move line that come from invoice |
311 | - invoice_move_id = self.pool.get('account.invoice').read(cr, uid, inv_move_line_data[1], ['move_id'], context=context).get('move_id', None) |
312 | - inv_move_line_account_id = move_line_obj.read(cr, uid, inv_move_line_data[0], ['account_id'], context=context).get('account_id', None) |
313 | - if invoice_move_id and inv_move_line_account_id: |
314 | - ml_ids = move_line_obj.search(cr, uid, [('move_id', '=', invoice_move_id[0]), ('account_id', '=', inv_move_line_account_id[0])], context=context) |
315 | - if not ml_ids or len(ml_ids) > 1: |
316 | - raise osv.except_osv(_('Error'), _('An error occurred on invoice reconciliation: Invoice line not found.')) |
317 | - # reconcile invoice line (from cash return) with specified invoice line (from invoice) |
318 | - move_line_obj.reconcile_partial(cr, uid, [ml_ids[0], inv_move_line_data[0]]) |
319 | - else: |
320 | - for adv_move_line_id in adv_move_line_ids: |
321 | - self.create_st_line_from_move_line(cr, uid, ids, register.id, move_id, adv_move_line_id, context=context) |
322 | - # Have you filled in the supplier field ? If yes let's go for creating some moves for them ! |
323 | - if advances_with_supplier: |
324 | - wiz_adv_line_obj = self.pool.get('wizard.advance.line') |
325 | - supp_move_ids = [] # to store the ids of the account moves created |
326 | - # Browse suppliers |
327 | - for supplier_id in advances_with_supplier: |
328 | - total = 0.0 |
329 | - # Calculate the total amount for the selected supplier |
330 | - for s_id in advances_with_supplier[supplier_id]: |
331 | - data = wiz_adv_line_obj.read(cr, uid, s_id, ['amount'], context=context) |
332 | - if 'amount' in data: |
333 | - total += data.get('amount') |
334 | - # create the move with 2 move lines for the supplier |
335 | - if total > 0: |
336 | - # prepare the move |
337 | - supp_move_info = wiz_adv_line_obj.read(cr, uid, advances_with_supplier[supplier_id][0], ['description', 'document_date'], context=context) |
338 | - supp_move_name = supp_move_info.get('description', "/") |
339 | - supp_move_date = supp_move_info.get('document_date', curr_date) |
340 | - supp_move_vals = { |
341 | - 'journal_id': journal.id, |
342 | - 'period_id': period_id, |
343 | - 'date': wizard.date, |
344 | - 'document_date': wizard.date, |
345 | - #'name': supp_move_name, ## Deleted in UF-1959. Was asked since UTP-330 and UF-1542. |
346 | - 'partner_id': supplier_id, |
347 | - } |
348 | - # search account_id of the supplier |
349 | - account_id = self.pool.get('res.partner').read(cr, uid, supplier_id, ['property_account_payable'], context=context) |
350 | - if 'property_account_payable' in account_id and account_id.get('property_account_payable', False): |
351 | - account_id = account_id.get('property_account_payable')[0] |
352 | - else: |
353 | - raise osv.except_osv(_('Warning'), _('One supplier seems not to have a payable account. \ |
354 | - Please contact an accountant administrator to resolve this problem.')) |
355 | - # Create the move |
356 | - supp_move_id = move_obj.create(cr, uid, supp_move_vals, context=context) |
357 | - supp_move_ids.append(supp_move_id) |
358 | - # Create move_lines |
359 | - supp_move_line_debit_id = self.create_move_line(cr, uid, ids, wizard.date, supp_move_date, supp_move_name, journal, register, supplier_id, False, \ |
360 | - account_id, total, 0.0, adv_return_ref, supp_move_id, False, context=context) |
361 | - supp_move_line_credit_id = self.create_move_line(cr, uid, ids, wizard.date, supp_move_date, supp_move_name, journal, register, supplier_id, False, \ |
362 | - account_id, 0.0, total, adv_return_ref, supp_move_id, False, context=context) |
363 | - # We hard post the move |
364 | - move_obj.post(cr, uid, [supp_move_id], context=context) |
365 | - # Verify that the posting has succeed |
366 | - if supp_move_id == False: |
367 | - raise osv.except_osv(_('Error'), _('An error has occurred: The journal entries cannot be posted.')) |
368 | - # Do reconciliation |
369 | - move_line_obj.reconcile_partial(cr, uid, [supp_move_line_debit_id, supp_move_line_credit_id]) |
370 | - # Update the statement line with the partner move ids ("Payable entries") |
371 | - if 'statement_line_id' in context: |
372 | - absl_obj.write(cr, uid, context['statement_line_id'], {'partner_move_ids': [(6, 0, supp_move_ids)]}, context) |
373 | + # handle invoice lines |
374 | + for inv_move_line_data in inv_move_line_ids: |
375 | + self.create_st_line_from_move_line(cr, uid, ids, register.id, move_id, inv_move_line_data[0], invoice_id=inv_move_line_data[1], context=context) |
376 | + # search the invoice move line that come from invoice |
377 | + invoice_move_id = self.pool.get('account.invoice').read(cr, uid, inv_move_line_data[1], ['move_id'], context=context).get('move_id', None) |
378 | + inv_move_line_account_id = move_line_obj.read(cr, uid, inv_move_line_data[0], ['account_id'], context=context).get('account_id', None) |
379 | + if invoice_move_id and inv_move_line_account_id: |
380 | + ml_ids = move_line_obj.search(cr, uid, [('move_id', '=', invoice_move_id[0]), ('account_id', '=', inv_move_line_account_id[0])], context=context) |
381 | + if not ml_ids or len(ml_ids) > 1: |
382 | + raise osv.except_osv(_('Error'), _('An error occurred on invoice reconciliation: Invoice line not found.')) |
383 | + # reconcile invoice line (from cash return) with specified invoice line (from invoice) |
384 | + move_line_obj.reconcile_partial(cr, uid, [ml_ids[0], inv_move_line_data[0]]) |
385 | + # handle advance lines |
386 | + for adv_move_line_id in adv_move_line_ids: |
387 | + self.create_st_line_from_move_line(cr, uid, ids, register.id, move_id, adv_move_line_id, context=context) |
388 | + # Have you filled in the supplier field ? If yes let's go for creating some moves for them ! |
389 | + if advances_with_supplier: |
390 | + wiz_adv_line_obj = self.pool.get('wizard.advance.line') |
391 | + supp_move_ids = [] # to store the ids of the account moves created |
392 | + # Browse suppliers |
393 | + for supplier_id in advances_with_supplier: |
394 | + total = 0.0 |
395 | + # Calculate the total amount for the selected supplier |
396 | + for s_id in advances_with_supplier[supplier_id]: |
397 | + data = wiz_adv_line_obj.read(cr, uid, s_id, ['amount'], context=context) |
398 | + if 'amount' in data: |
399 | + total += data.get('amount') |
400 | + # create the move with 2 move lines for the supplier |
401 | + if total > 0: |
402 | + # prepare the move |
403 | + supp_move_info = wiz_adv_line_obj.read(cr, uid, advances_with_supplier[supplier_id][0], ['description', 'document_date'], context=context) |
404 | + supp_move_name = supp_move_info.get('description', "/") |
405 | + supp_move_date = supp_move_info.get('document_date', curr_date) |
406 | + supp_move_vals = { |
407 | + 'journal_id': journal.id, |
408 | + 'period_id': period_id, |
409 | + 'date': wizard.date, |
410 | + 'document_date': wizard.date, |
411 | + #'name': supp_move_name, ## Deleted in UF-1959. Was asked since UTP-330 and UF-1542. |
412 | + 'partner_id': supplier_id, |
413 | + } |
414 | + # search account_id of the supplier |
415 | + account_id = self.pool.get('res.partner').read(cr, uid, supplier_id, ['property_account_payable'], context=context) |
416 | + if 'property_account_payable' in account_id and account_id.get('property_account_payable', False): |
417 | + account_id = account_id.get('property_account_payable')[0] |
418 | + else: |
419 | + raise osv.except_osv(_('Warning'), _('One supplier seems not to have a payable account. \ |
420 | + Please contact an accountant administrator to resolve this problem.')) |
421 | + # Create the move |
422 | + supp_move_id = move_obj.create(cr, uid, supp_move_vals, context=context) |
423 | + supp_move_ids.append(supp_move_id) |
424 | + # Create move_lines |
425 | + supp_move_line_debit_id = self.create_move_line(cr, uid, ids, wizard.date, supp_move_date, supp_move_name, journal, register, supplier_id, False, \ |
426 | + account_id, total, 0.0, adv_return_ref, supp_move_id, False, context=context) |
427 | + supp_move_line_credit_id = self.create_move_line(cr, uid, ids, wizard.date, supp_move_date, supp_move_name, journal, register, supplier_id, False, \ |
428 | + account_id, 0.0, total, adv_return_ref, supp_move_id, False, context=context) |
429 | + # We hard post the move |
430 | + move_obj.post(cr, uid, [supp_move_id], context=context) |
431 | + # Verify that the posting has succeed |
432 | + if supp_move_id == False: |
433 | + raise osv.except_osv(_('Error'), _('An error has occurred: The journal entries cannot be posted.')) |
434 | + # Do reconciliation |
435 | + move_line_obj.reconcile_partial(cr, uid, [supp_move_line_debit_id, supp_move_line_credit_id]) |
436 | + # Update the statement line with the partner move ids ("Payable entries") |
437 | + if 'statement_line_id' in context: |
438 | + absl_obj.write(cr, uid, context['statement_line_id'], {'partner_move_ids': [(6, 0, supp_move_ids)]}, context) |
439 | # reconcile advance and advance return lines |
440 | original_move_id = wizard.advance_st_line_id.move_ids[0] |
441 | criteria = [('statement_id', '=', wizard.advance_st_line_id.statement_id.id), ('account_id', '=', adv_closing_acc_id), ('move_id', '=', original_move_id.id)] |
442 | |
443 | === modified file 'bin/addons/register_accounting/wizard/wizard_cash_return.xml' |
444 | --- bin/addons/register_accounting/wizard/wizard_cash_return.xml 2017-07-03 14:27:01 +0000 |
445 | +++ bin/addons/register_accounting/wizard/wizard_cash_return.xml 2018-02-13 14:39:37 +0000 |
446 | @@ -11,7 +11,7 @@ |
447 | <field name="initial_amount"/> |
448 | <field name="additional_amount" on_change="onchange_addl_amount(returned_amount)"/> |
449 | <field name='returned_amount' |
450 | - on_change="onchange_returned_amount(returned_amount, invoice_line_ids, advance_line_ids, display_invoice, initial_amount, advance_linked_po_auto_invoice, additional_amount)"/> |
451 | + on_change="onchange_returned_amount(returned_amount, invoice_line_ids, advance_line_ids, initial_amount, advance_linked_po_auto_invoice, additional_amount)"/> |
452 | <newline /> |
453 | <field name='date'/> |
454 | <field name='reference' /> |
455 | @@ -35,14 +35,14 @@ |
456 | <button string='Add invoice(s)' name='action_add_invoice' type='object' icon='gtk-add' /> |
457 | </group> |
458 | <newline /> |
459 | - <field name='invoice_line_ids' attrs="{'invisible':[('display_invoice', '!=', True)]}" nolabel="1" colspan="4" /> |
460 | + <field name='invoice_line_ids' nolabel="1" colspan="4" /> |
461 | <newline /> |
462 | <group colspan="4"> |
463 | <label colspan="3"/> |
464 | - <button string="Clean invoices" name="clean_invoices" type="object" icon="gtk-clear" attrs="{'invisible':[('display_invoice', '!=', True)]}" /> |
465 | + <button string="Clean invoices" name="clean_invoices" type="object" icon="gtk-clear" /> |
466 | </group> |
467 | <newline /> |
468 | - <field name='advance_line_ids' attrs="{'invisible':[('display_invoice', '=', True)]}" nolabel="1" colspan="4" on_change="changeline(advance_line_ids, returned_amount, date, reference, additional_amount)"/> |
469 | + <field name='advance_line_ids' nolabel="1" colspan="4" on_change="changeline(advance_line_ids, returned_amount, invoice_line_ids, date, reference, additional_amount)"/> |
470 | <newline /> |
471 | <field name="total_amount"/> |
472 | <newline /> |
473 | @@ -55,7 +55,6 @@ |
474 | attrs="{'invisible': [('ok_with_confirm', '=', False)]}" /> |
475 | </group> |
476 | <field name='currency_id' invisible="1" /> |
477 | - <field name='display_invoice' invisible="1"/> |
478 | <field name="advance_linked_po_auto_invoice" invisible="1" /> |
479 | <field name="ok_with_confirm" invisible="1" /> |
480 | <field name="comment" colspan="4" nolabel="1" readonly="1" attrs="{'invisible':[('advance_linked_po_auto_invoice', '=', False)]}" /> |