[MERGE] OPW 51082: account_anglo_saxon: use account defined on product / product...
authorXavier ALT <xal@openerp.com>
Wed, 25 Apr 2012 10:20:20 +0000 (12:20 +0200)
committerXavier ALT <xal@openerp.com>
Wed, 25 Apr 2012 10:20:20 +0000 (12:20 +0200)
bzr revid: xal@openerp.com-20120425102020-s6y8gadnbc5relvt

1  2 
addons/account_anglo_saxon/product.py

@@@ -86,6 -87,31 +87,31 @@@ class product_template(osv.osv)
      }
  product_template()
  
+ class product_product(osv.osv):
+     _inherit = "product.product"
 -    
++
+     def do_change_standard_price(self, cr, uid, ids, datas, context=None):
+         """ Changes the Standard Price of Product and creates an account move accordingly.
+         @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal
+         @param context: A standard dictionary
+         @return:
+         """
+         product_obj=self.browse(cr, uid, ids, context=context)[0]
+         stock_price_diff_account = product_obj.property_account_creditor_price_difference and product_obj.property_account_creditor_price_difference.id or False
 -        
++
+         if not stock_price_diff_account:
+             stock_price_diff_account = product_obj.categ_id.property_account_creditor_price_difference_categ and product_obj.categ_id.property_account_creditor_price_difference_categ.id or False
+         if not stock_price_diff_account:
 -            raise osv.except_osv(_('Error!'),_('There is no price diffrent account defined ' \
++            raise osv.except_osv(_('Error!'),_('There is no price difference account defined ' \
+                                                'for this product: "%s" (id: %d)') % (product_obj.name, product_obj.id,))
+         datas['stock_input_account'] = stock_price_diff_account
+         datas['stock_output_account'] = stock_price_diff_account
 -            
++
+         return super(product_product, self).do_change_standard_price(cr, uid, ids, datas, context)
 -    
++
+ product_product()
  
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: