Kirti Savalia(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-889093-yml-ksa into 
lp:openobject-addons.

Requested reviews:
  Kirti Savalia(OpenERP) (ksa-openerp)
  Rucha (Open ERP) (rpa-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-889093-yml-ksa/+merge/83923

->Add demo data for product category with account information
->check real time valuation for stock value.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-889093-yml-ksa/+merge/83923
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-889093-yml-ksa.
=== modified file 'purchase/__openerp__.py'
--- purchase/__openerp__.py	2011-12-06 11:21:27 +0000
+++ purchase/__openerp__.py	2011-12-08 10:01:28 +0000
@@ -67,6 +67,7 @@
         'test/process/run_scheduler.yml',
         'test/process/merge_order.yml',
         'test/process/edi_purchase_order.yml',
+        'test/process/real_time_valuation.yml',
         'test/ui/print_report.yml',
         'test/ui/duplicate_order.yml',
         'test/ui/delete_order.yml',

=== modified file 'purchase/purchase.py'
--- purchase/purchase.py	2011-12-01 21:32:12 +0000
+++ purchase/purchase.py	2011-12-08 10:01:28 +0000
@@ -727,10 +727,12 @@
     # - name of method should "onchange_product_id"
     # - docstring
     # - merge 'product_uom_change' method
-    # - split into small internal methods for clearity 
+    # - split into small internal methods for clearity
     def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
             partner_id, date_order=False, fiscal_position=False, date_planned=False,
-            name=False, price_unit=False, notes=False, context={}):
+            name=False, price_unit=False, notes=False, context=None):
+        if context is None:
+            context = {}
         if not pricelist:
             raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.'))
         if not  partner_id:
@@ -744,11 +746,14 @@
         lang=False
         if partner_id:
             lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang']
-        context={'lang':lang}
+        context['lang'] = lang
         context['partner_id'] = partner_id
 
         prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
         prod_uom_po = prod.uom_po_id.id
+
+        if uom and prod and (uom <> prod_uom_po):
+            uom = prod_uom_po
         if not uom:
             uom = prod_uom_po
         if not date_order:
@@ -773,6 +778,7 @@
                 if qty < temp_qty: # If the supplier quantity is greater than entered from user, set minimal.
                     qty = temp_qty
                     res.update({'warning': {'title': _('Warning'), 'message': _('The selected supplier has a minimal quantity set to %s, you should not purchase less.') % qty}})
+        uom = context.get('uom_change', uom)
         qty_in_product_uom = product_uom_pool._compute_qty(cr, uid, uom, qty, to_uom_id=prod.uom_id.id)
         price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist],
                     product, qty_in_product_uom or 1.0, partner_id, {
@@ -786,7 +792,7 @@
             'taxes_id':map(lambda x: x.id, prod.supplier_taxes_id),
             'date_planned': date_planned or dt,'notes': notes or prod.description_purchase,
             'product_qty': qty,
-            'product_uom': prod.uom_id.id}})
+            'product_uom': uom or prod_uom_po}})
         domain = {}
 
         taxes = self.pool.get('account.tax').browse(cr, uid,map(lambda x: x.id, prod.supplier_taxes_id))
@@ -808,7 +814,7 @@
             name=False, price_unit=False, notes=False, context={}):
         res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom,
                 partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned,
-            name=name, price_unit=price_unit, notes=notes, context=context)
+            name=name, price_unit=price_unit, notes=notes, context={'uom_change': uom})
         if 'product_uom' in res['value']:
             if uom and (uom != res['value']['product_uom']) and res['value']['product_uom']:
                 seller_uom_name = self.pool.get('product.uom').read(cr, uid, [res['value']['product_uom']], ['name'])[0]['name']

=== modified file 'purchase/purchase_order_demo.yml'
--- purchase/purchase_order_demo.yml	2011-11-14 21:33:19 +0000
+++ purchase/purchase_order_demo.yml	2011-12-08 10:01:28 +0000
@@ -74,3 +74,23 @@
       - product_id: product.product_product_1
         product_qty: 15
 
+-
+  !record {model: product.product, id: product_sugar_id_50kg}:
+    default_code: SUGAR50KG
+    supply_method: buy
+    list_price: 110.0
+    standard_price: 3600.0
+    uom_id: product.product_uom_kgm
+    uom_po_id: product.product_uom_gram
+    name: SUGAR of 50KG
+    valuation: real_time
+    property_stock_account_input: account.o_expense
+    property_stock_account_output: account.o_income
+    categ_id: product.product_category_rawmaterial0
+
+-
+  !record {model: purchase.order, id: order_purchase_sugar}:
+    partner_id: base.res_partner_asus
+    order_line:
+      - product_id: product_sugar_id_50kg
+

=== added file 'purchase/test/process/real_time_valuation.yml'
--- purchase/test/process/real_time_valuation.yml	1970-01-01 00:00:00 +0000
+++ purchase/test/process/real_time_valuation.yml	2011-12-08 10:01:28 +0000
@@ -0,0 +1,37 @@
+-
+   In order to test real time stock valuation flow, I confirmed the purchase order.
+-
+  !workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase_sugar}
+-
+  I check that the order which was initially in the draft state has transmit to approved state.
+-
+  !assert {model: purchase.order, id: order_purchase_sugar}:
+    - state == 'approved'
+-
+  In order to test check that picking is generated or not.
+-
+  !python {model: purchase.order}: |
+    purchase_order = self.browse(cr, uid, ref("order_purchase_sugar"))
+    assert len(purchase_order.picking_ids) >= 1, "You should have only one reception order"
+    for picking in purchase_order.picking_ids:
+      assert picking.purchase_id.id == purchase_order.id
+-
+  Reception is ready for process so now done the reception.
+-
+  !python {model: stock.partial.picking}: |
+    pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("order_purchase_sugar")).picking_ids
+    partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
+    self.do_partial(cr, uid, [partial_id])
+-
+  Check the Journal having proper amount or not.
+-
+  !python {model: account.move.line}: |
+    pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("order_purchase_sugar")).picking_ids
+    for data in pick_ids:
+      for moveline in data.move_lines:
+        ids = self.pool.get('account.move.line').search(cr, uid, [('ref','=',data.name),('partner_id','=',data.partner_id.id)])
+        item_data = self.pool.get('account.move.line').browse(cr, uid, ids)
+        for item in item_data:
+            if item.account_id.id == moveline.product_id.property_stock_account_input.id:
+                assert item.credit == 3.6, "Journal items have not proper credit amount"
+                assert item.debit == 0.0, "Journal items have not proper debit amount"

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to