Merge lp:~openerp-dev/openobject-addons/6.1-opw-579043-ado into lp:openobject-addons/6.1

Proposed by Amit Dodiya (OpenERP)
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: no longer in the source branch.
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-579043-ado
Merge into: lp:openobject-addons/6.1
Diff against target: 142 lines (+91/-14)
1 file modified
mrp_subproduct/mrp_subproduct.py (+91/-14)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-579043-ado
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+125672@code.launchpad.net

Description of the change

Hello,

[FIX] mrp_subproduct doesnt pull sub products from bill of material when we have type phantom"

Issue :
After adding a suproduct line in Bill of matirial of type=Phantom we hope to see the material asigned in sub product of phantom bill of material when confirming the production order with the parent bill of material that the mrp_subproduct fills in finished product, but it doesn't do it.

Steps:
Check this video : http://youtu.be/Fp4Vj5aNtrw

Regards,
Amit Dodiya

To post a comment you must log in.
6999. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7000. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7001. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7002. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7003. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7004. By Olivier Dony (Odoo)

[FIX] OPW 574637: account_analytic_plans: remove the strange behavior of instance editing - a thing of the past

7005. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7006. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7007. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7008. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7009. By Xavier ALT

[MERGE] OPW 50562: stock: fix picking type for chained picking

  forward port of v6.0 revid: <email address hidden>

7010. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7011. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7012. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7013. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7014. By Olivier Dony (Odoo)

[MERGE] OPW 579232: mrp: better handle partial consumption of raw products that were split in production lots

- System will no longer consume every line of raw product after a split
- If a raw product line with the exact quantity to consume is present,
  only this one will be consumed
- If no raw product line matches the quantity to consume, the system
  will consume the available lines (starting with smallest quantities first)
  until it attains the required quantity, possibly splitting one line
  further if no combination of the existing lines gives the right
  quantity.
- The production lot column and the split button will now be available
  on both sides of the production order form, allowing fine control
  of the production lots that were consumed, in case the defaults
  do not match what was used in reality.

7015. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7016. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7017. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7018. By Xavier ALT

[MERGE] OPW 577045: translations: collective fix of missing translation terms in reports

7019. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7020. By Xavier ALT

[MERGE] OPW 575716: account: force account.financial.report balance of *zero* to be displayed positively

7021. By Xavier ALT

[MERGE] OPW 579553: account: fix traceback when modifing existing journal entry line

7022. By Xavier ALT

[MERGE] OPW 576019: sale/purchase: when changing SO or PO line product, use product's UoM even if current UoM is of the same category

7023. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7024. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7025. By Stephane Wirtel (OpenERP)

[FIX] point_of_sale: remove unused file

7026. By Xavier ALT

[MERGE] OPW 578622: project: duplicating project must reset analytic account code

7027. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7028. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7029. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7030. By Olivier Dony (Odoo)

[FIX] wiki: remove unused 6.0 web addon components - web API was rewritten from scratch in 6.1

7031. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7032. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7033. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7034. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7035. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7036. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7037. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7038. By Xavier ALT

[MERGE] OPW 577723: purchase: add domain on purchase order partner field for autocomplete to search only for suppliers

7039. By Xavier ALT

[MERGE] OPW 577045: account/hr_holidays: fix untranslated string and 'Filter By' display on account reports

7040. By Xavier ALT

[MERGE] OPW 576804: hr_holidays: fix problem with accentuated chars in 'Leaves by Department' report

7041. By Xavier ALT

[MERGE] OPW 579990: account: changing invoice line account should take product taxes or account taxes, not both

  backport of trunk addons revid: <email address hidden>

7042. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7043. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7044. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7045. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7046. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7047. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7048. By Xavier ALT

[MERGE] OPW 579331: base_vat: button check_vat should not return 'None' uppon success - this will cause error for clients using XML-RPC

7049. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7050. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7051. By Xavier ALT

[MERGE] OPW 578792: project_issue/resource: fix calc. of open/close & working hours to open/close on issue + has to be timezone aware

7052. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7053. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7054. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7055. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7056. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7057. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7058. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7059. By Olivier Dony (Odoo)

[FIX] project_issue: fix access rights error when using portal access

Due to the recent change in the computation of the closing duration
for project issues[1], viewing issues now fails for users who do not
have read access to project.project. This is typically the case for
portal users, who can view their own issues but not the project details.
Doing the computation in superuser mode does not cause any security
problem and avoids the access rights error.

7060. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7061. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7062. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7063. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7064. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7065. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7066. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7067. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7068. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7069. By Xavier ALT

[MERGE] OPW 576829: pos: fix creation of payment line when pos order have multiple payment methods + return

   partial trunk backport revid: <email address hidden>,
     <email address hidden>

7070. By Xavier ALT

[MERGE] OPW 576495: stock: fix missing 'state' field in view - required for button states evaluation

7071. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7072. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7073. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7074. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7075. By Antony Lesuisse (OpenERP)

[FIX] crm.lead add missing group_by country

7076. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7077. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7078. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7079. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7080. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7081. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7082. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7083. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7084. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7085. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7086. By Xavier ALT

[MERGE] OPW 581296: account_voucher: allow reconciling invoices with partially reconciled credit notes

7087. By Xavier ALT

[MERGE] OPW 577037: account_voucher: 'import entries' wizard should allow selecting credit notes

  cumulative forward-port of v6.0 revids:
  - <email address hidden>
  - <email address hidden>
  - <email address hidden>

7088. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7089. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7090. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7091. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7092. By Xavier ALT

[MERGE] 577037: account_voucher: also allow matching payment line with bank, cash journal for existing 'advanced payment'

7093. By Xavier ALT

[FIX] account_voucher: make sure we do not match move lines that are totally used within partial payment

7094. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7095. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7096. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7097. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7098. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

it seems big changes to incorporate in stable !

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-579043-port-kbh/+merge/138114 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

7099. By Amit Dodiya<email address hidden>

[FIX] mrp_subproduct doesnt pull sub products from bill of material when we have type phantom

Unmerged revisions

7099. By Amit Dodiya<email address hidden>

