Merge lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale into lp:~clearcorp-drivers/openobject-addons/elico-7.0-ccorp

Proposed by Ronald Rubi
Status: Merged
Merged at revision: 37
Proposed branch: lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale
Merge into: lp:~clearcorp-drivers/openobject-addons/elico-7.0-ccorp
Diff against target: 82 lines (+50/-0)
2 files modified
base_intercompany_sale/purchase.py (+25/-0)
base_intercompany_sale/sale.py (+25/-0)
To merge this branch: bzr merge lp:~rr.clearcorp/openobject-addons/7.0-base_intercompany_sale
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+229257@code.launchpad.net

Description of the change

[FIX] Fix discount. price_unit and taxes in base_intercompany_sale

To post a comment you must log in.
37. By Ronald Rubi

[MRG] Fix discount. price_unit and taxes in base_intercompany_sale

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_intercompany_sale/purchase.py'
2--- base_intercompany_sale/purchase.py 2014-02-18 12:28:09 +0000
3+++ base_intercompany_sale/purchase.py 2014-08-01 16:39:58 +0000
4@@ -277,6 +277,8 @@
5
6 @mapping
7 def price(self, record):
8+ if record.price_unit:
9+ return {'price_unit': record.price_unit}
10 if not record.product_id:
11 return {'price_unit': 0}
12 sess = self.session
13@@ -294,3 +296,26 @@
14 record.product_id.id, record.product_qty)
15 price = price_unit[int(pricelist_id)]
16 return {'price_unit': price}
17+
18+ @mapping
19+ def discount(self, record):
20+ if record.discount:
21+ return {'discount': record.discount}
22+ return {'discount': 0}
23+
24+ @mapping
25+ def taxes(self, record):
26+ sess = self.session
27+ backend = self._backend_to
28+ ic_uid = backend.icops_uid.id
29+ taxes_id = []
30+ if record.order_id:
31+ if record.product_id:
32+ for tax in record.product_id.taxes_id:
33+ if tax.company_id.id == backend.company_id.id:
34+ taxes_id.append(tax)
35+ line_tax_ids = sess.pool.get('account.fiscal.position').map_tax(sess.cr, ic_uid, record.order_id.fiscal_position, taxes_id)
36+ line_taxs = sess.pool.get('account.tax').browse(sess.cr, ic_uid, line_tax_ids)
37+ tax_id = [(6, 0, [x.id for x in line_taxs])]
38+ return {'tax_id': tax_id}
39+ return {'tax_id': []}
40
41=== modified file 'base_intercompany_sale/sale.py'
42--- base_intercompany_sale/sale.py 2014-02-18 12:28:09 +0000
43+++ base_intercompany_sale/sale.py 2014-08-01 16:39:58 +0000
44@@ -332,6 +332,8 @@
45 return {'name': record.name}
46
47 def _price(self, record, is_po=False):
48+ if record.price_unit:
49+ return {'price_unit': record.price_unit}
50 if not record.product_id:
51 return {'price_unit': 0}
52 sess = self.session
53@@ -355,6 +357,29 @@
54 record.product_id.id, record.product_uom_qty)
55 price = price_unit[int(pricelist_id)]
56 return {'price_unit': price}
57+
58+ @mapping
59+ def discount(self, record):
60+ if record.discount:
61+ return {'discount': record.discount}
62+ return {'discount': 0}
63+
64+ @mapping
65+ def taxes(self, record):
66+ sess = self.session
67+ backend = self._backend_to
68+ ic_uid = backend.icops_uid.id
69+ taxes_id = []
70+ if record.order_id:
71+ if record.product_id:
72+ for tax in record.product_id.taxes_id:
73+ if tax.company_id.id == backend.company_id.id:
74+ taxes_id.append(tax)
75+ line_tax_ids = sess.pool.get('account.fiscal.position').map_tax(sess.cr, ic_uid, record.order_id.fiscal_position, taxes_id)
76+ line_taxs = sess.pool.get('account.tax').browse(sess.cr, ic_uid, line_tax_ids)
77+ tax_id = [(6, 0, [x.id for x in line_taxs])]
78+ return {'taxes_id': tax_id}
79+ return {'taxes_id': []}
80
81 @mapping
82 def map_all(self, record):

Subscribers

People subscribed via source and target branches

to all changes: