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

Proposed by jftempo on 2018-07-09
Status: Merged
Merged at revision: 4972
Proposed branch: lp:~julie-w/unifield-server/US-4778
Merge into: lp:unifield-server
Diff against target: 52 lines (+11/-8)
2 files modified
bin/addons/register_accounting/purchase.py (+7/-7)
bin/addons/register_accounting/wizard/down_payment.py (+4/-1)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4778
Reviewer Review Type Date Requested Status
UniField Reviewer Team 2018-07-09 Pending
Review via email: mp+349121@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/register_accounting/purchase.py'
2--- bin/addons/register_accounting/purchase.py 2017-11-27 15:38:38 +0000
3+++ bin/addons/register_accounting/purchase.py 2018-07-09 08:35:51 +0000
4@@ -52,13 +52,13 @@
5
6 To be 100% invoiced, a PO should have some linked invoiced that are validated ('open' state or 'paid' state) and that sum of amount is greater or equal to PO total amount. So to find PO that are not 100% invoiced, you should find those from which all invoice are not created or which amount is inferior to PO total amount.
7
8- BKLG-51: new filters
9- 1) On PO state: only allow "confirmed" or "confirmed (waiting)" POs to be selected in the wizard
10- (keeping 'done' for not completly invoiced)
11- 2) On PO type: only allow regular, purchase list and direct purchase order PO types
12+ BKLG-51 / US-3782: new filters
13+ 1) On PO LINE state: only allow PO having at least one line in Confirmed State, or Closed State if the related
14+ invoice is still in Draft state or Cancelled
15+ 2) On PO type: only allow regular and "purchase list" purchase order types
16 3) Make sure that RFQs or tenders can not be linked to down payments
17- 1) state 'confirm_waiting' + 'approved' + 'done' (done tolerated if partially invoiced)
18- 2) order_type 'regular', 'purchase_list', 'direct'
19+ 1) line state 'confirmed' + 'done' (done tolerated if invoice still in Draft state)
20+ 2) order_type 'regular', 'purchase_list'
21 3) rfq_ok != True
22
23 US-1064: new rule: as soon as all goods are received on a PO (state 'done') no new Down Payment is possible
24@@ -81,7 +81,7 @@
25 where pir.invoice_id = inv.id AND inv.state not in ('draft', 'cancel')
26 group by pir.purchase_id) inv on inv.purchase_id = po.id
27 LEFT JOIN product_pricelist as prod ON (po.pricelist_id = prod.id AND prod.currency_id = %s)
28- LEFT JOIN (select pol1.order_id, sum(pol1.price_unit * pol1.product_qty) as total
29+ INNER JOIN (select pol1.order_id, sum(pol1.price_unit * pol1.product_qty) as total
30 from purchase_order_line pol1
31 where pol1.state in ('confirmed', 'done') group by pol1.order_id) pol on pol.order_id=po.id
32 WHERE po.pricelist_id = prod.id
33
34=== modified file 'bin/addons/register_accounting/wizard/down_payment.py'
35--- bin/addons/register_accounting/wizard/down_payment.py 2017-11-27 15:38:38 +0000
36+++ bin/addons/register_accounting/wizard/down_payment.py 2018-07-09 08:35:51 +0000
37@@ -86,11 +86,14 @@
38
39 # Cut away open and paid invoice linked to this PO
40 invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('purchase_ids', 'in', [po_id]), ('state', 'in', ['paid', 'open'])])
41+ included_dp_amls = []
42 for inv in self.pool.get('account.invoice').read(cr, uid, invoice_ids, ['amount_total', 'down_payment_ids']):
43 lines_amount -= inv.get('amount_total', 0.0)
44- dp_ids = inv.get('down_payment_ids', None)
45+ dp_ids = [dp_aml_id for dp_aml_id in inv.get('down_payment_ids', []) if dp_aml_id not in included_dp_amls]
46 for dp in self.pool.get('account.move.line').read(cr, uid, dp_ids, ['down_payment_amount']):
47 lines_amount += dp.get('down_payment_amount', 0.0)
48+ # store each DP JI included in the calculation so its amount is counted only once (even if linked to several SIs)
49+ included_dp_amls.append(dp.get('id'))
50
51 total_amount = lines_amount + absl.amount
52 if (total + total_amount) < -0.001:

Subscribers

People subscribed via source and target branches