[FIX] mrp_subproduct doesnt pull sub products from bill of material when we have type phantom

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp_subproduct/mrp_subproduct.py'
2--- mrp_subproduct/mrp_subproduct.py 2012-02-14 15:57:46 +0000
3+++ mrp_subproduct/mrp_subproduct.py 2012-12-10 08:57:21 +0000
4@@ -22,6 +22,7 @@
5 from osv import fields
6 from osv import osv
7 import decimal_precision as dp
8+import tools
9
10 class mrp_subproduct(osv.osv):
11 _name = 'mrp.subproduct'
12@@ -61,6 +62,79 @@
13 _columns={
14 'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
15 }
16+
17+ def _bom_explode(self, cr, uid, bom, factor, properties=[], addthis=False, level=0, routing_id=False, result_subproducts=False):
18+ """ Finds sub products and work centers for related bom lines which has several sub products defined in it.
19+ @param bom: BoM of particular product.
20+ @param factor: Factor of product UoM.
21+ @param properties: A List of properties Ids.
22+ @param addthis: If BoM found then True else False.
23+ @param level: Depth level to find BoM lines starts from 10.
24+ @return: result: List of dictionaries containing product details.
25+ result2: List of dictionaries containing Work Center details.
26+ """
27+ if result_subproducts is False:
28+ result_subproducts = []
29+ if self._columns.has_key('sub_products'):#if module mrp_subproduct is installed
30+ for sub_product in bom.sub_products:
31+ qty1 = sub_product.product_qty
32+ if sub_product.subproduct_type == 'variable':
33+ qty1 = factor*qty1/bom.product_uom.factor_inv
34+ result_subproducts.append({
35+ 'product_id': sub_product.product_id.id,
36+ 'product_qty': qty1,
37+ 'product_uom': sub_product.product_uom.id,
38+ })
39+ routing_obj = self.pool.get('mrp.routing')
40+ factor = factor / (bom.product_efficiency or 1.0)
41+ factor = rounding(factor, bom.product_rounding)
42+ if factor < bom.product_rounding:
43+ factor = bom.product_rounding
44+ result = []
45+ result2 = []
46+ phantom = False
47+ if bom.type == 'phantom' and not bom.bom_lines:
48+ newbom = self._bom_find(cr, uid, bom.product_id.id, bom.product_uom.id, properties)
49+
50+ if newbom:
51+ newbom_pool = self.browse(cr, uid, newbom)
52+ res = self._bom_explode(cr, uid, self.browse(cr, uid, [newbom])[0], factor*bom.product_qty/(newbom_pool.product_qty*newbom_pool.product_uom.factor_inv), properties, addthis=True, level=level+10, result_subproducts=result_subproducts)
53+ result = result + res[0]
54+ result2 = result2 + res[1]
55+ phantom = True
56+ else:
57+ phantom = False
58+ if not phantom:
59+ if addthis and not bom.bom_lines:
60+ result.append(
61+ {
62+ 'name': bom.product_id.name,
63+ 'product_id': bom.product_id.id,
64+ 'product_qty': bom.product_qty * factor,
65+ 'product_uom': bom.product_uom.id,
66+ 'product_uos_qty': bom.product_uos and bom.product_uos_qty * factor or False,
67+ 'product_uos': bom.product_uos and bom.product_uos.id or False,
68+ })
69+ routing = (routing_id and routing_obj.browse(cr, uid, routing_id)) or bom.routing_id or False
70+ if routing:
71+ for wc_use in routing.workcenter_lines:
72+ wc = wc_use.workcenter_id
73+ d, m = divmod(factor, wc_use.workcenter_id.capacity_per_cycle)
74+ mult = (d + (m and 1.0 or 0.0))
75+ cycle = mult * wc_use.cycle_nbr
76+ result2.append({
77+ 'name': tools.ustr(wc_use.name) + ' - ' + tools.ustr(bom.product_id.name),
78+ 'workcenter_id': wc.id,
79+ 'sequence': level+(wc_use.sequence or 0),
80+ 'cycle': cycle,
81+ 'hour': float(wc_use.hour_nbr*mult + ((wc.time_start or 0.0)+(wc.time_stop or 0.0)+cycle*(wc.time_cycle or 0.0)) * (wc.time_efficiency or 1.0)),
82+ })
83+ for bom2 in bom.bom_lines:
84+ res = self._bom_explode(cr, uid, bom2, factor, properties, addthis=True, level=level+10, result_subproducts=result_subproducts)
85+ result = result + res[0]
86+ result2 = result2 + res[1]
87+ return result, result2
88+
89
90 mrp_bom()
91
92@@ -73,27 +147,24 @@
93 """ Confirms production order and calculates quantity based on subproduct_type.
94 @return: Newly generated picking Id.
95 """
96+ bom_obj = self.pool.get('mrp.bom')
97+ uom_obj = self.pool.get('product.uom')
98 picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
99 for production in self.browse(cr, uid, ids):
100 source = production.product_id.product_tmpl_id.property_stock_production.id
101- if not production.bom_id:
102+ bom_id = production.bom_id
103+ if not bom_id:
104 continue
105- for sub_product in production.bom_id.sub_products:
106- qty1 = sub_product.product_qty
107- qty2 = production.product_uos and production.product_uos_qty or False
108- if sub_product.subproduct_type == 'variable':
109- if production.product_qty:
110- qty1 *= production.product_qty / (production.bom_id.product_qty or 1.0)
111- if production.product_uos_qty:
112- qty2 *= production.product_uos_qty / (production.bom_id.product_uos_qty or 1.0)
113+ factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_id.product_uom.id)
114+ result_subproducts =[]
115+ res = bom_obj._bom_explode(cr, uid, bom_id, factor / bom_id.product_qty, properties=False, routing_id=False, result_subproducts=result_subproducts)
116+ for sub_product in result_subproducts:
117 data = {
118 'name': 'PROD:'+production.name,
119 'date': production.date_planned,
120- 'product_id': sub_product.product_id.id,
121- 'product_qty': qty1,
122- 'product_uom': sub_product.product_uom.id,
123- 'product_uos_qty': qty2,
124- 'product_uos': production.product_uos and production.product_uos.id or False,
125+ 'product_id': sub_product['product_id'],
126+ 'product_qty': sub_product['product_qty'],
127+ 'product_uom': sub_product['product_uom'],
128 'location_id': source,
129 'location_dest_id': production.location_dest_id.id,
130 'move_dest_id': production.move_prod_id.id,
131@@ -127,6 +198,12 @@
132
133 mrp_production()
134
135+def rounding(f, r):
136+ import math
137+ if not r:
138+ return f
139+ return math.ceil(f / r) * r
140+
141 class change_production_qty(osv.osv_memory):
142 _inherit = 'change.production.qty'
143